Class Recyclers

java.lang.Object
io.activej.common.recycle.Recyclers

public class Recyclers extends Object
A registry of known Recyclers
  • Constructor Details

    • Recyclers

      public Recyclers()
  • Method Details

    • register

      public static <T> void register(Class<T> type, Recycler<T> item)
      Registers a new recycler for some type
      Type Parameters:
      T - a type of object that will be recycled
      Parameters:
      type - a class of object that will be recycled
      item - a recycler for a given type
      Throws:
      IllegalStateException - if a recycler for a type already exists and is not equal to a given recycler
    • recycle

      public static void recycle(Object object)
      Recycles a given object if there is a registered recycler for an object's class. Otherwise, does nothing
      Parameters:
      object - an object to be recycled
    • ensureRecycler

      @NotNull public static @NotNull Recycler<?> ensureRecycler(@NotNull @NotNull Class<?> type)
      Ensures a recycler for a given type
      Parameters:
      type - a type for which a recycler will be ensured
      Returns:
      an ensured recycler for a given type
      Throws:
      IllegalArgumentException - if there are conflicting recyclers that match given type