public class PropertySchema extends Object implements Serializable
A schema declares the properties that can be set, their type and their eventual default value.
| Modifier and Type | Field and Description |
|---|---|
protected UUID |
digest
The uuid.
|
static PropertySchema |
NONE
A default schema that treats all properties as string.
|
protected Map<String,PropertyType<?>> |
properties
The properties and their types, may be empty, never null.
|
protected Map<String,Object> |
values
The properties default value.
|
| Constructor and Description |
|---|
PropertySchema(DataInput input)
The deserializing constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
declareProperty(String name,
PropertyType<?> type)
Declares a new property.
|
boolean |
declareProperty(String name,
PropertyType<?> type,
Object defaultValue)
Declares a new property.
|
boolean |
equals(Object o) |
void |
forEach(BiConsumer<String,PropertyType<?>> action)
Perform an action on all properties.
|
Object |
getDefaultValue(String name)
Gets the default value for a property.
|
UUID |
getDigest()
Gets this property schema digest.
|
String |
getName() |
PropertyType<?> |
getPropertyType(String name)
Gets the type for a given property.
|
int |
getVersionNumber() |
int |
hashCode() |
boolean |
removeProperty(String name)
For testing purpose, removes a property from this schema.
|
void |
setDefaultValue(String name,
Object value)
Sets the default value for a property.
|
String |
toString() |
void |
write(DataOutput output)
The serializing write method.
|
protected transient volatile UUID digest
protected final transient Map<String,PropertyType<?>> properties
public static final PropertySchema NONE
public PropertySchema(DataInput input) throws IOException
Called by reflection through SerializationProxy
input - the input streamIOException - if IO failpublic void write(DataOutput output) throws IOException
output - the output streamIOException - if IO failpublic String getName()
public int getVersionNumber()
public UUID getDigest()
public void forEach(BiConsumer<String,PropertyType<?>> action)
action - the actionpublic PropertyType<?> getPropertyType(String name)
name - the property namepublic Object getDefaultValue(String name)
name - the property namepublic void setDefaultValue(String name, Object value)
name - the property namevalue - the default value to setpublic boolean declareProperty(String name, PropertyType<?> type)
name - the property nametype - the property typeIllegalArgumentException - if a property with the same name but a different type has already been declaredpublic boolean declareProperty(String name, PropertyType<?> type, Object defaultValue)
name - the property nametype - the property typedefaultValue - the default property valueIllegalArgumentException - if a property with the same name but a different type has already been declaredpublic boolean removeProperty(String name)
name - the property nameCopyright © 2024 The Apache Software Foundation. All rights reserved.