Package org.apache.sis.feature
Class PropertyView
java.lang.Object
org.apache.sis.feature.PropertyView
- Type Parameters:
V- the type of property values.
An attribute or association implementation which delegate its work to the parent feature.
This class is used for default implementation of
AbstractFeature.getProperty(String).
This implementation is inefficient!
This class is for making easier to begin with a custom AbstractFeature implementation,
but developers are encouraged to provide their own AbstractFeature.getProperty(String)
implementation.
- Since:
- 0.8
- Version:
- 0.8
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static Propertycreate(AbstractFeature feature, AbstractIdentifiedType type) Creates a new property which will delegate its work to the given feature.(package private) static ObjectgetValue(AbstractFeature feature, String name) Returns the singleton value.(package private) static <V> Collection<V>getValues(AbstractFeature feature, String name, Class<V> expected) Returns the values as a collection.(package private) static inthashCode(AbstractFeature feature, String name) Returns a hash code value for this property.(package private) static voidsetValue(AbstractFeature feature, String name, Object value) Sets the values of the given attribute.(package private) static voidsetValues(AbstractFeature feature, String name, Collection<?> values) Sets the values of the given attribute.(package private) static <V> List<V>singletonOrEmpty(V element) Returns the given value as a singleton if non-null, or returns an empty list otherwise.(package private) static StringtoString(Class<?> classe, Class<?> valueClass, org.opengis.util.GenericName name, Collection<?> values) Returns a string representation of this property for debugging purposes.
-
Constructor Details
-
PropertyView
private PropertyView()Do not allow instantiation of this class.
-
-
Method Details
-
create
Creates a new property which will delegate its work to the given feature.- Parameters:
feature- the feature from which to read and where to write the property value.type- the type of the property. Must be one of the properties listed in thefeature(this is not verified by this constructor).
-
getValue
Returns the singleton value. This default implementation assumes that the property is multi-valued (single-valued properties shall override this method), but we nevertheless provide a fallback for non-Iterablevalues as a safety against implementations that are not strictly compliant to ourFeature.getPropertyValue(String)method contract. Then this method verifies that the value is a collection containing zero or one element and returns that element ornull. -
setValue
Sets the values of the given attribute. This default implementation assumes that the property is multi-valued (single-valued properties shall override this method) and that theFeature.setPropertyValue(String, Object)implementation will verify the argument type. -
singletonOrEmpty
Returns the given value as a singleton if non-null, or returns an empty list otherwise.- Type Parameters:
V- the element type.- Parameters:
element- the element to returns in a collection if non-null.- Returns:
- a collection containing the given element if non-null, or an empty collection otherwise.
-
getValues
Returns the values as a collection. This method tries to verify that the collection contains elements of the expected type, but this verification is not always possible. Consequently this method may, sometimes, be actually unsafe. -
setValues
Sets the values of the given attribute. This method assumes that theFeature.setPropertyValue(String, Object)implementation will verify the argument type. -
hashCode
Returns a hash code value for this property. -
toString
static String toString(Class<?> classe, Class<?> valueClass, org.opengis.util.GenericName name, Collection<?> values) Returns a string representation of this property for debugging purposes.
-