public static < T extends Enum < T > > Optional < T > asEnumValue ( Class < T > clazz , Attribute a ) { class Visitor extends SimpleAnnotationValueVisitor8 < T , Void > { @ Override public T visitEnumConstant ( VariableElement c , Void unused ) { return Enum . valueOf ( clazz , c . getSimpleName ( ) . toString ( ) ) ; } } return Optional . ofNullable ( a . accept ( new Visitor ( ) , null ) ) ; }
Converts the given attribute to an enum value .