Package com.google.caliper.memory
Class Chain
- java.lang.Object
-
- com.google.caliper.memory.Chain
-
public abstract class Chain extends Object
A chain of references, which starts at a root object and leads to a particular value (either an object or a primitive).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ChaingetParent()Returns the parent chain, from which this chain was created.ObjectgetRoot()Returns the root object of this chain.ObjectgetValue()Returns the value that this chain leads to.abstract Class<?>getValueType()booleanhasParent()Returns whether this chain has a parent.booleanisPrimitive()Returns whether the value of this chain represents a primitive.booleanisThroughArrayIndex()Returns whether the connection of the parent chain and this chain is through an array index, i.e.booleanisThroughField()Returns whether the connection of the parent chain and this chain is through a field (of the getParent().getValue().getClass() class).StringtoString()
-
-
-
Method Detail
-
hasParent
public boolean hasParent()
Returns whether this chain has a parent. This returns false only when this chain represents the root object itself.
-
getParent
@Nonnull public Chain getParent()
Returns the parent chain, from which this chain was created.- Throws:
IllegalStateException- if!hasParent(), then an
-
getValue
@Nullable public Object getValue()
Returns the value that this chain leads to. If the value is a primitive, a wrapper object is returned instead.
-
isThroughField
public boolean isThroughField()
Returns whether the connection of the parent chain and this chain is through a field (of the getParent().getValue().getClass() class).
-
isThroughArrayIndex
public boolean isThroughArrayIndex()
Returns whether the connection of the parent chain and this chain is through an array index, i.e. the parent leads to an array, and this chain leads to an element of that array.
-
isPrimitive
public boolean isPrimitive()
Returns whether the value of this chain represents a primitive.
-
-