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

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

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

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: apache/sis

  /**
   * 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: Geomatys/geotoolkit

/**
 * Returns a unmodifiable version of the given set.
 * This method is different than the standard {@link Collections#unmodifiableSet(Set)}
 * in that it tries to returns a more efficient object when there is zero or one element.
 * Such small set occurs frequently in Apache SIS, especially for
 * {@link org.apache.sis.referencing.AbstractIdentifiedObject} names or identifiers.
 *
 * <p><em>The set returned by this method may or may not be a view of the given set</em>.
 * Consequently this method shall be used <strong>only</strong> if the given set will
 * <strong>not</strong> be modified after this method call. In case of doubt, use the
 * standard {@link Collections#unmodifiableSet(Set)} method instead.</p>
 *
 * @param  <E>  The type of elements in the set.
 * @param  set  The set to make unmodifiable, or {@code null}.
 * @return A unmodifiable version of the given set, or {@code null} if the given set was null.
 */
public static <E> Set<E> unmodifiableOrCopy(Set<E> set) {
  return CollectionsExt.unmodifiableOrCopy(set);
}
origin: Geomatys/geotoolkit

/**
 * Returns a unmodifiable version of the given map.
 * This method is different than the standard {@link Collections#unmodifiableMap(Map)}
 * in that it tries to returns a more efficient object when there is zero or one entry.
 * Such small maps occur frequently in Apache SIS.
 *
 * <p><em>The map returned by this method may or may not be a view of the given map</em>.
 * Consequently this method shall be used <strong>only</strong> if the given map will
 * <strong>not</strong> be modified after this method call. In case of doubt, use the
 * standard {@link Collections#unmodifiableMap(Map)} method instead.</p>
 *
 * @param  <K>  The type of keys in the map.
 * @param  <V>  The type of values in the map.
 * @param  map  The map to make unmodifiable, or {@code null}.
 * @return A unmodifiable version of the given map, or {@code null} if the given map was null.
 */
public static <K,V> Map<K,V> unmodifiableOrCopy(Map<K,V> map) {
  return CollectionsExt.unmodifiableOrCopy(map);
}
origin: apache/sis

/**
 * {@inheritDoc}
 */
@Override
public boolean transition(final State target) {
  final Collection<Identifier> p = identifiers;
  final boolean changed = super.transition(target);
  if (changed) {
    /*
     * The 'identifiers' collection will have been replaced by an unmodifiable collection if
     * subclass has an "identifiers" property. If this is not the case, then the collection
     * is unchanged (or null) so we have to make it unmodifiable here.
     */
    if (p != null && p == identifiers) {
      if (p instanceof Set<?>) {
        identifiers = CollectionsExt.unmodifiableOrCopy((Set<Identifier>) p);
      } else if (p instanceof List<?>) {
        identifiers = CollectionsExt.unmodifiableOrCopy((List<Identifier>) p);
      } else {
        identifiers = Collections.unmodifiableCollection(p);
      }
    }
  }
  return changed;
}
origin: org.apache.sis.core/sis-utility

  set.remove(null);
return unmodifiableOrCopy(set);
origin: apache/sis

  set.remove(null);
return unmodifiableOrCopy(set);
origin: org.apache.sis.core/sis-referencing

/**
 * Returns the code spaces of all factories given to the constructor.
 *
 * <div class="note"><b>Implementation note:</b>
 * the current implementation may be relatively costly since it implies instantiation of all factories.
 * </div>
 *
 * @return the code spaces of all factories.
 */
@Override
@SuppressWarnings("ReturnOfCollectionOrArrayField")
public Set<String> getCodeSpaces() {
  Set<String> union = codeSpaces;
  if (union == null) {
    union = new LinkedHashSet<>();
    for (final Iterator<AuthorityFactory> it = getAllFactories(); it.hasNext();) {
      union.addAll(getCodeSpaces(it.next()));
    }
    codeSpaces = union = CollectionsExt.unmodifiableOrCopy(union);
  }
  return union;
}
origin: apache/sis

nodataValues = CollectionsExt.unmodifiableOrCopy(pads);
origin: apache/sis

/**
 * Returns the code spaces of all factories given to the constructor.
 *
 * <div class="note"><b>Implementation note:</b>
 * the current implementation may be relatively costly since it implies instantiation of all factories.
 * </div>
 *
 * @return the code spaces of all factories.
 */
@Override
@SuppressWarnings("ReturnOfCollectionOrArrayField")
public Set<String> getCodeSpaces() {
  Set<String> union = codeSpaces;
  if (union == null) {
    union = new LinkedHashSet<>();
    for (final Iterator<AuthorityFactory> it = getAllFactories(); it.hasNext();) {
      union.addAll(getCodeSpaces(it.next()));
    }
    codeSpaces = union = CollectionsExt.unmodifiableOrCopy(union);
  }
  return union;
}
origin: org.apache.sis.core/sis-utility

