Tabnine Logo
CollectionsExt
Code IndexAdd Tabnine to your IDE (free)

How to use
CollectionsExt
in
org.apache.sis.internal.util

Best Java code snippets using org.apache.sis.internal.util.CollectionsExt (Showing top 20 results out of 315)

origin: org.apache.sis.core/sis-utility

  @Override public Collection<TemporalExtent>   getTemporalElements()   {return singletonOrEmpty(temporalElements);}
}
origin: org.apache.sis.core/sis-referencing

  /**
   * 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);
  }
}
origin: org.apache.sis.core/sis-referencing

/**
 * 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<>();
}
origin: org.apache.sis.core/sis-referencing

/**
 * 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));
}
origin: org.apache.sis.core/sis-feature

/**
 * 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;
}
origin: apache/sis

byName       = CollectionsExt.compact(byName);
indices      = CollectionsExt.compact(indices);
assignableTo = CollectionsExt.unmodifiableOrCopy(assignableTo);
origin: org.apache.sis.core/sis-metadata

      } else {
        clones(array);
        collection = CollectionsExt.immutableSet(false, array);
  entry.setValue(clone(entry.getValue()));
return CollectionsExt.unmodifiableOrCopy(map);
origin: org.apache.sis.core/sis-metadata

/**
 * 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());
      }
    }
  }
}
origin: apache/sis

  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;
origin: org.apache.sis.core/sis-referencing

/**
 * 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.
}
origin: apache/sis

/**
 * 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());
}
origin: org.apache.sis.core/sis-utility

case 0:  return Collections.emptyList();
case 1:  return Collections.singletonList(merged.get(0));
default: return Containers.unmodifiableList(CollectionsExt.toArray(merged, Identifier.class));
origin: apache/sis

/**
 * 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);
}
origin: org.apache.sis.core/sis-metadata

/**
 * 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));
}
origin: org.apache.sis.core/sis-feature

/**
 * 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;
}
origin: org.apache.sis.core/sis-feature

byName       = CollectionsExt.compact(byName);
indices      = CollectionsExt.compact(indices);
assignableTo = CollectionsExt.unmodifiableOrCopy(assignableTo);
origin: apache/sis

      } else {
        applyToAll(array);
        collection = CollectionsExt.immutableSet(false, array);
  entry.setValue(applyTo(entry.getValue()));
return CollectionsExt.unmodifiableOrCopy(map);
origin: apache/sis

/**
 * 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());
      }
    }
  }
}
origin: org.apache.sis.core/sis-referencing

  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;
origin: org.apache.sis.core/sis-referencing

/**
 * 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.
}
org.apache.sis.internal.utilCollectionsExt

Javadoc

Static methods working on Collection objects. This is an extension to the standard Collections utility class. Some worthy methods are:
  • #toCollection(Object) for wrapping or copying arbitrary objects to list or collection.
  • #modifiableCopy(Collection) method for taking a snapshot of an arbitrary implementation into an unsynchronized, modifiable, in-memory object.
  • #unmodifiableOrCopy(Set) methods, which may be slightly more compact than the standard Collections#unmodifiableSet(Set) equivalent when the unmodifiable collection is not required to be a view over the original collection.
This class is not in public API because some functionality provided there are not really the purpose of a geospatial library and may change at any time. Some method contracts are a little bit tedious to explain, which is an other indication that they should not be in public API.

Most used methods

  • singletonOrEmpty
    Returns the given value as a singleton if non-null, or returns an empty set otherwise.
  • unmodifiableOrCopy
    Returns a unmodifiable version of the given set. This method is different than the standard Collecti
  • addToMultiValuesMap
    Adds a value in a pseudo multi-values map. The multi-values map is simulated by a map of lists. The
  • compact
    Returns a more compact representation of the given map. This method is similar to #unmodifiableOrCop
  • first
    Returns the first element of the given iterable, or null if none. This method does not emit warning
  • immutableSet
    Returns the specified array as an immutable set, or null if the array is null. If the given array co
  • toArray
    Returns the elements of the given collection as an array. This method can be used when the valueClas
  • nonNull
    Returns the given set, or Collections#EMPTY_SET if the given set is null.
  • createSetForType
    Creates an initially empty set for elements of the given type. This method will creates specialized
  • emptySortedSet
    Returns a SortedSet which is always empty and accepts no element.Note: This method exists only on th
  • filter
    Returns an iterator over the elements of the given iterator where the predicate returns true. The it
  • identityEquals
    Returns true if the next elements returned by the given iterators are the same. This method compares
  • filter,
  • identityEquals,
  • modifiableCopy,
  • nonNullArraySet,
  • removeFromMultiValuesMap,
  • toCaseInsensitiveNameMap,
  • toCollection,
  • empty,
  • emptyQueue,
  • nonEmpty

Popular in Java

  • Running tasks concurrently on multiple threads
  • addToBackStack (FragmentTransaction)
  • getSupportFragmentManager (FragmentActivity)
  • getExternalFilesDir (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now