Search in sources :

Example 1 with ValueRange

use of org.apache.sis.measure.ValueRange in project sis by apache.

the class PropertyAccessor method information.

/**
 * Returns the information for the property at the given index.
 * The information are created when first needed.
 *
 * @param  index  the index of the property for which to get the information.
 * @return the information for the property at the given index, or {@code null} if the index is out of bounds.
 *
 * @see PropertyInformation
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
final synchronized ExtendedElementInformation information(final int index) {
    ExtendedElementInformation[] informations = this.informations;
    if (informations == null) {
        this.informations = informations = new PropertyInformation<?>[standardCount];
    }
    if (index < 0 || index >= informations.length) {
        return null;
    }
    ExtendedElementInformation information = informations[index];
    if (information == null) {
        final Class<?> elementType = elementTypes[index];
        final String name = name(index, KeyNamePolicy.UML_IDENTIFIER);
        final Method getter = getters[index];
        final ValueRange range;
        try {
            range = implementation.getMethod(getter.getName(), (Class<?>[]) null).getAnnotation(ValueRange.class);
        } catch (NoSuchMethodException error) {
            /*
                 * Should never happen, since the implementation class
                 * implements the interface where the getter come from.
                 */
            throw new AssertionError(error);
        }
        information = new PropertyInformation<>(standard, name, getter, elementType, range);
        informations[index] = information;
    }
    return information;
}
Also used : ValueRange(org.apache.sis.measure.ValueRange) ExtendedElementInformation(org.opengis.metadata.ExtendedElementInformation) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 ValueRange (org.apache.sis.measure.ValueRange)1 ExtendedElementInformation (org.opengis.metadata.ExtendedElementInformation)1