> +      }
> +
> +      /**
> +       * Used from jclouds builtin deserializer.
> +       */
> +      public static Type fromValue(String type) {
> +          if (type != null) {
> +             for (Type value : Type.values()) {
> +                if (type.equals(value.type)) {
> +                   return value;
> +                }
> +             }
> +             return UNRECOGNIZED;
> +          }
> +          return null;
> +      }

> In the implementation you provide, you use the enum valueOf(), which cannot 
> be overriden, in order to map the 
> values in the constructors with the enum values.

Indeed. Maybe I was misunderstanding your code, but unless `equals` on Type is 
overridden `type.equals(value.type)` in the current implementation should have 
the same effect?

If, as @zack-shoylev suggests, we should support case-insensitive matching too, 
then `Type.valueOf` in my suggestion will of course need to be replaced 
something more like:
```
public static Type fromValue(String value) {
   if (value == null) {
      return null;
   }
   // Or compute the value in the Type class and expose a method 
lowercaseValues() there?
   // Or indeed simply add a `caseInsensitiveValueOf(String value)` method on 
Type?
   for (Type type : Type.values()) { 
      if (type.equalsIgnoreCase(value)) {
         return value;
      }
   }
   logger.warn("Unrecognized console type: %s", type); // or logger.debug or so?
   return UNRECOGNIZED;
}
```


---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/339/files#r13315742

Reply via email to