T - type of wrapped valuepublic abstract class Microtype<T> extends java.lang.Object implements Value<T>
It implements equals(), hashCode() and toString() methods
Main purpose of this class is to be able to wrap simple types and add them a class name, to make the code more readable. So instead of using String you could use AccountNumber that extends Microtype<String> or instead of BigDecimal you could use a Salary that extends Microtype<BigDecimal>.
| Modifier | Constructor and Description |
|---|---|
protected |
Microtype(T value)
Constructor of
Microtype initialized with value to wrap |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object other)
Evaluates if object to compare is of the same Microtype type and the wrapped
values are equal
|
T |
getValue()
Returns the wrapped value
|
int |
hashCode()
Returns wrapped value
hashCode() method response. |
<T2> T2 |
map(java.util.function.Function<? super T,? extends T2> mapper)
Maps wrapped value using the provided
Function. |
java.lang.String |
toString()
Returns wrapped value
toString() method response. |
T |
value()
Returns the wrapped value
|
protected Microtype(T value)
Microtype initialized with value to wrapvalue - value that should be wrapped and will be accessible from
created Microtype instancejava.lang.IllegalArgumentException - if null is passed as input parameterpublic T value()
public T getValue()
public <T2> T2 map(java.util.function.Function<? super T,? extends T2> mapper)
Function.T2 - the type of generated valuemapper - function to map the wrapped valuepublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - value to compare totrue if other value is of the same Microtype type and wraps
the same value. Otherwise returns falsepublic int hashCode()
hashCode() method response.hashCode in class java.lang.Objectpublic java.lang.String toString()
toString() method response.toString in class java.lang.Object