Example usage for java.lang Class getSimpleName

List of usage examples for java.lang Class getSimpleName

Introduction

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

Prototype

public String getSimpleName() 

Source Link

Document

Returns the simple name of the underlying class as given in the source code.

Usage

From source file:com.hpcloud.util.Serialization.java

private static String rootNameFor(Class<?> type) {
    JsonRootName rootName = type.getAnnotation(JsonRootName.class);
    return rootName == null ? type.getSimpleName() : rootName.value();
}

From source file:com.wavemaker.commons.util.TypeConversionUtils.java

public static Class<?> primitiveWrapperClassByName(String className) {
    for (Class klass : PRIMITIVE_WRAPPERS) {
        if (klass.getSimpleName().equals(className)) {
            return klass;
        }//from w  w  w  .j  a v  a 2s  .co m
    }
    return null;
}

From source file:com.omertron.themoviedbapi.methods.AbstractMethod.java

/**
 * Helper function to get a pre-generated TypeReference for a class
 *
 * @param aClass//from  ww w. java2s.c o m
 * @return
 * @throws MovieDbException
 */
protected static TypeReference getTypeReference(Class aClass) throws MovieDbException {
    if (TYPE_REFS.containsKey(aClass)) {
        return TYPE_REFS.get(aClass);
    } else {
        throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE,
                "Class type reference for '" + aClass.getSimpleName() + "' not found!");
    }
}

From source file:com.nabla.wapp.server.database.StatementFormat.java

public static IStatementSetter getSetter(final Class parameterClass) {
    Class c = parameterClass;/*from   w  w  w  . ja  v a2s.co m*/
    while (c != null) {
        final IStatementSetter writer = cache.get(c);
        if (writer != null)
            return writer;
        c = c.getSuperclass();
    }
    if (log.isDebugEnabled())
        log.debug("found no SQL statement setter for type '" + parameterClass.getSimpleName() + "'");
    return defaultSetter;
}

From source file:com.puppycrawl.tools.checkstyle.AllChecksTest.java

/**
 * Checks whether a class may be considered as the checkstyle module.
 * Checkstyle's modules are nonabstract classes which names end with 'Check',
 * do not contain the word 'Input' (are not input files for UTs),
 * checkstyle's filters and SuppressWarningsHolder class.
 * @param loadedClass class to check.//from  w  w w  .  ja v  a  2 s .  co m
 * @return true if the class may be considered as the checkstyle module.
 */
private static boolean isCheckstyleModule(Class<?> loadedClass) {
    final String className = loadedClass.getSimpleName();
    return isCheckstyleNonAbstractCheck(loadedClass, className) || isFilterModule(loadedClass, className)
            || "SuppressWarningsHolder".equals(className);
}

From source file:com.puppycrawl.tools.checkstyle.AllChecksTest.java

/**
 * Removes 'Check' suffix from each class name in the set.
 * @param checks class instances.//from   www.  ja  va  2s.c o  m
 * @return a set of simple names.
 */
private static Set<String> getSimpleNames(Set<Class<?>> checks) {
    final Set<String> checksNames = new HashSet<>();
    for (Class<?> check : checks) {
        checksNames.add(check.getSimpleName().replace("Check", ""));
    }
    return checksNames;
}

From source file:ips1ap101.lib.core.util.VelocityAid.java

private static void putClass(VelocityContext context, Class<?> clazz) {
    context.put(clazz.getSimpleName(), clazz);
}

From source file:com.joliciel.talismane.utils.PerformanceMonitor.java

/**
 * Get a monitor for the class provided.
 * @param clazz/*from   w w w.jav  a2s.  co m*/
 * @return
 */
public static PerformanceMonitor getMonitor(@SuppressWarnings("rawtypes") Class clazz) {
    return getMonitor(clazz.getCanonicalName(), clazz.getSimpleName());
}

From source file:com.dosport.system.utils.ReflectionUtils.java

/**
 * ??, Class?. , Object.class./* w  w  w. j a  va2 s. co m*/
 * 
 * public UserDao extends HibernateDao<User,Long>
 * 
 * @param clazz
 *            clazz The class to introspect
 * @param index
 *            the Index of the generic ddeclaration,start from 0.
 * @return the index generic declaration, or Object.class if cannot be
 *         determined
 */
@SuppressWarnings("rawtypes")
public static Class getSuperClassGenricType(final Class clazz, final int index) {

    Type genType = clazz.getGenericSuperclass();

    if (!(genType instanceof ParameterizedType)) {
        logger.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType");
        return Object.class;
    }

    Type[] params = ((ParameterizedType) genType).getActualTypeArguments();

    if (index >= params.length || index < 0) {
        logger.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
                + params.length);
        return Object.class;
    }
    if (!(params[index] instanceof Class)) {
        logger.warn(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
        return Object.class;
    }

    return (Class) params[index];
}

From source file:co.runrightfast.core.utils.JmxUtils.java

static ObjectName applicationMBeanObjectName(final String domain, @NonNull final Class<?> mbeanType,
        final String name) {
    checkArgument(isNotBlank(domain));//  ww  w  .  jav a2 s.  c  o  m
    checkArgument(isNotBlank(name));
    try {
        @SuppressWarnings("UseOfObsoleteCollectionType")
        final Hashtable<String, String> attributes = new Hashtable<>();
        attributes.put("type", mbeanType.getSimpleName());
        attributes.put("name", name);
        return ObjectName.getInstance(domain, attributes);
    } catch (final MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
}