Class Property<T>
- Type Parameters:
T
- the type of the property
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.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the "default value" for this property.final boolean
static <T> Property<T>
Returns a property with the given name and type.final String
getName()
Returns the name of this property.Returns the raw type of this property.final Type
getType()
Returns the type of this property.final int
hashCode()
toString()
withDefault
(T defaultValue) Returns a copy of this property with a new default value.
-
Constructor Details
-
Property
Constructs a property with the given name. The type information is captured implicitly.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") {};
- Parameters:
name
- the name of the property (notnull
)- See Also:
-
-
Method Details
-
get
Returns a property with the given name and type. The type is represented by a specified class object. The returned property has no default value (i.e.,defaultValue()
will always returnnull
).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.
- Type Parameters:
T
- the type of the property- Parameters:
name
- the name of the property (notnull
)type
- the type of the property (notnull
)- Returns:
- a property with the given name and type (never
null
)
-
withDefault
Returns a copy of this property with a new default value.This property is immutable and is unaffected by this method call.
- Parameters:
defaultValue
- the default value (may benull
)- Returns:
- a copy of this property with a new default value
(never
null
)
-
getName
Returns the name of this property.- Returns:
- the property name (never
null
)
-
getType
Returns the type of this property.- Returns:
- the property type (never
null
)
-
getRawType
Returns the raw type of this property.- Returns:
- the property raw type (never
null
)
-
defaultValue
Returns the "default value" for this property.- Returns:
- the default value (may be
null
)
-
equals
-
hashCode
public final int hashCode() -
toString
-