Java Class Name Get getClassNameFromConfig(Object config)

Here you can find the source of getClassNameFromConfig(Object config)

Description

Given the standard configuration block in Yaml, extract the class name Block looks like:
 - class: Something param1: value1 OR - Something 

License

Apache License

Parameter

Parameter Description
config the config

Return

the class name from config

Declaration

public static String getClassNameFromConfig(Object config) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Map;

public class Main {
    /**//  ww w . j a  v a 2  s .c  o  m
     * Given the standard configuration block in Yaml, extract the class name
     *
     * Block looks like:
     *
     * <pre>
     * - class: Something
     *   param1: value1
     *
     * OR
     * - Something
     * </pre>
     *
     *
     * @param config
     *            the config
     * @return the class name from config
     */
    public static String getClassNameFromConfig(Object config) {
        if (config instanceof String) {
            return (String) config;
        } else if (config instanceof Map) {
            Map<String, Object> consumer = (Map<String, Object>) config;
            return (String) consumer.get("class");
        } else {
            return null;
        }
    }
}

Related

  1. getClassName(Integer typeValue)
  2. getClassName(String string)
  3. getClassName(String typeName)
  4. getClassName(String upnpDataType)
  5. getClassNameAsSrc(Class clazz)
  6. getClassNames( StackTraceElement[] currentStack)
  7. getClassNames(Class[] ifaces)
  8. getClassNameWithoutPackage(Object object)