Class SchemaOptions

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

public class SchemaOptions extends HashMap<String,Object>

SchemaOptions represents a set of options influencing how a Schemable instance renders its Schema.

The options are expressed as key/value pairs and stored internally in a Map. In addition to generic map-style access, this class provides typed convenience accessors for commonly used options such as LIMIT.

The interpretation of individual option keys and values is intentionally left to the respective Schemable implementation. This makes SchemaOptions generic and reusable across different domains and schema-producing components.

Instances of this class are typically created using the nested SchemaOptions.Builder.

See Also:
  • Field Details

    • LIMIT

      public static final String LIMIT

      Key identifying a limit option.

      The associated value is expected to be an Integer. Its semantic meaning (for example, limiting the number of repeated elements rendered in a schema) is defined by the Schemable implementation consuming this option.

      See Also:
  • Constructor Details

    • SchemaOptions

      protected SchemaOptions()

      Protected default constructor.

      Instances are typically created via the SchemaOptions.Builder.

    • SchemaOptions

      protected SchemaOptions(SchemaOptions.Builder aBuilder)
      Instantiates a new SchemaOptions instance from the given builder.
      Parameters:
      aBuilder - the builder from which to populate the SchemaOptions
  • Method Details

    • getLimit

      public int getLimit()

      Returns the configured limit value.

      This is a convenience method equivalent to calling getLimitOr(int) with -1 as the default value.

      Returns:
      the configured limit value, or -1 if no limit is set
    • getLimitOr

      public int getLimitOr(int aValue)
      Returns the configured limit value or the provided default.
      Parameters:
      aValue - the default value to return if no limit is present
      Returns:
      the configured limit value or aValue if absent
    • get

      public <T> T get(String aKey, Class<T> aType)
      Returns the value associated with the given key if it matches the requested type.
      Type Parameters:
      T - the expected type
      Parameters:
      aKey - the option key
      aType - the expected value type
      Returns:
      the typed value, or null if the key is not present or the value is of a different type
    • getOr

      public <T> T getOr(String aKey, Class<T> aType, T aValue)
      Returns the value associated with the given key if it matches the requested type, or a default value otherwise.
      Type Parameters:
      T - the expected type
      Parameters:
      aKey - the option key
      aType - the expected value type
      aValue - the default value to return if the option is absent or of a different type
      Returns:
      the typed value or aValue if not present or incompatible
    • builder

      public static SchemaOptions.Builder builder()
      Creates a new SchemaOptions.Builder for constructing SchemaOptions instances.
      Returns:
      a new builder instance