T
- the type of the propertypublic class Property<T>
extends java.lang.Object
All properties share the default implementation of equals
inherited from Object
. Property objects that are not equal
according to equals
may still be "functionally equal" and
used interchangeably, depending on the usage context. Such equivalence
relations need to be specified on a case-by-case basis.
Modifier | Constructor and Description |
---|---|
protected |
Property(java.lang.String name)
Constructs a property with the given name.
|
Modifier and Type | Method and Description |
---|---|
T |
defaultValue()
Returns the "default value" for this property.
|
boolean |
equals(java.lang.Object obj) |
static <T> Property<T> |
get(java.lang.String name,
java.lang.Class<T> type)
Returns a property with the given name and type.
|
java.lang.String |
getName()
Returns the name of this property.
|
java.lang.Class<T> |
getRawType()
Returns the raw type of this property.
|
java.lang.reflect.Type |
getType()
Returns the type of this property.
|
int |
hashCode() |
java.lang.String |
toString() |
Property<T> |
withDefault(T defaultValue)
Returns a copy of this property with a new default value.
|
protected Property(java.lang.String name)
The protected constructor forces clients to create a subclass of this class which enables retrieval of the actual type argument at runtime.
For example, to create a property of type List<String>
,
you can create an empty anonymous inner class:
Property<List<String>> p1 =
new Property<List<String>>("p1") {};
name
- the name of the property (not null
)get(String, Class)
public static <T> Property<T> get(java.lang.String name, java.lang.Class<T> type)
defaultValue()
will always return null
).
If the type of property values is not generic, using this method of obtaining a property might be preferable to using the constructor as it avoids creating a subclass for the property.
T
- the type of the propertyname
- the name of the property (not null
)type
- the type of the property (not null
)null
)public Property<T> withDefault(T defaultValue)
This property is immutable and is unaffected by this method call.
defaultValue
- the default value (may be null
)null
)public final java.lang.String getName()
null
)public final java.lang.reflect.Type getType()
null
)public final java.lang.Class<T> getRawType()
null
)public T defaultValue()
null
)public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright (c) 2014, 2020 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0