Class Intern<T>
- java.lang.Object
-
- com.biomatters.geneious.publicapi.utilities.Intern<T>
-
public class Intern<T> extends java.lang.Object
Manages manually interning Objects (likeString.intern()
) except this implemenation avoids the following pitfalls withString.intern()
- Objects are not interned into the permgen (the permgen is independent of the normal heap and limited to 64MB by default), so using String.intern too often can result in OutOfMemory errors when you have plently of free space
- This implemenation is faster than String.intern since it doesn't have to deal with garbage collecting weak references
- No automatic garbage collection of Objects. Instead, you must discard the refernce to this Intern object to
allow Objects to be garbage collected
-
-
Constructor Summary
Constructors Constructor Description Intern()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the intenal cache of interned Objects.T
intern(T objectToIntern)
Interns an object.
-
-
-
Method Detail
-
intern
public T intern(T objectToIntern)
Interns an object.- Parameters:
objectToIntern
- the object to intern- Returns:
- the
objectToIntern
passed to a previous call to this method if that Object was equal to this Object orobjectToIntern
if this Object has not been previously interned.
-
clear
public void clear()
Clears the intenal cache of interned Objects.
-
-