Class PropertyView

java.lang.Object
org.apache.sis.feature.PropertyView
Type Parameters:
V - the type of property values.

final class PropertyView extends Object
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 Details

    • PropertyView

      private PropertyView()
      Do not allow instantiation of this class.
  • Method Details

    • create

      static Property create(AbstractFeature feature, AbstractIdentifiedType type)
      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 the feature (this is not verified by this constructor).
    • getValue

      static Object getValue(AbstractFeature feature, String name)
      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-Iterable values as a safety against implementations that are not strictly compliant to our Feature.getPropertyValue(String) method contract. Then this method verifies that the value is a collection containing zero or one element and returns that element or null.
    • setValue

      static void setValue(AbstractFeature feature, String name, Object value)
      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 the Feature.setPropertyValue(String, Object) implementation will verify the argument type.
    • singletonOrEmpty

      static <V> List<V> singletonOrEmpty(V element)
      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

      static <V> Collection<V> getValues(AbstractFeature feature, String name, Class<V> expected)
      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

      static void setValues(AbstractFeature feature, String name, Collection<?> values)
      Sets the values of the given attribute. This method assumes that the Feature.setPropertyValue(String, Object) implementation will verify the argument type.
    • hashCode

      static int hashCode(AbstractFeature feature, String name)
      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.