Skip to content

10.0.0: make PolicyCategory an open value class, so an unknown category is typed rather than null #240

Description

@saurabhjain1592

What

PolicyTypes.PolicyCategory (src/main/java/com/getaxonflow/sdk/types/policies/PolicyTypes.java) is a closed enum with a @JsonValue getter only. The platform sends categories outside it: pdp/shipped_posture.json at enterprise 857455033 carries 14, five of which the enum lacks (security-dangerous, compliance-euaiact, dangerous_queries, pii_detection, sql_injection). A closed enum cannot represent a value this build does not know.

For 9.x the fix is additive, so nothing breaks on the release train:

  • the enum gains the five constants;
  • the read types keep the wire string, so a read-then-write round-trips byte-exact;
  • getCategory() returns the enum, or null for a category this build does not know;
  • getCategoryValue() is the lossless form;
  • the builders gain a category(String) overload.

The null from getCategory() is a temporary cost of staying source-compatible, not the design.

The 10.0.0 shape

Make PolicyCategory an open value class, on the pattern authzen.AuthZENObligationType already uses:

  • public static final constants for the known values;
  • PolicyCategory.of(String), with @JsonCreator, returning the constant or a carrier for an unknown value;
  • isKnown();
  • @JsonValue value();
  • equals and hashCode on the value.

An unknown category is then typed everywhere, in reads, requests and builders, instead of null, and the getCategoryValue() / category(String) pair from 9.x can be deprecated.

The change is source-breaking for callers that switch on the enum or use valueOf, values(), ordinal(), EnumSet or EnumMap. So it belongs in a major release. Inside the SDK the only enum-only uses today are four PolicyCategory.valueOf lines in MediaGovernanceTypesTest.

PolicyTier stays a closed enum: the platform constrains a static policy's tier to system, organization and tenant by a database CHECK (enterprise migrations/core/030_policy_tier_columns.sql:14 and :47).

Refs getaxonflow/axonflow-enterprise#4224 (the spec's category enum is staler than every SDK).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions