Package com.vladris.maki
Class VariantBase
- java.lang.Object
-
- com.vladris.maki.VariantBase
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
<T> T
get()
Gets the item inhabiting the variant as aT
.byte
getIndex()
Gets the 0-based index of the type inhabiting the variant.java.lang.Object
getItem()
Gets the item inhabiting the variant as an Object.int
hashCode()
<T> boolean
is(java.lang.Class<T> type)
Returns a value that indicates whether the variant is inhabited by an item of typeT
.
-
-
-
Method Detail
-
getIndex
public byte getIndex()
Gets the 0-based index of the type inhabiting the variant.- Returns:
- 0-based index of the type inhabiting the variant.
-
is
public <T> boolean is(java.lang.Class<T> type)
Returns a value that indicates whether the variant is inhabited by an item of typeT
.- Type Parameters:
T
- Should be one of the variant's supplied types.- Parameters:
type
- Class ofT
.- Returns:
true
if the variant is inhabited by an item of typeT
, false otherwise.
-
get
public <T> T get()
Gets the item inhabiting the variant as aT
.- Type Parameters:
T
- Should be one of the variant's supplied types.- Returns:
- Item inhabiting the variant as the given type
T
.
-
getItem
public java.lang.Object getItem()
Gets the item inhabiting the variant as an Object.- Returns:
- Item inhabiting the variant as an Object.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-