private static <T extends Enum<T>> Map<String, T> getValueMapping(Class<T> enumClass) {

        T[] values = enumClass.getEnumConstants();
        Map<String, T> valueMapping = new HashMap<>(values.length);

        for (T value : values) {

            // Retrieve Field which corresponds to the current enum constant
            Field field;
            try {
                field = enumClass.getDeclaredField(value.name());
            }
            catch (NoSuchFieldException e) {
                // This SHOULD be impossible
                throw new IllegalStateException("Fields of enum do not "
                        + "match declared values.", e);
            }

            // Map enum constant only if one or more PropertyValue annotations
            // are present
            PropertyValues valuesAnnotation = field.getAnnotation(PropertyValues.class);
            if (valuesAnnotation != null) {
                for (PropertyValue valueAnnotation : valuesAnnotation.value())
                    valueMapping.put(valueAnnotation.value(), value);
            }

            // The PropertyValue annotation may appear as a separate, single
            // annotation, or as a multi-valued annotation via PropertyValues
            // (see above)
            PropertyValue valueAnnotation = field.getAnnotation(PropertyValue.class);
            if (valueAnnotation != null)
                valueMapping.put(valueAnnotation.value(), value);

        }

        return valueMapping;

    }
Produces a mapping of Guacamole property value to corresponding enum
constant. All enum constants annotated with {@link PropertyValue} are
included in the resulting Map.

@param <T>
    The enum for which a value mapping is being produced.

@param enumClass
    The Class of the enum for which a value mapping is being produced.

@return
    A new Map which associates the Guacamole property string values of
    enum constants (as defined by {@link PropertyValue} annotations)
    with their corresponding enum constants.
guacamole-ext/src/main/java/org/apache/guacamole/properties/EnumGuacamoleProperty.java