Last active
December 22, 2016 05:19
-
-
Save jorgejch/0be6b7790789624dba34062c7ba959fd to your computer and use it in GitHub Desktop.
Enum for reverse lookup.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum SEARCHABLE { | |
DESCRIPTION("description"), | |
NAME("name"), | |
DISPLAYNAME("displayName"), | |
TAGS("tags"); | |
final private static Set<String> _searchableFieldNames = | |
Arrays.stream(SEARCHABLE.values()).map(SEARCHABLE::getFieldName).collect(Collectors.toSet()); | |
final private String _fieldName; | |
SEARCHABLE(String fieldName) { | |
_fieldName = fieldName; | |
} | |
public static boolean isFieldNameSearchable(String fieldName) { | |
return SEARCHABLE._searchableFieldNames.contains(fieldName); | |
} | |
public String getFieldName() { | |
return _fieldName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment