Example usage for java.lang Class getEnumConstants

List of usage examples for java.lang Class getEnumConstants

Introduction

In this page you can find the example usage for java.lang Class getEnumConstants.

Prototype

public T[] getEnumConstants() 

Source Link

Document

Returns the elements of this enum class or null if this Class object does not represent an enum type.

Usage

From source file:org.talend.metadata.managment.hive.EmbeddedHiveDataBaseMetadata.java

@Override
public ResultSet getTables(String catalog, String schema, String tableNamePattern, String[] types)
        throws SQLException {
    if (hiveObject == null) {
        throw new SQLException("Unable to instantiate org.apache.hadoop.hive.ql.metadata.Hive."); //$NON-NLS-1$
    }// www  . j av a2 s  . co  m
    String hiveCat = catalog;
    if (StringUtils.isBlank(hiveCat)) {
        hiveCat = HIVE_SCHEMA_DEFAULT;
    }
    String[] hiveTypes = types;
    if (hiveTypes == null) {
        hiveTypes = new String[0];
    }

    // Added this for TDI-25456 by Marvin Wang on Apr. 11, 2013.
    ClassLoader currCL = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(classLoader);

    EmbeddedHiveResultSet tableResultSet = new EmbeddedHiveResultSet();
    tableResultSet.setMetadata(TABLE_META);
    List<String[]> list = new ArrayList<String[]>();
    tableResultSet.setData(list);

    try {
        Class hiveClass = hiveObject.getClass();
        Method method = hiveClass.getDeclaredMethod("getConf");//$NON-NLS-1$ 
        Object hiveConf = method.invoke(hiveObject);
        Class hiveConfClass = hiveConf.getClass();
        // find ConfVar enum in the HiveConf class.
        Class confVarClass = null;
        for (Class curClass : hiveConfClass.getClasses()) {
            if (curClass.getSimpleName().equals("ConfVars")) { //$NON-NLS-1$
                confVarClass = curClass;
                break;
            }
        }
        if (confVarClass != null) {
            Object confVar = null;
            // try to find enumeration: ConfVars.METASTORE_CLIENT_SOCKET_TIMEOUT
            for (Object curConfVar : confVarClass.getEnumConstants()) {
                if (curConfVar.toString().equals("hive.metastore.client.socket.timeout")) { //$NON-NLS-1$
                    confVar = curConfVar;
                    break;
                }
            }
            if (confVar != null) {
                Method setIntVarMethod = hiveConfClass.getDeclaredMethod("setIntVar", confVarClass, int.class); //$NON-NLS-1$
                int timeout = 15;
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
                    IDesignerCoreService designerService = (IDesignerCoreService) GlobalServiceRegister
                            .getDefault().getService(IDesignerCoreService.class);
                    timeout = designerService.getDBConnectionTimeout();
                }
                setIntVarMethod.invoke(hiveConf, confVar, timeout);
            }
        }
        String tempTableNamepattern = tableNamePattern;
        if (StringUtils.isEmpty(tempTableNamepattern)
                || TableInfoParameters.DEFAULT_FILTER.equals(tempTableNamepattern)) {
            tempTableNamepattern = "*"; //$NON-NLS-1$
        }
        Object tables = ReflectionUtils.invokeMethod(hiveObject, "getTablesByPattern", //$NON-NLS-1$
                new Object[] { hiveCat, tempTableNamepattern });
        if (tables instanceof List) {
            List<String> tableList = (List<String>) tables;
            for (String tableName : tableList) {
                String tableType = getTableType(hiveCat, tableName);
                if (tableType != null && ArrayUtils.contains(hiveTypes, tableType)) {
                    String[] array = new String[] { "", hiveCat, tableName, tableType, "" }; //$NON-NLS-1$//$NON-NLS-2$
                    list.add(array);
                }
            }
        }
    } catch (Exception e) {
        throw new SQLException(e);
    } finally {
        Thread.currentThread().setContextClassLoader(currCL);
    }

    return tableResultSet;
}

From source file:com.grepcurl.random.ObjectGenerator.java

protected <T> T generate(Class<T> klass, SetterOverrides setterOverrides, Deque<Object> objectStack,
        Object... constructorArgs) {
    Validate.notNull(klass);/*from  ww w.  ja va 2 s.  c o m*/
    Validate.notNull(constructorArgs);
    if (verbose) {
        log(String.format("generating object of type: %s, with args: %s, with overrides: %s", klass,
                Arrays.toString(constructorArgs), setterOverrides));
    }
    try {
        Class[] constructorTypes = _toClasses(constructorArgs);
        T t;
        if (klass.isEnum()) {
            int randomOrdinal = randomInt(0, klass.getEnumConstants().length - 1);
            t = klass.getEnumConstants()[randomOrdinal];
        } else {
            t = klass.getConstructor(constructorTypes).newInstance(constructorArgs);
        }
        objectStack.push(t);
        Method[] methods = klass.getMethods();
        for (Method method : methods) {
            _processMethod(method, setterOverrides, t, objectStack);
        }
        objectStack.pop();
        return t;
    } catch (Exception e) {
        e.printStackTrace();
        throw new FailedRandomObjectGenerationException(e);
    }
}

From source file:com.google.api.server.spi.config.jsonwriter.JsonConfigWriter.java

/**
 * Adds an arbitrary, non-array type to a given schema config.
 *
 * @param schemasNode the config to store the generated type schema
 * @param type the type from which to generate a schema
 * @param enclosingType for bean properties, the enclosing bean type, used for resolving type
 *        variables/*w  w  w . j  a  v a  2 s  .  co  m*/
 * @return the name of the schema generated from the type
 */
@VisibleForTesting
String addTypeToSchema(ObjectNode schemasNode, TypeToken<?> type, TypeToken<?> enclosingType,
        ApiConfig apiConfig, List<ApiParameterConfig> parameterConfigs) throws ApiConfigException {
    if (typeLoader.isSchemaType(type)) {
        return typeLoader.getSchemaType(type);
    } else if (Types.isObject(type)) {
        if (!schemasNode.has(ANY_SCHEMA_NAME)) {
            ObjectNode anySchema = objectMapper.createObjectNode();
            anySchema.put("id", ANY_SCHEMA_NAME);
            anySchema.put("type", "any");
            schemasNode.set(ANY_SCHEMA_NAME, anySchema);
        }
        return ANY_SCHEMA_NAME;
    } else if (Types.isMapType(type)) {
        if (!schemasNode.has(MAP_SCHEMA_NAME)) {
            ObjectNode mapSchema = objectMapper.createObjectNode();
            mapSchema.put("id", MAP_SCHEMA_NAME);
            mapSchema.put("type", "object");
            schemasNode.set(MAP_SCHEMA_NAME, mapSchema);
        }
        return MAP_SCHEMA_NAME;
    }

    // If we already have this schema defined, don't define it again!
    String typeName = Types.getSimpleName(type, apiConfig.getSerializationConfig());
    JsonNode existing = schemasNode.get(typeName);
    if (existing != null && existing.isObject()) {
        return typeName;
    }

    ObjectNode schemaNode = objectMapper.createObjectNode();
    Class<?> c = type.getRawType();
    if (c.isEnum()) {
        schemasNode.set(typeName, schemaNode);
        schemaNode.put("id", typeName);
        schemaNode.put("type", "string");

        ArrayNode enumNode = objectMapper.createArrayNode();
        for (Object enumConstant : c.getEnumConstants()) {
            enumNode.add(enumConstant.toString());
        }
        schemaNode.set("enum", enumNode);
    } else {
        // JavaBean
        TypeToken<?> serializedType = ApiAnnotationIntrospector.getSchemaType(type, apiConfig);
        if (!type.equals(serializedType)) {
            return addTypeToSchema(schemasNode, serializedType, enclosingType, apiConfig, parameterConfigs);
        } else {
            addBeanTypeToSchema(schemasNode, typeName, schemaNode, type, apiConfig, parameterConfigs);
        }
    }
    return typeName;
}

From source file:com.delcyon.capo.Configuration.java

