Class WXMNamedParameter<T>
java.lang.Object
com.io7m.waxmill.cmdline.internal.WXMNamedParameter<T>
- All Implemented Interfaces:
WXMNamedParameterType<T>
public final class WXMNamedParameter<T> extends java.lang.Object implements WXMNamedParameterType<T>
Immutable implementation of
WXMNamedParameterType.
Use the builder to create immutable instances:
WXMNamedParameter.builder().
Use the static factory method to create immutable instances:
WXMNamedParameter.of().
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWXMNamedParameter.Builder<T>Builds instances of typeWXMNamedParameter. -
Method Summary
Modifier and Type Method Description static <T> WXMNamedParameter.Builder<T>builder()Creates a builder forWXMNamedParameter.static <T> WXMNamedParameter<T>copyOf(WXMNamedParameterType<T> instance)Creates an immutable copy of aWXMNamedParameterTypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofWXMNamedParameterthat have equal attribute values.inthashCode()Computes a hash code from attributes:name,value.java.lang.Stringname()static <T> WXMNamedParameter<T>of(java.lang.String name, T value)Construct a new immutableWXMNamedParameterinstance.java.lang.StringtoString()Prints the immutable valueWXMNamedParameterwith attribute values.Tvalue()WXMNamedParameter<T>withName(java.lang.String value)Copy the current immutable object by setting a value for thenameattribute.WXMNamedParameter<T>withValue(T value)Copy the current immutable object by setting a value for thevalueattribute.
-
Method Details
-
name
public java.lang.String name()- Specified by:
namein interfaceWXMNamedParameterType<T>- Returns:
- The value of the
nameattribute
-
value
- Specified by:
valuein interfaceWXMNamedParameterType<T>- Returns:
- The value of the
valueattribute
-
withName
Copy the current immutable object by setting a value for thenameattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for name- Returns:
- A modified copy of the
thisobject
-
withValue
Copy the current immutable object by setting a value for thevalueattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for value- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(java.lang.Object another)This instance is equal to all instances ofWXMNamedParameterthat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()Computes a hash code from attributes:name,value.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()Prints the immutable valueWXMNamedParameterwith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
of
Construct a new immutableWXMNamedParameterinstance.- Type Parameters:
T- generic parameter T- Parameters:
name- The value for thenameattributevalue- The value for thevalueattribute- Returns:
- An immutable WXMNamedParameter instance
-
copyOf
Creates an immutable copy of aWXMNamedParameterTypevalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Type Parameters:
T- generic parameter T- Parameters:
instance- The instance to copy- Returns:
- A copied immutable WXMNamedParameter instance
-
builder
Creates a builder forWXMNamedParameter.WXMNamedParameter.<T>builder() .setName(String) // requiredname.setValue(T) // requiredvalue.build();- Type Parameters:
T- generic parameter T- Returns:
- A new WXMNamedParameter builder
-