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:org.develspot.data.orientdb.mapping.BasicOrientPersistentEntity.java

public BasicOrientPersistentEntity(TypeInformation<T> information) {
    super(information);

    Class<T> rawType = information.getType();
    //default/*w w  w .  j  a v a 2 s .c  om*/
    this.vertexType = rawType.getSimpleName();
    //check if annotation is present
    if (rawType.isAnnotationPresent(VertexType.class)) {
        VertexType annotation = rawType.getAnnotation(VertexType.class);
        if (!annotation.value().isEmpty()) {
            this.vertexType = annotation.value();
        }
    }
}

From source file:org.kuali.kfs.sys.context.SpringContext.java

/**
 * Use this method to retrieve a spring bean when one of the following is the case. Pass in the type of the service interface,
 * NOT the service implementation. 1. there is only one bean of the specified type in our spring context 2. there is only one
 * bean of the specified type in our spring context, but you want the one whose bean id is the same as type.getSimpleName() with
 * the exception of the first letter being lower case in the former and upper case in the latter, For example, there are two
 * beans of type DateTimeService in our context dateTimeService and testDateTimeService. To retrieve the former, you should
 * specific DateTimeService.class as the type. To retrieve the latter, you should specify ConfigurableDateService.class as the
 * type. Unless you are writing a unit test and need to down cast to an implementation, you do not need to cast the result of
 * this method.//w ww. ja va  2  s . co  m
 *
 * @param <T>
 * @param type
 * @return an object that has been defined as a bean in our spring context and is of the specified type
 */
public static <T> T getBean(Class<T> type) {
    verifyProperInitialization();
    T bean = null;
    if (SINGLETON_BEANS_BY_TYPE_CACHE.containsKey(type)) {
        bean = (T) SINGLETON_BEANS_BY_TYPE_CACHE.get(type);
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Bean not already in cache: " + type + " - calling getBeansOfType() ");
        }
        Collection<T> beansOfType = getBeansOfType(type).values();
        if (!beansOfType.isEmpty()) {
            if (beansOfType.size() > 1) {
                bean = getBean(type, StringUtils.uncapitalize(type.getSimpleName()));
            } else {
                bean = beansOfType.iterator().next();
            }
        } else {
            try {
                bean = getBean(type, StringUtils.uncapitalize(type.getSimpleName()));
            } catch (Exception ex) {
                // do nothing, let fall through
            }
            if (bean == null) { // unable to find bean - check GRL
                // this is needed in case no beans of the given type exist locally
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Bean not found in local context: " + type.getName() + " - calling GRL");
                }
                Object remoteServiceBean = getService(StringUtils.uncapitalize(type.getSimpleName()));
                if (remoteServiceBean != null) {
                    if (type.isAssignableFrom(remoteServiceBean.getClass())) {
                        bean = (T) remoteServiceBean;
                    }
                }
            }
        }
        if (bean != null) {
            synchronized (SINGLETON_TYPES) {
                if (SINGLETON_TYPES.contains(type) || hasSingletonSuperType(type, SINGLETON_TYPES)) {
                    SINGLETON_TYPES.add(type);
                    SINGLETON_BEANS_BY_TYPE_CACHE.put(type, bean);
                }
            }
        } else {
            throw new RuntimeException(
                    "Request for non-existent bean.  Unable to find in local context or on the GRL: "
                            + type.getName());
        }
    }
    return bean;
}

From source file:org.github.aenygmatic.payroll.usecases.postprocessors.EmployeeComponentEnumMapPostProcessor.java

@Override
protected String generateName(Class<?> interfaceType) {
    String s = EmployeeType.class.getSimpleName() + interfaceType.getSimpleName() + "Proxy";
    return Character.toLowerCase(s.charAt(0)) + s.substring(1);
}

From source file:com.tommy.base.dao.DaoImpl.java

@SuppressWarnings("unchecked")
public List<T> findAll(Class<T> clazz) {
    return (List<T>) entityManager.createQuery("FROM " + clazz.getSimpleName()).getResultList();
}

From source file:org.docksidestage.dbflute.svflute.GodHandableControllerInterceptor.java

protected String buildActionDisp(HandlerMethod handlerMethod) {
    final Method method = handlerMethod.getMethod();
    final Class<?> declaringClass = method.getDeclaringClass();
    return declaringClass.getSimpleName() + "." + method.getName() + "()";
}

From source file:org.docksidestage.dbflute.svflute.GodHandableControllerInterceptor.java

protected String buildActionName(HandlerMethod handlerMethod) {
    final Method method = handlerMethod.getMethod();
    final Class<?> declaringClass = method.getDeclaringClass();
    return declaringClass.getSimpleName();
}

From source file:org.fornax.cartridges.sculptor.framework.richclient.util.SpringInitializer.java

@SuppressWarnings("unchecked")
public <T> T getBeanFromSimpleClassName(Class<T> beanClass) {
    String beanName = beanClass.getSimpleName();
    beanName = toFirstLower(beanName);/*from ww  w  . j a  v a2s. c  om*/
    T result = (T) getSpringContext().getBean(beanName);
    return result;
}

From source file:org.jrb.commons.web.controller.AbstractController.java

protected String entityRel(Class<?> classname) {
    return StringUtils.uncapitalize(English.plural(classname.getSimpleName()));
}

From source file:cz.lbenda.coursing.client.ClientServiceLocator.java

public <T> T getBean(Class<T> serviceInterface) {
    return (T) this.ctx.getBean(serviceInterface.getSimpleName());
}

From source file:com.nexmo.client.auth.NexmoUnacceptableAuthException.java

private String generateErrorMessage() {
    SortedSet<String> availableTypes = new TreeSet<>();
    for (AuthMethod auth : this.availableAuths) {
        availableTypes.add(auth.getClass().getSimpleName());
    }//from   ww w . j  a v  a  2  s  .co m

    SortedSet<String> acceptableTypes = new TreeSet<>();
    for (Class klass : this.acceptableAuthClasses) {
        acceptableTypes.add(klass.getSimpleName());
    }

    return String.format(
            "No acceptable authentication type could be found. Acceptable types are: %s. Supplied " + "types "
                    + "were: %s",
            StringUtils.join(acceptableTypes, ", "), StringUtils.join(availableTypes, ", "));
}