@SuppressWarnings({ "unchecked", "static-access" })
public Configuration(String... programArgs) throws Exception {

    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    documentBuilder = documentBuilderFactory.newDocumentBuilder();

    options = new Options();
    // the enum this is a little complicated, but it gives us a nice
    // centralized place to put all of the system parameters
    // and lets us iterate of the list of options and preferences
    PREFERENCE[] preferences = PREFERENCE.values();
    for (PREFERENCE preference : preferences) {
        // not the most elegant, but there is no default constructor, but
        // the has arguments value is always there
        OptionBuilder optionBuilder = OptionBuilder.hasArg(preference.hasArgument);
        if (preference.hasArgument == true) {
            String[] argNames = preference.arguments;
            for (String argName : argNames) {
                optionBuilder = optionBuilder.withArgName(argName);
            }//from w w  w  .  j  a va 2 s  . c o  m
        }

        optionBuilder = optionBuilder.withDescription(preference.getDescription());
        optionBuilder = optionBuilder.withLongOpt(preference.getLongOption());
        options.addOption(optionBuilder.create(preference.getOption()));

        preferenceHashMap.put(preference.toString(), preference);
    }

    //add dynamic options

    Set<String> preferenceProvidersSet = CapoApplication.getAnnotationMap()
            .get(PreferenceProvider.class.getCanonicalName());
    if (preferenceProvidersSet != null) {
        for (String className : preferenceProvidersSet) {
            Class preferenceClass = Class.forName(className).getAnnotation(PreferenceProvider.class)
                    .preferences();
            if (preferenceClass.isEnum()) {
                Object[] enumObjects = preferenceClass.getEnumConstants();
                for (Object enumObject : enumObjects) {

                    Preference preference = (Preference) enumObject;
                    //filter out any preferences that don't belong on this server or client.
                    if (preference.getLocation() != Location.BOTH) {
                        if (CapoApplication.isServer() == true && preference.getLocation() == Location.CLIENT) {
                            continue;
                        } else if (CapoApplication.isServer() == false
                                && preference.getLocation() == Location.SERVER) {
                            continue;
                        }
                    }
                    preferenceHashMap.put(preference.toString(), preference);
                    boolean hasArgument = false;
                    if (preference.getArguments() == null || preference.getArguments().length == 0) {
                        hasArgument = false;
                    } else {
                        hasArgument = true;
                    }

                    OptionBuilder optionBuilder = OptionBuilder.hasArg(hasArgument);
                    if (hasArgument == true) {
                        String[] argNames = preference.getArguments();
                        for (String argName : argNames) {
                            optionBuilder = optionBuilder.withArgName(argName);
                        }
                    }

                    optionBuilder = optionBuilder.withDescription(preference.getDescription());
                    optionBuilder = optionBuilder.withLongOpt(preference.getLongOption());
                    options.addOption(optionBuilder.create(preference.getOption()));
                }

            }
        }
    }

    // create parser
    CommandLineParser commandLineParser = new GnuParser();
    this.commandLine = commandLineParser.parse(options, programArgs);

    Preferences systemPreferences = Preferences
            .systemNodeForPackage(CapoApplication.getApplication().getClass());
    String capoDirString = null;
    while (true) {
        capoDirString = systemPreferences.get(PREFERENCE.CAPO_DIR.longOption, null);
        if (capoDirString == null) {

            systemPreferences.put(PREFERENCE.CAPO_DIR.longOption, PREFERENCE.CAPO_DIR.defaultValue);
            capoDirString = PREFERENCE.CAPO_DIR.defaultValue;
            try {
                systemPreferences.sync();
            } catch (BackingStoreException e) {
                //e.printStackTrace();            
                if (systemPreferences.isUserNode() == false) {
                    System.err.println("Problem with System preferences, trying user's");
                    systemPreferences = Preferences
                            .userNodeForPackage(CapoApplication.getApplication().getClass());
                    continue;
                } else //just bail out
                {
                    throw e;
                }

            }
        }
        break;
    }

    disableAutoSync = hasOption(PREFERENCE.DISABLE_CONFIG_AUTOSYNC);

    File capoDirFile = new File(capoDirString);
    if (capoDirFile.exists() == false) {
        if (disableAutoSync == false) {
            capoDirFile.mkdirs();
        }
    }
    File configDir = new File(capoDirFile, PREFERENCE.CONFIG_DIR.defaultValue);
    if (configDir.exists() == false) {
        if (disableAutoSync == false) {
            configDir.mkdirs();
        }
    }

    if (disableAutoSync == false) {
        capoConfigFile = new File(configDir, CONFIG_FILENAME);
        if (capoConfigFile.exists() == false) {

            Document configDocument = CapoApplication.getDefaultDocument("config.xml");

            FileOutputStream configFileOutputStream = new FileOutputStream(capoConfigFile);
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer();
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.transform(new DOMSource(configDocument), new StreamResult(configFileOutputStream));
            configFileOutputStream.close();
        }

        configDocument = documentBuilder.parse(capoConfigFile);
    } else //going memory only, because of disabled auto sync
    {
        configDocument = CapoApplication.getDefaultDocument("config.xml");
    }
    if (configDocument instanceof CDocument) {
        ((CDocument) configDocument).setSilenceEvents(true);
    }
    loadPreferences();
    preferenceValueHashMap.put(PREFERENCE.CAPO_DIR.longOption, capoDirString);
    //print out preferences
    //this also has the effect of persisting all of the default values if a values doesn't already exist
    for (PREFERENCE preference : preferences) {
        if (getValue(preference) != null) {
            CapoApplication.logger.log(Level.CONFIG, preference.longOption + "='" + getValue(preference) + "'");
        }
    }

    CapoApplication.logger.setLevel(Level.parse(getValue(PREFERENCE.LOGGING_LEVEL)));
}

