Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Small optimization of MetricType retrieval
Signed-off-by: mitra.chandra <bhanumchandra@gmail.com>
  • Loading branch information
bhchandra authored and jmartisk committed Sep 5, 2019
1 parent 82eabe8 commit 6943929
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -87,15 +87,16 @@ public String toString() {
return type;
}

/**
private static final EnumSet<MetricType> METRIC_TYPES = EnumSet.allOf(MetricType.class);

/**
* Convert the string representation into an enum
* @param in the String representation
* @return the matching Enum
* @throws IllegalArgumentException if in is not a valid enum value
*/
public static MetricType from(String in) {
EnumSet<MetricType> enumSet = EnumSet.allOf(MetricType.class);
for (MetricType u : enumSet) {
for (MetricType u : METRIC_TYPES) {
if (u.type.equals(in)) {
return u;
}
Expand All @@ -110,8 +111,7 @@ public static MetricType from(String in) {
* @throws IllegalArgumentException if in is not a valid metric class
*/
public static MetricType from(Class<?> in) {
EnumSet<MetricType> enumSet = EnumSet.allOf(MetricType.class);
for (MetricType u : enumSet) {
for (MetricType u : METRIC_TYPES) {
if (u.classtype != null && u.classtype.isAssignableFrom(in)) {
return u;
}
Expand Down

0 comments on commit 6943929

Please sign in to comment.