if (collection != null) {
  if (collection instanceof Set<?>) {
    return unmodifiableOrCopy((Set<E>) collection);
origin: org.apache.sis.core/sis-metadata

/**
 * Declares this metadata and all its properties as unmodifiable. Any attempt to modify a property
 * after this method call will throw an {@link org.apache.sis.metadata.UnmodifiableMetadataException}.
 * If this metadata is already unmodifiable, then this method does nothing.
 *
 * <p>Subclasses usually do not need to override this method since the default implementation
 * performs most of its work using Java reflection.</p>
 */
@Override
public void freeze() {
  if (isModifiable()) {
    final Collection<Identifier> p = identifiers;
    super.freeze();
    /*
     * The 'identifiers' collection will have been replaced by an unmodifiable collection if
     * subclass has an "identifiers" property. If this is not the case, then the collection
     * is unchanged (or null) so we have to make it unmodifiable here.
     */
    if (p == identifiers) {
      identifiers = CollectionsExt.unmodifiableOrCopy(p);                     // Null safe.
    }
  }
}
origin: org.apache.sis.core/sis-utility

  i++;
memberIndices = CollectionsExt.unmodifiableOrCopy(memberIndices);
baseValueClass = (baseValueClass != null) ? Numbers.wrapperToPrimitive(baseValueClass) : Object.class;
return types;
origin: apache/sis

/**
 * Stores the given result in the cache.
 * This method shall be invoked only when {@link #getSearchDomain()} is not {@link Domain#DECLARATION}.
 */
@Override
final Set<IdentifiedObject> cache(final IdentifiedObject object, Set<IdentifiedObject> result) {
  final Map<IdentifiedObject,FindEntry> findPool = ((ConcurrentAuthorityFactory<?>) factory).findPool;
  result = CollectionsExt.unmodifiableOrCopy(result);
  FindEntry entry = new FindEntry();
  synchronized (findPool) {
    final FindEntry c = findPool.putIfAbsent(object, entry);
    if (c != null) {
      entry = c;          // May happen if the same set has been computed in another thread.
    }
    // 'finder' should never be null since this method is not invoked directly by this Finder.
    result = entry.set(finder.isIgnoringAxes(), result, object == searching);
  }
  return result;
}
origin: apache/sis

  i++;
memberIndices = CollectionsExt.unmodifiableOrCopy(memberIndices);
baseValueClass = (baseValueClass != null) ? Numbers.wrapperToPrimitive(baseValueClass) : Object.class;
return types;
origin: org.apache.sis.core/sis-utility

components = CollectionsExt.unmodifiableOrCopy(components);
dim = new UnitDimension(components);
if (!Units.initialized) {
origin: apache/sis

if (dim == null) {
  components.replaceAll((c, power) -> power.unique());
  components = CollectionsExt.unmodifiableOrCopy(components);
  dim = new UnitDimension(components);
  if (!Units.initialized) {
origin: apache/sis

if (state == COMPLETABLE) {
  if (useSet) {
    target = CollectionsExt.unmodifiableOrCopy((Set<E>) target);
  } else {
    target = CollectionsExt.unmodifiableOrCopy((List<E>) target);
origin: org.apache.sis.core/sis-referencing

/**
 * Stores the given result in the cache.
 * This method shall be invoked only when {@link #getSearchDomain()} is not {@link Domain#DECLARATION}.
 */
@Override
final Set<IdentifiedObject> cache(final IdentifiedObject object, Set<IdentifiedObject> result) {
  final Map<IdentifiedObject,FindEntry> findPool = ((ConcurrentAuthorityFactory<?>) factory).findPool;
  result = CollectionsExt.unmodifiableOrCopy(result);
  FindEntry entry = new FindEntry();
  synchronized (findPool) {
    final FindEntry c = JDK8.putIfAbsent(findPool, object, entry);
    if (c != null) {
      entry = c;          // May happen if the same set has been computed in another thread.
    }
    // 'finder' should never be null since this method is not invoked directly by this Finder.
    result = entry.set(finder.isIgnoringAxes(), result, object == searching);
  }
  return result;
}
origin: org.apache.sis.core/sis-metadata

  entry.setValue(clone(entry.getValue()));
return CollectionsExt.unmodifiableOrCopy(map);
org.apache.sis.internal.utilCollectionsExtunmodifiableOrCopy

Javadoc

Returns a unmodifiable version of the given collection. If the given collection is a Set or a List, then this method tries to return a collection of the same type. Other types are not guaranteed to be preserved.

The collection returned by this method may or may not be a view of the given collection. Consequently this method shall be used only if the given collection will not be modified after this method call. In case of doubt, use the standard Collections#unmodifiableCollection(Collection) method instead.

Popular methods of CollectionsExt

  • singletonOrEmpty
    Returns the given value as a singleton if non-null, or returns an empty set otherwise.
  • 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
  • modifiableCopy
    Copies the content of the given map to a new unsynchronized, modifiable, in-memory map. The implemen
  • identityEquals,
  • modifiableCopy,
  • nonNullArraySet,
  • removeFromMultiValuesMap,
  • toCaseInsensitiveNameMap,
  • toCollection,
  • empty,
  • emptyQueue,
  • nonEmpty

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (Timer)
  • getResourceAsStream (ClassLoader)
  • requestLocationUpdates (LocationManager)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Best IntelliJ 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