Class Utility

java.lang.Object
com.rabbitmq.utility.Utility

public class Utility extends Object
Catch-all holder class for static helper methods.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <E> List<E>
    copy(List<E> list)
    Synchronizes on the list and then returns a copy of the list that is safe to iterate over.
    static <K, V> Map<K,V>
    copy(Map<K,V> map)
    Synchronizes on the map and then returns a copy of the map that is safe to iterate over.
    static <E> Set<E>
    copy(Set<E> set)
    Synchronizes on the set and then returns a copy of the set that is safe to iterate over.
    static <T extends Throwable & SensibleClone<T>>
    T
    fixStackTrace(T throwable)
     
    static String
    Deprecated.
    use logging library instead for logging stack traces somewhere

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Utility

      public Utility()
  • Method Details

    • fixStackTrace

      public static <T extends Throwable & SensibleClone<T>> T fixStackTrace(T throwable)
    • makeStackTrace

      public static String makeStackTrace(Throwable throwable)
      Deprecated.
      use logging library instead for logging stack traces somewhere
      Parameters:
      throwable -
      Returns:
    • copy

      public static <E> Set<E> copy(Set<E> set)
      Synchronizes on the set and then returns a copy of the set that is safe to iterate over. Useful when wanting to do thread-safe iteration over a Set wrapped in Collections.synchronizedSet(Set).
      Parameters:
      set - The set, which may not be null
      Returns:
      LinkedHashSet copy of the set
    • copy

      public static <E> List<E> copy(List<E> list)
      Synchronizes on the list and then returns a copy of the list that is safe to iterate over. Useful when wanting to do thread-safe iteration over a List wrapped in Collections.synchronizedList(List).
      Parameters:
      list - The list, which may not be null
      Returns:
      ArrayList copy of the list
    • copy

      public static <K, V> Map<K,V> copy(Map<K,V> map)
      Synchronizes on the map and then returns a copy of the map that is safe to iterate over. Useful when wanting to do thread-safe iteration over a Map wrapped in Collections.synchronizedMap(Map)
      Parameters:
      map - The map, which may not be null
      Returns:
      LinkedHashMap copy of the map