Skip to content

feat: add field expression type helpers - #726

Open
JimmyLiuJia wants to merge 1 commit into
jmrozanec:masterfrom
JimmyLiuJia:feat/field-expression-type-helpers
Open

JimmyLiuJia wants to merge 1 commit into
jmrozanec:masterfrom
JimmyLiuJia:feat/field-expression-type-helpers

Conversation

@JimmyLiuJia

Copy link
Copy Markdown

Inspecting a cron field's expression type currently requires callers to check concrete expression classes. Add FieldExpression.isAlways() and FieldExpression.isEvery() as convenient predicates for wildcard and step expressions, addressing #690.

The predicates inspect the top-level expression type. Parsed */1 is normalized to Always, whereas a directly constructed Every(1) remains Every even though it renders as *. An And containing a step expression returns false for both predicates. Javadoc explains these boundaries and points callers to Every.getPeriod() for the step value.

Tests cover parsed wildcards, steps, ranges, fixed values and lists, plus Every(1), a deserialized Always, QuestionMark, and a custom expression subclass.

Validation on JDK 17:

  • mvn -B -ntp clean verify passed, including binary, source and Javadoc JAR generation. Surefire reported 814 tests, 0 failures, 0 errors and 57 skipped.
  • FieldExpressionTest: 13 cases, 0 failures, 0 errors and 0 skipped.

Fixes #690.

AI assistance: OpenAI Codex assisted with the implementation, tests and PR description.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support more helper functions within FieldExpression

1 participant