@Override public Collection<TemporalExtent> getTemporalElements() {return singletonOrEmpty(temporalElements);} }
/** * Creates a new parameter descriptor for the given units. * * @param units the units. */ public EPSGParameterDomain(final Set<Unit<?>> units) { super(Double.class, null, false, null, false); this.units = CollectionsExt.unmodifiableOrCopy(units); } }
/** * Constructs a factory with the given default properties. * {@code GeodeticObjectFactory} will fallback on the map given to this constructor for any property * not present in the map provided to a {@code createFoo(Map<String,?>, …)} method. * * @param properties the default properties, or {@code null} if none. */ public GeodeticObjectFactory(Map<String,?> properties) { if (properties == null || properties.isEmpty()) { properties = Collections.emptyMap(); } else { properties = CollectionsExt.compact(new HashMap<>(properties)); } defaultProperties = properties; pool = new WeakHashSet<>(AbstractIdentifiedObject.class); parser = new AtomicReference<>(); }
/** * Returns the "main" namespace of the given factory, or {@code null} if none. * Current implementation returns the first namespace, but this may be changed in any future SIS version. * * <p>The purpose of this method is to get a unique identifier of a factory, ignoring version number.</p> */ static String getCodeSpace(final AuthorityFactory factory) { return CollectionsExt.first(getCodeSpaces(factory)); }
/** * Returns the names of feature properties that this operation needs for performing its task. */ @Override @SuppressWarnings("ReturnOfCollectionOrArrayField") public synchronized Set<String> getDependencies() { if (dependencies == null) { dependencies = CollectionsExt.immutableSet(true, attributeNames); } return dependencies; }
byName = CollectionsExt.compact(byName); indices = CollectionsExt.compact(indices); assignableTo = CollectionsExt.unmodifiableOrCopy(assignableTo);
} else { clones(array); collection = CollectionsExt.immutableSet(false, array); entry.setValue(clone(entry.getValue())); return CollectionsExt.unmodifiableOrCopy(map);
/** * Closes this element. This method verifies that there is no unprocessed value (dates, * numbers, booleans or strings), but ignores inner elements as required by ISO 19162. * * This method add the keywords of ignored elements in the {@code ignoredElements} map as below: * <ul> * <li><b>Keys</b>: keyword of ignored elements. Note that a key may be null.</li> * <li><b>Values</b>: keywords of all elements containing an element identified by the above-cited key. * This list is used for helping the users to locate the ignored elements.</li> * </ul> * * @param ignoredElements the collection where to declare ignored elements. * @throws ParseException if the list still contains some unprocessed values. */ final void close(final Map<String, List<String>> ignoredElements) throws ParseException { if (list != null) { for (final Object value : list) { if (value instanceof Element) { CollectionsExt.addToMultiValuesMap(ignoredElements, ((Element) value).keyword, keyword); } else { throw new UnparsableObjectException(locale, Errors.Keys.UnexpectedValueInElement_2, new Object[] {keyword, value}, offset + keyword.length()); } } } }
final Set<T> valids = CollectionsExt.createSetForType(valueClass, validValues.length); for (T value : validValues) { if (value != null) { this.validValues = CollectionsExt.unmodifiableOrCopy(valids); } else { this.validValues = null;
/** * Returns identifiers which references elsewhere the object's defining information. * Alternatively identifiers by which this object can be referenced. * * @return this object identifiers, or an empty set if there is none. * * @see IdentifiedObjects#getIdentifier(IdentifiedObject, Citation) */ @Override public Set<ReferenceIdentifier> getIdentifiers() { return nonNull(identifiers); // Needs to be null-safe because we may have a null value on unmarshalling. }
/** * Tests {@link CollectionsExt#addToMultiValuesMap(Map, Object, Object)}, then * opportunistically tests {@link CollectionsExt#removeFromMultiValuesMap(Map, Object, Object)}, */ @Test public void testAddAndRemoveToMultiValuesMap() { final Map<String, List<Integer>> map = new LinkedHashMap<>(); final Integer A1 = 2; final Integer A2 = 4; final Integer B1 = 3; final Integer B2 = 6; final Integer B3 = 9; assertArrayEquals(new Integer[] {A1}, CollectionsExt.addToMultiValuesMap(map, "A", A1).toArray()); assertArrayEquals(new Integer[] {B1}, CollectionsExt.addToMultiValuesMap(map, "B", B1).toArray()); assertArrayEquals(new Integer[] {B1, B2}, CollectionsExt.addToMultiValuesMap(map, "B", B2).toArray()); assertArrayEquals(new Integer[] {A1, A2}, CollectionsExt.addToMultiValuesMap(map, "A", A2).toArray()); assertArrayEquals(new Integer[] {B1, B2, B3}, CollectionsExt.addToMultiValuesMap(map, "B", B3).toArray()); assertArrayEquals(new String[] {"A", "B"}, map.keySet().toArray()); assertArrayEquals(new Integer[] {A1, A2}, map.get("A").toArray()); assertArrayEquals(new Integer[] {B1, B2, B3}, map.get("B").toArray()); assertNull( CollectionsExt.removeFromMultiValuesMap(map, "C", A2)); assertArrayEquals(new Integer[] {A1}, CollectionsExt.removeFromMultiValuesMap(map, "A", A2).toArray()); assertArrayEquals(new Integer[] {B1, B3}, CollectionsExt.removeFromMultiValuesMap(map, "B", B2).toArray()); assertArrayEquals(new Integer[] {}, CollectionsExt.removeFromMultiValuesMap(map, "A", A1).toArray()); assertArrayEquals(new String[] {"B"}, map.keySet().toArray()); assertArrayEquals(new Integer[] {B1, B3}, map.get("B").toArray()); }
case 0: return Collections.emptyList(); case 1: return Collections.singletonList(merged.get(0)); default: return Containers.unmodifiableList(CollectionsExt.toArray(merged, Identifier.class));
/** * Tests {@link CollectionsExt#createSetForType(Class, int)}. */ @Test public void testCreateSetForType() { Set<?> set = CollectionsExt.createSetForType(java.lang.annotation.ElementType.class, 0); assertTrue("isEmpty", set.isEmpty()); assertInstanceOf("Set<ElementType>", EnumSet.class, set); set = CollectionsExt.createSetForType(org.opengis.referencing.cs.AxisDirection.class, 0); assertTrue("isEmpty", set.isEmpty()); assertInstanceOf("Set<AxisDirection>", CodeListSet.class, set); set = CollectionsExt.createSetForType(String.class, 0); assertTrue("isEmpty", set.isEmpty()); assertInstanceOf("Set<String>", HashSet.class, set); }
/** * Invoked by JAXB {@link javax.xml.bind.Marshaller} before this object is marshalled to XML. * This method sets the locale to be used for XML marshalling to the metadata language. */ private void beforeMarshal(final Marshaller marshaller) { Context.push(CollectionsExt.first(languages)); }
/** * Returns the names of feature properties that this operation needs for performing its task. */ @Override @SuppressWarnings("ReturnOfCollectionOrArrayField") public synchronized Set<String> getDependencies() { if (dependencies == null) { dependencies = CollectionsExt.immutableSet(true, attributeNames); } return dependencies; }
byName = CollectionsExt.compact(byName); indices = CollectionsExt.compact(indices); assignableTo = CollectionsExt.unmodifiableOrCopy(assignableTo);
} else { applyToAll(array); collection = CollectionsExt.immutableSet(false, array); entry.setValue(applyTo(entry.getValue())); return CollectionsExt.unmodifiableOrCopy(map);
/** * Closes this element. This method verifies that there is no unprocessed value (dates, * numbers, booleans or strings), but ignores inner elements as required by ISO 19162. * * This method add the keywords of ignored elements in the {@code ignoredElements} map as below: * <ul> * <li><b>Keys</b>: keyword of ignored elements. Note that a key may be null.</li> * <li><b>Values</b>: keywords of all elements containing an element identified by the above-cited key. * This list is used for helping the users to locate the ignored elements.</li> * </ul> * * @param ignoredElements the collection where to declare ignored elements. * @throws ParseException if the list still contains some unprocessed values. */ final void close(final Map<String, List<String>> ignoredElements) throws ParseException { if (list != null) { for (final Object value : list) { if (value instanceof Element) { CollectionsExt.addToMultiValuesMap(ignoredElements, ((Element) value).keyword, keyword); } else { throw new UnparsableObjectException(locale, Errors.Keys.UnexpectedValueInElement_2, new Object[] {keyword, value}, offset + keyword.length()); } } } }
final Set<T> valids = CollectionsExt.createSetForType(valueClass, validValues.length); for (T value : validValues) { if (value != null) { this.validValues = CollectionsExt.unmodifiableOrCopy(valids); } else { this.validValues = null;
/** * Returns alternative names by which this object is identified. * * @return the aliases, or an empty collection if there is none. * * @see #getName() */ @Override public Collection<GenericName> getAlias() { return nonNull(alias); // Needs to be null-safe because we may have a null value on unmarshalling. }