code: public static Enum castToEnum(Object object, Class<? extends Enum> type) {
          if (object==null) return null;
          if (type.isInstance(object)) return (Enum) object;
          if (object instanceof String || object instanceof GString) {
              return Enum.valueOf(type, object.toString());
          }
          throw new GroovyCastException(object, type);
      }
docs: this class requires that the supplied enum is not fitting a
  Collection case for casting