Class CollectionUtil

java.lang.Object
ca.uhn.fhir.util.CollectionUtil

public class CollectionUtil extends Object
  • Method Details

    • nullSafeUnion

      @Nonnull public static <T> Collection<T> nullSafeUnion(@Nullable Collection<T> theCollection0, @Nullable Collection<T> theCollection1)
      Returns an immutable union of both collections. If either or both arguments are null they will be treated as an empty collection, meaning that even if both arguments are null, an empty immutable collection will be returned.

      DO NOT use this method if the underlying collections can be changed after calling this method, as the behaviour is indeterminate.

      Parameters:
      theCollection0 - The first set in the union, or null.
      theCollection1 - The second set in the union, or null.
      Returns:
      Returns a union of both collections. Will not return null ever.
      Since:
      7.4.0
    • newSet

      public static <T> Set<T> newSet(T... theValues)
      This method is equivalent to Set.of(...) but is kept here and used instead of that method because Set.of is not present on Android SDKs (at least up to 29).

      Sets returned by this method are unmodifiable.