Package io.activej.common.recycle
Class Recyclers
java.lang.Object
io.activej.common.recycle.Recyclers
A registry of known
Recyclers-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Recycler<?>ensureRecycler(@NotNull Class<?> type) Ensures a recycler for a given typestatic voidRecycles a given object if there is a registered recycler for an object's class.static <T> voidRegisters a new recycler for some type
-
Constructor Details
-
Recyclers
public Recyclers()
-
-
Method Details
-
register
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 recycleditem- 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
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
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
-