From source file:com.amazon.kinesis.streaming.agent.config.Configuration.java

/**
 *
 * @param enumType//from  w  w  w . ja  v  a 2  s  .  c  o  m
 * @param key
 * @return the enum constant at given key.
 * @throws ConfigurationException
 *             if the enum constant failed to be returned.
 */
public <E extends Enum<E>> E readEnum(Class<E> enumType, String key) {
    String stringVal = readString(key, null);
    if (stringVal != null) {
        try {
            return Enum.valueOf(enumType, stringVal);
        } catch (Exception e) {
            throw new ConfigurationException(
                    String.format("Value(%s) is not legally accepted by key: %s. " + "Legal values are %s",
                            stringVal, key, Joiner.on(",").join(enumType.getEnumConstants())),
                    e);
        }
    } else
        throw new ConfigurationException("Required configuration value missing: " + key);
}

From source file:org.jboss.forge.roaster.model.impl.AnnotationImpl.java

private <E extends Enum<E>> E convertLiteralToEnum(final Class<E> type, String literalValue) {
    E[] constants = type.getEnumConstants();

    for (E inst : constants) {
        String[] tokens = literalValue.split("\\.");
        if (tokens.length > 1) {
            literalValue = tokens[tokens.length - 1];
        }//ww w .  j a v  a2s.  c  o m

        if (inst.name().equals(literalValue)) {
            return inst;
        }
    }
    return null;
}

From source file:com.amazon.kinesis.streaming.agent.config.Configuration.java

/**
 *
 * @param enumType/*  w  ww  .  j  ava2 s .c  om*/
 * @param key
 * @param fallback
 * @return the enum constant at given key, or <code>fallback</code> if the
 *         key does not exist in the configuration.
 * @throws ConfigurationException
 *             if the enum type is <code>null</code> or the specified enum type 
 *             has no constant with the specified value read from key
 */
public <E extends Enum<E>> E readEnum(Class<E> enumType, String key, E fallback) {
    String stringVal = readString(key, null);
    if (stringVal != null) {
        try {
            return Enum.valueOf(enumType, stringVal);
        } catch (Exception e) {
            throw new ConfigurationException(
                    String.format("Value(%s) is not legally accepted by key: %s. " + "Legal values are %s",
                            stringVal, key, Joiner.on(",").join(enumType.getEnumConstants())),
                    e);
        }
    } else
        return fallback;
}

From source file:org.wrml.runtime.schema.PropertyProtoSlot.java

