public class EmptyConfiguration extends java.lang.Object implements JsonSerializable
GraphDrawingAlgorithm
.Modifier and Type | Class and Description |
---|---|
static class |
EmptyConfiguration.PropertyDescriptor<T>
A property descriptor for storing simple properties.
|
Constructor and Description |
---|
EmptyConfiguration() |
Modifier and Type | Method and Description |
---|---|
void |
addCost(java.lang.Object cost)
Adds a new cost object to this configuration.
|
protected <T> void |
addProperty(EmptyConfiguration.PropertyDescriptor<T> property,
T value)
Adds a new property to the configuration.
|
EmptyConfiguration |
clone()
Returns a clone of this configuration.
|
void |
fromJson(javax.json.JsonValue json) |
java.util.List<java.lang.Object> |
getCosts()
Gets an unmodifiable copy of all the costs associated with this configuration.
|
<T> java.util.List<T> |
getCosts(java.lang.Class<T> clazz)
Gets all costs which are assignable to the given class.
|
<T> T |
getProperty(EmptyConfiguration.PropertyDescriptor<T> property)
Get the property pointed to by the given property descriptor, if it exists.
|
<T> java.util.Optional<T> |
getPropertySafe(EmptyConfiguration.PropertyDescriptor<T> property)
Get the property pointed to by the given property descriptor, if it exists.
|
protected void |
initializeProperties()
Initialize the set of properties supported by this configuration.
|
protected static <T> EmptyConfiguration.PropertyDescriptor<T> |
property(java.lang.String name,
java.lang.Class<T> clazz) |
void |
removeCost(java.lang.Object cost)
Removes the given cost from this configuration.
|
void |
removeCosts(java.lang.Class<?> clazz)
Removes all the costs of the given class (or any subclass) from this configuration.
|
EmptyConfiguration |
setProperty(EmptyConfiguration.PropertyDescriptor<?> property,
java.lang.Object value)
Set the property for the given property descriptor.
|
java.util.Set<java.lang.Class<?>> |
supportedCostBaseTypes()
Returns a set of the supported base types for the costs.
|
java.util.Set<EmptyConfiguration.PropertyDescriptor<?>> |
supportedProperties()
Returns the set of property descriptors supported by this configuration.
|
boolean |
supportsCostType(java.lang.Class<?> candidate)
Returns whether the given class is among the supported cost types, i.e.
|
java.lang.String |
toString() |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
toJson
protected static <T> EmptyConfiguration.PropertyDescriptor<T> property(java.lang.String name, java.lang.Class<T> clazz)
public <T> java.util.Optional<T> getPropertySafe(EmptyConfiguration.PropertyDescriptor<T> property)
T
- The type of the property.property
- The property descriptor.public <T> T getProperty(EmptyConfiguration.PropertyDescriptor<T> property) throws java.lang.IllegalArgumentException
T
- The type of the property.property
- The property descriptor.java.lang.IllegalArgumentException
- If there is no property stored for the given descriptor.java.lang.ClassCastException
- If the stored property is of the wrong type.public EmptyConfiguration setProperty(EmptyConfiguration.PropertyDescriptor<?> property, java.lang.Object value) throws java.lang.IllegalArgumentException
property
- The property descriptor.value
- The new property to be set.java.lang.IllegalArgumentException
- If the property is of the wrong type, or no property for the given property
descriptor exists.public java.util.Set<EmptyConfiguration.PropertyDescriptor<?>> supportedProperties()
setProperty(PropertyDescriptor, Object)
or
getProperty(PropertyDescriptor)
for any other property will throw an exception.public void addCost(java.lang.Object cost) throws java.lang.IllegalArgumentException
supportsCostType(Class)
to check whether the given object's type is supported
by this configuration.cost
- The cost object to add.java.lang.IllegalArgumentException
- If the type of the cost object is not supported.public void removeCost(java.lang.Object cost)
cost
- The cost to be removed.public void removeCosts(java.lang.Class<?> clazz)
clazz
- The class of which to remove all costs.public java.util.List<java.lang.Object> getCosts()
public <T> java.util.List<T> getCosts(java.lang.Class<T> clazz)
T
- The type of costs to find.clazz
- The class of which to find all costs.public java.util.Set<java.lang.Class<?>> supportedCostBaseTypes()
public boolean supportsCostType(java.lang.Class<?> candidate)
supportedCostBaseTypes()
.candidate
- The candiate class.public EmptyConfiguration clone()
clone
in class java.lang.Object
public void fromJson(javax.json.JsonValue json)
fromJson
in interface JsonSerializable
public java.lang.String toString()
toString
in class java.lang.Object
protected <T> void addProperty(EmptyConfiguration.PropertyDescriptor<T> property, T value)
T
- The type of the new property.property
- The property descriptor.value
- The new property to be added.aprotected void initializeProperties()
addProperty(PropertyDescriptor, Object)
as a way to add new properties in this method.