static Constant toConstant(Object value) {
      Class clazz = value.getClass();
      if (clazz.isEnum()) {
        CstString descriptor = new CstString(TypeId.get(clazz).getName());
        CstString name = new CstString(((Enum) value).name());
        CstNat cstNat = new CstNat(name, descriptor);
        return new CstEnumRef(cstNat);
      } else if (clazz.isArray()) {
        throw new UnsupportedOperationException("Array is not supported yet");
      } else if (value instanceof TypeId) {
        throw new UnsupportedOperationException("TypeId is not supported yet");
      } else {
        return Constants.getConstant(value);
      }
    }
Convert a value of an element to a {@code Constant}.

<p><strong>Warning:</strong> Array or TypeId value is not supported yet.

@param value an annotation element value.
@return a Constant
android/android_framework/dex-maker/src/main/java/com/android/dx/AnnotationId.java