uk.ac.starlink.util

## Class Util

- java.lang.Object
- - uk.ac.starlink.util.Util

-     public class Util
      extends java.lang.Object

  General class containing utility methods. Several of these relate to the java.util classes.
  Since:
    18 Jul 2023

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> boolean` | `contains(java.util.Collection<T> collection, T item)` Typed contains test.
    `static <K,V> boolean` | `containsKey(java.util.Map<K,V> map, K key)` Typed map key test operation.
    `static <T> boolean` | `equals(T t1, T t2)` Typed equality operation.
    `static <K,V> V` | `get(java.util.Map<K,V> map, K key)` Typed map get operation.
    `static <K,V> V` | `remove(java.util.Map<K,V> map, K key)` Typed map remove operation.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### get

          public static <K,V> V get(java.util.Map<K,V> map,
                                    K key)

      Typed map get operation. This simply calls `Map.get(Object)`, but it provides compile-time assurance that the supplied key has the right type.
      Parameters:
        `map` - map
        `key` - key
      Returns:
        result of map.get(key)

    - #### containsKey

          public static <K,V> boolean containsKey(java.util.Map<K,V> map,
                                                  K key)

      Typed map key test operation. This simply calls `Map.containsKey(Object)`, but it provides compile-time assurance that the supplied key has the right type.
      Parameters:
        `map` - map
        `key` - key
      Returns:
        result of map.containsKey(key)

    - #### remove

          public static <K,V> V remove(java.util.Map<K,V> map,
                                       K key)

      Typed map remove operation. This simply calls `Map.remove(Object)`, but it provides compile-time assurance that the supplied key has the right type.
      Parameters:
        `map` - map
        `key` - key
      Returns:
        result of map.remove(key)

    - #### equals

          public static <T> boolean equals(T t1,
                                           T t2)

      Typed equality operation. This simply calls `Objects.equals(Object,Object)`, but provides compile-time assurance that the two supplied parameters have the same type.
      Parameters:
        `t1` - first object
        `t2` - second object
      Returns:
        result of Objects.equals(t1, t1)

    - #### contains

          public static <T> boolean contains(java.util.Collection<T> collection,
                                             T item)

      Typed contains test. This simply calls `Collection.contains(java.lang.Object)`, but provides compile-time assurance that the item's type is compatible with the collection.
      Parameters:
        `collection` - collection
        `item` - item
      Returns:
        true iff item is in collection (equality semantics)