Class SchemaOptions
- All Implemented Interfaces:
Serializable,Cloneable,Map<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:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtected default constructor.protectedSchemaOptions(SchemaOptions.Builder aBuilder) Instantiates a newSchemaOptionsinstance from the given builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic SchemaOptions.Builderbuilder()Creates a newSchemaOptions.Builderfor constructingSchemaOptionsinstances.<T> TReturns the value associated with the given key if it matches the requested type.intgetLimit()Returns the configured limit value.intgetLimitOr(int aValue) Returns the configured limit value or the provided default.<T> TReturns the value associated with the given key if it matches the requested type, or a default value otherwise.Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Field Details
-
LIMIT
-
-
Constructor Details
-
SchemaOptions
protected SchemaOptions()Protected default constructor.
Instances are typically created via the
SchemaOptions.Builder. -
SchemaOptions
Instantiates a newSchemaOptionsinstance from the given builder.- Parameters:
aBuilder- the builder from which to populate theSchemaOptions
-
-
Method Details
-
getLimit
public int getLimit()Returns the configured limit value.
This is a convenience method equivalent to calling
getLimitOr(int)with-1as the default value.- Returns:
- the configured limit value, or
-1if 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
aValueif absent
-
get
Returns the value associated with the given key if it matches the requested type.- Type Parameters:
T- the expected type- Parameters:
aKey- the option keyaType- the expected value type- Returns:
- the typed value, or
nullif the key is not present or the value is of a different type
-
getOr
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 keyaType- the expected value typeaValue- the default value to return if the option is absent or of a different type- Returns:
- the typed value or
aValueif not present or incompatible
-
builder
Creates a newSchemaOptions.Builderfor constructingSchemaOptionsinstances.- Returns:
- a new builder instance
-