Example usage for java.lang Class getName

List of usage examples for java.lang Class getName

Introduction

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

Prototype

public String getName() 

Source Link

Document

Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String .

Usage

From source file:com.github.pjungermann.config.validation.ConfigValidatorTest.java

static void registerSingleton(Class... classes) {
    for (Class clazz : classes) {
        applicationContext.registerBeanDefinition(clazz.getName(),
                BeanDefinitionBuilder.rootBeanDefinition(clazz)
                        .setAutowireMode(AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE).getBeanDefinition());
    }/*from  w ww.ja  va  2 s . co m*/
}

From source file:com.comstar.mars.env.EnvMapperFactoryBean.java

private static Object getRealMapper(String env, Class mapperClazz) {
    Map<String, Object> mappers = envMappers.get(env);
    if (mappers.isEmpty()) {
        return null;
    }//from  w  w  w.j  a  v  a2s. c  o m

    return mappers.get(mapperClazz.getName());
}

From source file:com._4dconcept.springframework.data.marklogic.repository.config.MarklogicRepositoryConfigurationExtensionTest.java

private static void assertDoesNotHaveRepo(Class<?> repositoryInterface,
        Collection<RepositoryConfiguration<RepositoryConfigurationSource>> configs) {

    for (RepositoryConfiguration<?> config : configs) {
        if (config.getRepositoryInterface().equals(repositoryInterface.getName())) {
            fail("Expected not to find config for repository interface ".concat(repositoryInterface.getName()));
        }//from   w w  w.ja v  a2 s.com
    }
}

From source file:uk.co.techblue.alfresco.client.Service.java

private static void registerResteasyProvider(final ResteasyProviderFactory providerFactory,
        final Class<?> providerClass) {
    logger.info("Registering custom Provider with Resteasy:" + providerClass.getName() + " ...");
    providerFactory.registerProvider(providerClass);
    logger.info("Registered custom Provider with Resteasy:" + providerClass.getName());
}

From source file:Main.java

/**
 * Extracts the package name from the given class object
 *//*from ww  w  .j  a  v  a2s.  c om*/
public static String getPackage(Class<?> cls) {
    // cls.getPackage() sometimes returns null, in which case fall back to string massaging.
    java.lang.Package pkg = cls.isArray() ? cls.getComponentType().getPackage() : cls.getPackage();
    if (pkg == null) {
        int dotPos;
        int dolPos = cls.getName().indexOf('$');
        if (dolPos > 0) {
            // we have nested classes, so adjust dotpos to before first $
            dotPos = cls.getName().substring(0, dolPos).lastIndexOf('.');
        } else {
            dotPos = cls.getName().lastIndexOf('.');
        }

        if (dotPos > 0) {
            return cls.getName().substring(0, dotPos);
        } else {
            // must be default package.
            return "";
        }
    } else {
        return pkg.getName();
    }
}

From source file:org.web4thejob.util.L10nUtil.java

public static String getMessage(Class<?> clazz, String code, Object[] args, String defaultValue) {
    if (getMessageSource() != null) {
        try {/* w w w.j a v a  2s  .  c o  m*/
            return getMessageSource().getMessage(clazz.getName() + "." + code, args, CoreUtil.getUserLocale());
        } catch (NoSuchMessageException e) {
            if (!CoreUtil.getUserLocale().equals(Locale.ENGLISH)) {
                logMissingMessage(clazz.getName() + "." + code, defaultValue);
            }
        }
    }

    if (args != null) {
        return MessageFormat.format(defaultValue, args);
    } else {
        return defaultValue;
    }

}

From source file:com.dcits.govsbu.southernbase.baseproject2.modules.utils.Reflections.java

/**
 * ?CGLib??./*  w w  w .  j  av  a 2s  .c  om*/
 */
public static Class<?> getUserClass(Object instance) {
    Validate.notNull(instance, "Instance must not be null");
    Class clazz = instance.getClass();
    if ((clazz != null) && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
        Class<?> superClass = clazz.getSuperclass();
        if ((superClass != null) && !Object.class.equals(superClass)) {
            return superClass;
        }
    }
    return clazz;

}

From source file:com._4dconcept.springframework.data.marklogic.repository.config.MarklogicRepositoryConfigurationExtensionTest.java

private static void assertHasRepo(Class<?> repositoryInterface,
        Collection<RepositoryConfiguration<RepositoryConfigurationSource>> configs) {

    for (RepositoryConfiguration<?> config : configs) {
        if (config.getRepositoryInterface().equals(repositoryInterface.getName())) {
            return;
        }/*from  w  w  w.  j a  va 2s . c  o m*/
    }

    fail("Expected to find config for repository interface ".concat(repositoryInterface.getName())
            .concat(" but got ").concat(configs.toString()));
}

From source file:io.servicecomb.foundation.vertx.VertxUtils.java

public static <T extends AbstractVerticle> void deployVerticle(Vertx vertx, Class<T> cls, int instanceCount) {
    DeploymentOptions options = new DeploymentOptions().setInstances(instanceCount);

    vertx.deployVerticle(cls.getName(), options);
}

From source file:ml.shifu.shifu.util.ClassUtils.java

public static Field getDeclaredFieldIncludeSuper(String fieldName, Class<?> clazz) {
    String key = clazz.getName() + "#" + fieldName;
    Field cacheField = FIELD_CACHE.get(key);
    if (cacheField != null) {
        return cacheField;
    }//  www  .  j a  va2 s.c om
    for (Field field : ClassUtils.getAllFields(clazz)) {
        if (field.getName().equals(fieldName)) {
            return field;
        }
    }
    return null;
}