Class PolicyExpression

java.lang.Object
com.eqixiac.equinix.iam.model.PolicyExpression

public final class PolicyExpression extends Object
A lossless, typed wrapper for the polymorphic oneOf union members used throughout the IAM access-control schemas - the permissions/intersect/subtract entries of an AccessPolicy, PermissionSet and PrincipalPolicy, and the managedPolicies/managedPermissionSets/subtract fields of a PolicyMask.

Each of these union members may be:

  • a bare string - a literal such as "none" / "all", an Equinix Resource Name (ERN), a permissionset:/managedset:/managedpolicy: id, etc.; or
  • a structured value - an inline-permission object, a foreign-access-policy reference, a general permission-set reference, an array of ids, a subtract object, and so on.

Rather than collapsing this to a raw Object (which loses type fidelity and is awkward to inspect), a PolicyExpression preserves whichever form was received on read and emits exactly that form on write. Internally it carries the underlying JsonNode verbatim, so both the string and structured shapes round-trip losslessly; serialization simply re-emits the captured node via toJsonNode() (annotated JsonValue), and deserialization captures any incoming JSON via fromJsonNode(JsonNode) (annotated JsonCreator).

Convenience accessors (isString(), asString(), isArray(), asStringList(), isObject()) let callers branch on the form without depending on Jackson types, while toJsonNode() exposes the full structure for richer navigation.

  • Method Summary

    Modifier and Type
    Method
    Description
     
    Returns the array members as strings when this entry is an array of textual values, otherwise null.
    boolean
    equals(Object other)
     
    fromJsonNode(com.fasterxml.jackson.databind.JsonNode node)
    Captures an arbitrary deserialized JSON value (string, array or object) verbatim.
    int
     
    boolean
     
    boolean
     
    boolean
     
    of(com.fasterxml.jackson.databind.JsonNode node)
    Wraps an already-built structured node (e.g. an inline-permission object or a subtract object) verbatim.
    of(String value)
    Creates a PolicyExpression from a bare string member (e.g.
    Creates a PolicyExpression from a list of string members (e.g. an array of managedpolicy: ids), preserving the array form on write.
    com.fasterxml.jackson.databind.JsonNode
    Exposes the underlying JSON node verbatim for full structural navigation, and is the value Jackson serializes (so the captured form is re-emitted exactly).
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • fromJsonNode

      public static PolicyExpression fromJsonNode(com.fasterxml.jackson.databind.JsonNode node)
      Captures an arbitrary deserialized JSON value (string, array or object) verbatim. Used by Jackson when deserializing a union member.
      Parameters:
      node - the raw JSON node (never null in practice; null/missing maps to a JSON null node)
      Returns:
      a PolicyExpression wrapping the node
    • of

      public static PolicyExpression of(String value)
      Creates a PolicyExpression from a bare string member (e.g. "none", an ERN, or a permission-set id).
      Parameters:
      value - the string value
      Returns:
      a string-form PolicyExpression
    • ofStrings

      public static PolicyExpression ofStrings(List<String> values)
      Creates a PolicyExpression from a list of string members (e.g. an array of managedpolicy: ids), preserving the array form on write.
      Parameters:
      values - the string values
      Returns:
      an array-form PolicyExpression
    • of

      public static PolicyExpression of(com.fasterxml.jackson.databind.JsonNode node)
      Wraps an already-built structured node (e.g. an inline-permission object or a subtract object) verbatim.
      Parameters:
      node - the structured JSON node
      Returns:
      a structured-form PolicyExpression
    • isString

      public boolean isString()
      Returns:
      true when this entry is a bare JSON string
    • isArray

      public boolean isArray()
      Returns:
      true when this entry is a JSON array
    • isObject

      public boolean isObject()
      Returns:
      true when this entry is a structured JSON object
    • asString

      public String asString()
      Returns:
      the string value when isString(), otherwise null
    • asStringList

      public List<String> asStringList()
      Returns the array members as strings when this entry is an array of textual values, otherwise null. Non-textual array members are rendered via their JSON text.
      Returns:
      the list of string members, or null when not an array
    • toJsonNode

      public com.fasterxml.jackson.databind.JsonNode toJsonNode()
      Exposes the underlying JSON node verbatim for full structural navigation, and is the value Jackson serializes (so the captured form is re-emitted exactly).
      Returns:
      the underlying JsonNode
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object