> +      }
> +
> +      /**
> +       * 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;
> +      }

I might be misunderstanding some of the previous discussion here?

* Can `type` here ever be `null` on a legitimate response from the server (cc 
@zack-shoylev?) If so, what should the response be? `null` or `UNRECOGNIZED`?
* Can `type` here ever be a non-null value that doesn't match the `Type` enum? 
From what I understand, that may indeed be possible (e.g. if the jclouds enum 
is out-of-date), and the result in that case should be `UNRECOGNIZED`

In that case, how about something like:
```
public static Type fromValue(String type) {
   if (type == null) {
      return null;
   }
   try {
      return Type.valueOf(type);
   } catch(IllegalArgumentException e) {
      logger.warn("Unrecognized console type: " + 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#r13215901

Reply via email to