Package com.google.common.base
Class Enums.StringConverter<T extends java.lang.Enum<T>>
- java.lang.Object
-
- com.google.common.base.Converter<java.lang.String,T>
-
- com.google.common.base.Enums.StringConverter<T>
-
- All Implemented Interfaces:
Function<java.lang.String,T>
,java.io.Serializable
,java.util.function.Function<java.lang.String,T>
- Enclosing class:
- Enums
private static final class Enums.StringConverter<T extends java.lang.Enum<T>> extends Converter<java.lang.String,T> implements java.io.Serializable
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<T>
enumClass
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description StringConverter(java.lang.Class<T> enumClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
doBackward(T enumValue)
Returns a representation ofb
as an instance of typeA
.protected T
doForward(java.lang.String value)
Returns a representation ofa
as an instance of typeB
.boolean
equals(java.lang.Object object)
Indicates whether another object is equal to this converter.int
hashCode()
java.lang.String
toString()
-
Methods inherited from class com.google.common.base.Converter
andThen, apply, convert, convertAll, correctedDoBackward, correctedDoForward, doAndThen, from, identity, reverse
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StringConverter
StringConverter(java.lang.Class<T> enumClass)
-
-
Method Detail
-
doForward
protected T doForward(java.lang.String value)
Description copied from class:Converter
Returns a representation ofa
as an instance of typeB
. Ifa
cannot be converted, an unchecked exception (such asIllegalArgumentException
) should be thrown.
-
doBackward
protected java.lang.String doBackward(T enumValue)
Description copied from class:Converter
Returns a representation ofb
as an instance of typeA
. Ifb
cannot be converted, an unchecked exception (such asIllegalArgumentException
) should be thrown.- Specified by:
doBackward
in classConverter<java.lang.String,T extends java.lang.Enum<T>>
- Parameters:
enumValue
- the instance to convert; will never be null- Returns:
- the converted instance; must not be null
-
equals
public boolean equals(@CheckForNull java.lang.Object object)
Description copied from class:Converter
Indicates whether another object is equal to this converter.Most implementations will have no reason to override the behavior of
Object.equals(java.lang.Object)
. However, an implementation may also choose to returntrue
wheneverobject
is aConverter
that it considers interchangeable with this one. "Interchangeable" typically means thatObjects.equal(this.convert(a), that.convert(a))
is true for alla
of typeA
(and similarly forreverse
). Note that afalse
result from this method does not imply that the converters are known not to be interchangeable.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-