PropertyProtoSlot(final Prototype prototype, final String slotName, final Property property) {

    super(prototype, slotName);

    if (property == null) {
        throw new NullPointerException(
                "Prototype (" + prototype + ") Slot (" + slotName + ") property cannot be null.");
    }/*  w ww  .ja  v a 2 s . c  o m*/

    _Property = property;

    final Type heapValueType = getHeapValueType();

    final SyntaxLoader syntaxLoader = getContext().getSyntaxLoader();

    final DefaultValue defaultValue = getAnnotation(DefaultValue.class);
    if (defaultValue != null) {
        final String defaultValueString = defaultValue.value();

        try {
            _DefaultValue = syntaxLoader.parseSyntacticText(defaultValueString, heapValueType);
        } catch (final Exception e) {

            throw new PrototypeException(prototype + " slot named \"" + slotName
                    + "\" default value annotation's value could not be converted from text value \""
                    + defaultValueString + "\" to a Java " + heapValueType + ". Detail message: "
                    + e.getMessage(), e, prototype, slotName);
        }
    }

    if (Boolean.TYPE.equals(heapValueType)) {
        if (_DefaultValue == null) {
            _DefaultValue = Boolean.FALSE;
        }
    } else if (TypeUtils.isAssignable(heapValueType, Enum.class)) {

        if (_DefaultValue == null) {
            // Enum's default to their first constant
            // Single selects default to the first choice
            @SuppressWarnings("unchecked")
            final Class<Enum<?>> enumValueType = (Class<Enum<?>>) heapValueType;
            if (enumValueType != null) {
                final Enum<?>[] enumChoices = enumValueType.getEnumConstants();
                if (enumChoices != null && enumChoices.length > 0) {
                    _DefaultValue = enumChoices[0];
                }
            }
        }

    } else if (TypeUtils.isAssignable(heapValueType, Number.class) || Integer.TYPE.equals(heapValueType)
            || Long.TYPE.equals(heapValueType) || Double.TYPE.equals(heapValueType)) {

        if (_DefaultValue == null && Integer.TYPE.equals(heapValueType) || Long.TYPE.equals(heapValueType)
                || Double.TYPE.equals(heapValueType)) {
            _DefaultValue = getValueType().getDefaultValue();
        }

        // isolate()
        {
            final MinimumValue minimumValue = getAnnotation(MinimumValue.class);
            if (minimumValue != null) {
                final String minimumValueString = minimumValue.value();

                try {
                    _MinimumValue = syntaxLoader.parseSyntacticText(minimumValueString, heapValueType);
                } catch (final Exception e) {

                    throw new PrototypeException(prototype + " slot named \"" + slotName
                            + "\" minimum value annotation's value could not be converted from text value \""
                            + minimumValueString + "\" to a Java " + heapValueType + ". Detail message: "
                            + e.getMessage(), e, prototype, slotName);
                }

                _IsExclusiveMinimum = minimumValue.exclusive();

            }
        }

        // isolate()
        {
            final MaximumValue maximumValue = getAnnotation(MaximumValue.class);
            if (maximumValue != null) {
                final String maximumValueString = maximumValue.value();

                try {
                    _MaximumValue = syntaxLoader.parseSyntacticText(maximumValueString, heapValueType);
                } catch (final Exception e) {

                    throw new PrototypeException(prototype + " slot named \"" + slotName
                            + "\" maximum value annotation's value could not be converted from text value \""
                            + maximumValueString + "\" to a Java " + heapValueType + ". Detail message: "
                            + e.getMessage(), e, prototype, slotName);
                }

                _IsExclusiveMaximum = maximumValue.exclusive();
            }
        }

        // isolate()
        {
            final DivisibleByValue divisibleByValue = getAnnotation(DivisibleByValue.class);
            if (divisibleByValue != null &&
            // The "divisible by" constraint does not apply to doubles
                    !Double.TYPE.equals(heapValueType)
                    && !TypeUtils.isAssignable(heapValueType, Double.class)) {
                final String divisibleByValueString = divisibleByValue.value();

                try {
                    _DivisibleByValue = syntaxLoader.parseSyntacticText(divisibleByValueString, heapValueType);
                } catch (final Exception e) {

                    throw new PrototypeException(prototype + " slot named \"" + slotName
                            + "\" divisibleBy value annotation's value could not be converted from text value \""
                            + divisibleByValueString + "\" to a Java " + heapValueType + ". Detail message: "
                            + e.getMessage(), e, prototype, slotName);
                }

                if (_DivisibleByValue.equals(0)) {
                    throw new PrototypeException(prototype + " slot named \"" + slotName
                            + "\" divisibleBy value annotation's value could not be converted from text value \""
                            + divisibleByValueString + "\" to a Java " + heapValueType + ". Detail message: "
                            + "zero value", null, prototype, slotName);

                }

            }
        }

        // isolate()
        {
            final DisallowedValues disallowedValues = getAnnotation(DisallowedValues.class);
            if (disallowedValues != null) {
                final String[] disallowedValuesArray = disallowedValues.value();
                if (disallowedValuesArray != null) {
                    _DisallowedValues = new LinkedHashSet<>(disallowedValuesArray.length);
                    for (final String disallowedValueString : disallowedValuesArray) {

                        final Object disallowedValue = syntaxLoader.parseSyntacticText(disallowedValueString,
                                heapValueType);

                        _DisallowedValues.add(disallowedValue);
                    }
                }
            }
        }

    } else if (String.class.equals(heapValueType)) {

        final MinimumLength minimumLength = getAnnotation(MinimumLength.class);
        if (minimumLength != null) {
            _MinimumLength = minimumLength.value();
        }

        final MaximumLength maximumLength = getAnnotation(MaximumLength.class);
        if (maximumLength != null) {
            _MaximumLength = maximumLength.value();
        }

        final Multiline multiline = getAnnotation(Multiline.class);
        if (multiline != null) {
            _IsMultiline = true;
        }

        final DisallowedValues disallowedValues = getAnnotation(DisallowedValues.class);
        if (disallowedValues != null) {
            final String[] disallowedValuesArray = disallowedValues.value();
            if (disallowedValuesArray != null) {
                _DisallowedValues = new LinkedHashSet<>(disallowedValuesArray.length);
                _DisallowedValues.addAll(Arrays.asList(disallowedValuesArray));
            }
        }

    } else if (TypeUtils.isAssignable(heapValueType, Collection.class)) {

        final MinimumSize minimumSize = getAnnotation(MinimumSize.class);
        if (minimumSize != null) {
            _MinimumSize = minimumSize.value();
        }

        final MaximumSize maximumSize = getAnnotation(MaximumSize.class);
        if (maximumSize != null) {
            _MaximumSize = maximumSize.value();
        }

    }

    final Searchable searchable = getAnnotation(Searchable.class);
    if (searchable != null) {
        _Searchable = true;
    }

}

