List of usage examples for java.lang Class getSimpleName
public String getSimpleName()
From source file:nc.noumea.mairie.organigramme.core.utility.OrganigrammeUtil.java
public static String getSimpleNameOfClass(@SuppressWarnings("rawtypes") Class clazz) { if (clazz == null) { return null; }/*from w w w .ja va 2 s. c o m*/ String result = clazz.getSimpleName(); String marqueur = "_$$"; // quelquefois le simple name contient _$$ // suivi d'une chane gnre, cette mthode // permet de ne pas en tenir compte if (result.contains(marqueur)) { result = result.substring(0, result.indexOf(marqueur)); } return result; }
From source file:org.web4thejob.context.ContextUtil.java
public static <T extends Panel> T getDefaultPanel(Class<T> clazz) { return rootContext.getBean(DEFAULT_PREFFIX + clazz.getSimpleName(), clazz); }
From source file:com.omertron.thetvdbapiv2.methods.AbstractMethod.java
/** * Helper function to get a pre-generated TypeReference for a class * * @param aClass//ww w .java 2s.c o m * @return * @throws com.omertron.thetvdbapiv2.TvDbException * @throws MovieDbException */ protected static TypeReference getTypeReference(Class aClass) throws TvDbException { if (TYPE_REFS.containsKey(aClass)) { return TYPE_REFS.get(aClass); } else { throw new TvDbException(ApiExceptionType.UNKNOWN_CAUSE, "Class type reference for '" + aClass.getSimpleName() + "' not found!"); } }
From source file:api.wiki.WikiGenerator.java
private static String apiClassMethodLinks(Class<?> declaringClass, List<ApiDocumentation> apiDocumentations) { return "## " + declaringClass.getSimpleName() + "\n" + apiDocumentations.stream().map(apiDocumentation -> apiDocumentation.apiMethod) .sorted(comparing(Method::getName)).map(apiMethod -> "* " + hyperLink(apiMethod)) .collect(joining("\n")); }
From source file:cn.geobeans.web.common.utils.ReflectionUtils.java
/** * ??, Class?./*from ww w .j a v a2 s.co m*/ * , Object.class. * * 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("unchecked") 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:cn.taqu.core.modules.utils.ReflectionUtils.java
/** * ??, Class?.//from ww w . ja v a 2s . c om * , Object.class. * * 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 */ 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:io.lavagna.common.QueryFactory.java
private static QueryTypeAndQuery extractQueryAnnotation(Class<?> clazz, String activeDb, Method method) { Query q = method.getAnnotation(Query.class); QueriesOverride qs = method.getAnnotation(QueriesOverride.class); Assert.isTrue(q != null, String.format("missing @Query annotation for method %s in interface %s", method.getName(), clazz.getSimpleName())); // only one @Query annotation, thus we return the value without checking the database if (qs == null) { return new QueryTypeAndQuery(q.type(), q.value()); }//from w ww. j a va2 s . c o m for (QueryOverride query : qs.value()) { if (query.db().equals(activeDb)) { return new QueryTypeAndQuery(q.type(), query.value()); } } return new QueryTypeAndQuery(q.type(), q.value()); }
From source file:com.yize.broadcast.core.util.ReflectionUtils.java
/** * ??, Class?. , Object.class.//from w w w . j a v a2s . 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 */ 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:cc.redpen.validator.ValidatorFactory.java
static void registerValidator(Class<? extends Validator> clazz) { boolean deprecated = clazz.getAnnotation(Deprecated.class) == null ? false : true; if (deprecated) { LOG.warn(clazz.getName() + " is deprecated"); }/*from w w w. j ava2s . co m*/ validators.put(clazz.getSimpleName().replace("Validator", ""), createValidator(clazz)); }
From source file:com.evolveum.midpoint.testing.sanity.ModelClientUtil.java
public static String getTypeUri(Class<? extends ObjectType> type) { // QName typeQName = JAXBUtil.getTypeQName(type); // String typeUri = QNameUtil.qNameToUri(typeQName); String typeUri = NS_COMMON + "#" + type.getSimpleName(); return typeUri; }