use of org.opengis.metadata.ExtendedElementInformation in project sis by apache.
the class SpecialCasesTest method testPropertyInformation.
/**
* Tests {@link SpecialCases#information(int)}.
*/
@Test
public void testPropertyInformation() {
final ExtendedElementInformation info = accessor.information(accessor.indexOf("westBoundLongitude", true));
final InternationalString domain = info.getDomainValue();
assertInstanceOf("Expected numerical information about range.", NumberRange.class, domain);
final NumberRange<?> range = (NumberRange) domain;
assertEquals(-180, range.getMinDouble(), STRICT);
assertEquals(+180, range.getMaxDouble(), STRICT);
}
use of org.opengis.metadata.ExtendedElementInformation in project sis by apache.
the class PropertyInformationTest method testGetDomainValue.
/**
* Tests {@link PropertyInformation#getDomainValue()} with a non-null range.
*
* @throws NoSuchMethodException if the {@code getMaxRelativeHumidity()} or other method has not been found.
*/
@Test
@SuppressWarnings("UnnecessaryBoxing")
public void testGetDomainValue() throws NoSuchMethodException {
final ExtendedElementInformation information = new PropertyInformation<>(HardCodedCitations.ISO_19115, "maxRelativeHumidity", EnvironmentalRecord.class.getMethod("getMaxRelativeHumidity"), Double.class, DefaultEnvironmentalRecord.class.getMethod("getMaxRelativeHumidity").getAnnotation(ValueRange.class));
final InternationalString domainValue = information.getDomainValue();
assertNotNull(domainValue);
assertEquals("[0.0 … 100.0]", domainValue.toString());
assertEquals("[0 … 100]", domainValue.toString(Locale.ENGLISH));
assertEquals("[0 … 100]", domainValue.toString(Locale.FRENCH));
assertInstanceOf("Specific to SIS implementation.", Range.class, domainValue);
assertEquals("getMinValue()", Double.valueOf(0), ((Range) domainValue).getMinValue());
assertEquals("getMaxValue()", Double.valueOf(100), ((Range) domainValue).getMaxValue());
}
use of org.opengis.metadata.ExtendedElementInformation 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;
}
Aggregations