public class PropertyMap extends Object implements Serializable
Maps follow a copy-on-write scheme gated by a dirty flag (avoid copy of a dirty map). This allows sharing their content (the inner properties map) with guaranteed isolation and thread safety.
Modifier and Type | Field and Description |
---|---|
protected UUID |
digest
The uuid.
|
protected boolean |
dirty
Whether this map is dirty which also reflects its copy-on-write state.
|
static org.slf4j.Logger |
LOGGER
The logger.
|
protected Map<String,Object> |
properties
The properties and their values; the map is cow-once.
|
protected PropertySchema |
schema
The schema for this map, describes allowed properties and their types.
|
Constructor and Description |
---|
PropertyMap(DataInput input,
Function<String,PropertySchema> getSchema)
Deserialization ctor.
|
PropertyMap(PropertyMap src,
Map<String,Object> input)
The projection constructor.
|
Modifier and Type | Method and Description |
---|---|
PropertyMap |
copy()
A copy of this map.
|
boolean |
equals(Object o) |
Map<String,String> |
export()
Exports this property map as a key/value as string map.
|
Map<String,String> |
export(boolean withDefaults)
Exports this property map as a key/value as string map.
|
void |
exportToProperties(Properties javap)
Exports this map properties to java properties
|
void |
forEach(BiConsumer<? super String,Object> action)
Call action on each property name/value.
|
UUID |
getDigest()
Gets this property set digest.
|
Object |
getProperty(String name)
Gets the value of a property.
|
Object |
getPropertyValue(String name)
Gets the value of a property.
|
protected PropertyType<?> |
getTypeOf(String name) |
int |
hashCode() |
void |
importFromProperties(Properties javap)
Import key value pairs from java properties.
|
boolean |
isDirty() |
boolean |
isDropped() |
boolean |
isEmpty() |
Object |
putProperty(String name,
Object value)
Sets the value of a property.
|
Object |
removeProperty(String name)
Removes a property from this map.
|
void |
setClean()
Clears the inner dirty flag.
|
int |
size() |
void |
write(DataOutput out)
The Serialization method.
|
public static final org.slf4j.Logger LOGGER
protected final transient PropertySchema schema
protected transient volatile UUID digest
protected transient Map<String,Object> properties
protected transient boolean dirty
public PropertyMap(PropertyMap src, Map<String,Object> input)
This copies an instance and sets key/value pairs at the same time.
Note that the resulting map is not dirty.
src
- the instance to copyinput
- the pairs to setpublic PropertyMap(DataInput input, Function<String,PropertySchema> getSchema) throws IOException
Used through deserializtion through reflection by the serialization proxy.
input
- the input streamIOException
- if IO failpublic void write(DataOutput out) throws IOException
out
- the output streamIOException
- if IO failpublic int size()
public boolean isEmpty()
public boolean isDirty()
public void setClean()
This implies the inner map becomes shareable between instances (see #copy()).
This should only be called after a save()/write().
public boolean isDropped()
public PropertyMap copy()
Called to avoid sharing instances from cache.
protected PropertyType<?> getTypeOf(String name)
public void exportToProperties(Properties javap)
javap
- the java propertiespublic void importFromProperties(Properties javap)
javap
- the java propertiespublic UUID getDigest()
public Object putProperty(String name, Object value)
name
- the property namevalue
- the valueIllegalArgumentException
- if the property is not declared or the value is of an incorrect typepublic Object removeProperty(String name)
name
- the property namepublic Object getProperty(String name)
name
- the property namepublic Object getPropertyValue(String name)
name
- the property namepublic void forEach(BiConsumer<? super String,Object> action)
action
- the action to callpublic Map<String,String> export()
Copyright © 2023 The Apache Software Foundation. All rights reserved.