use of org.apache.sis.metadata.iso.acquisition.DefaultInstrument in project sis by apache.
the class MetadataStandardTest method testEqualsOnCyclicMetadata.
/**
* Tests the {@link MetadataStandard#equals(Object, Object, ComparisonMode)} method on an object
* having cyclic associations. In absence of safety guard against infinite recursivity, this test
* would produce {@link StackOverflowError}.
*/
@Test
@DependsOnMethod("testEquals")
public void testEqualsOnCyclicMetadata() {
final DefaultAcquisitionInformation p1 = createCyclicMetadata();
final DefaultAcquisitionInformation p2 = createCyclicMetadata();
assertTrue("equals", p1.equals(p2));
final DefaultPlatform platform = (DefaultPlatform) getSingleton(p2.getPlatforms());
final DefaultInstrument instrument = (DefaultInstrument) getSingleton(platform.getInstruments());
instrument.setType(new SimpleInternationalString("An other instrument type."));
assertFalse("equals", p1.equals(p2));
}
use of org.apache.sis.metadata.iso.acquisition.DefaultInstrument in project sis by apache.
the class MetadataBuilder method addInstrument.
/**
* Adds an instrument or sensor on the platform.
* Storage location is:
*
* <ul>
* <li>{@code metadata/acquisitionInformation/platform/instrument/identifier}</li>
* </ul>
*
* @param authority identifiers the authority that define instrument codes, or {@code null} if none.
* @param identifier identifier of the sensor to add, or {@code null} for no-operation.
*/
public final void addInstrument(final CharSequence authority, String identifier) {
if (identifier != null && !(identifier = identifier.trim()).isEmpty()) {
final DefaultInstrument instrument = new DefaultInstrument();
instrument.setIdentifier(sharedIdentifier(authority, identifier));
addIfNotPresent(platform().getInstruments(), instrument);
}
}
use of org.apache.sis.metadata.iso.acquisition.DefaultInstrument in project sis by apache.
the class MetadataStandardTest method createCyclicMetadata.
/**
* Creates a metadata object having a cyclic association. The cycle is between
* {@code platform.instrument} and {@code instrument.isMountedOn}.
*/
static DefaultAcquisitionInformation createCyclicMetadata() {
final DefaultInstrument instrument = new DefaultInstrument();
instrument.setType(new SimpleInternationalString("An instrument type."));
final DefaultPlatform platform = new DefaultPlatform();
platform.setDescription(new SimpleInternationalString("A platform."));
instrument.setMountedOn(platform);
platform.setInstruments(singleton(instrument));
final DefaultAcquisitionInformation acquisition = new DefaultAcquisitionInformation();
acquisition.setPlatforms(singleton(platform));
return acquisition;
}
Aggregations