From source file:com.ocs.dynamo.domain.model.impl.ModelBasedFieldFactory.java

/**
 * Fills an enumeration field with messages from the message bundle
 * /*from  www  .  ja va2s  .  c om*/
 * @param select
 * @param enumClass
 */
@SuppressWarnings("unchecked")
private <E extends Enum<E>> void fillEnumField(AbstractSelect select, Class<E> enumClass) {
    select.removeAllItems();
    for (Object p : select.getContainerPropertyIds()) {
        select.removeContainerProperty(p);
    }
    select.addContainerProperty(CAPTION_PROPERTY_ID, String.class, "");
    select.setItemCaptionPropertyId(CAPTION_PROPERTY_ID);
    for (E e : enumClass.getEnumConstants()) {
        Item newItem = select.addItem(e);

        String msg = messageService.getEnumMessage(enumClass, e);
        if (msg != null) {
            newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(msg);
        } else {
            newItem.getItemProperty(CAPTION_PROPERTY_ID)
                    .setValue(DefaultFieldFactory.createCaptionByPropertyId(e.name()));
        }
    }
}

From source file:com.datatorrent.stram.webapp.OperatorDiscoverer.java

public JSONObject describeClass(Class<?> clazz) throws Exception {
    JSONObject desc = new JSONObject();
    desc.put("name", clazz.getName());
    if (clazz.isEnum()) {
        @SuppressWarnings("unchecked")
        Class<Enum<?>> enumClass = (Class<Enum<?>>) clazz;
        ArrayList<String> enumNames = Lists.newArrayList();
        for (Enum<?> e : enumClass.getEnumConstants()) {
            enumNames.add(e.name());/*from ww  w.ja  va2  s  .com*/
        }
        desc.put("enum", enumNames);
    }
    UI_TYPE ui_type = UI_TYPE.getEnumFor(clazz);
    if (ui_type != null) {
        desc.put("uiType", ui_type.getName());
    }
    desc.put("properties", getClassProperties(clazz, 0));
    return desc;
}