Package org.apache.commons.lang3.mutable
Class MutableObject<T>
- java.lang.Object
-
- org.apache.commons.lang3.mutable.MutableObject<T>
-
- Type Parameters:
T- the type to set and get
- All Implemented Interfaces:
java.io.Serializable,Mutable<T>
public class MutableObject<T> extends java.lang.Object implements Mutable<T>, java.io.Serializable
A mutableObjectwrapper.- Since:
- 2.1
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MutableObject()Constructs a new MutableObject with the default value ofnull.MutableObject(T value)Constructs a new MutableObject with the specified value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Compares this object against the specified object.TgetValue()Gets the value.inthashCode()Returns the value's hash code or0if the value isnull.voidsetValue(T value)Sets the value.java.lang.StringtoString()Returns the String value of this mutable.
-
-
-
Constructor Detail
-
MutableObject
public MutableObject()
Constructs a new MutableObject with the default value ofnull.
-
MutableObject
public MutableObject(T value)
Constructs a new MutableObject with the specified value.- Parameters:
value- the initial value to store
-
-
Method Detail
-
getValue
public T getValue()
Gets the value.
-
setValue
public void setValue(T value)
Sets the value.
-
equals
public boolean equals(java.lang.Object obj)
Compares this object against the specified object. The result is
trueif and only if the argument is notnulland is aMutableObjectobject that contains the sameTvalue as this object.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to compare with,nullreturnsfalse- Returns:
trueif the objects are the same;trueif the objects have equivalentvaluefields;falseotherwise.
-
hashCode
public int hashCode()
Returns the value's hash code or0if the value isnull.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the value's hash code or
0if the value isnull.
-
toString
public java.lang.String toString()
Returns the String value of this mutable.- Overrides:
toStringin classjava.lang.Object- Returns:
- the mutable value as a string
-
-