List of usage examples for java.lang Class getSimpleName
public String getSimpleName()
From source file:com.facebook.stetho.inspector.MethodDispatcher.java
private static Map<String, MethodDispatchHelper> buildDispatchTable(ObjectMapper objectMapper, Iterable<ChromeDevtoolsDomain> domainHandlers) { Util.throwIfNull(objectMapper); HashMap<String, MethodDispatchHelper> methods = new HashMap<String, MethodDispatchHelper>(); for (ChromeDevtoolsDomain domainHandler : Util.throwIfNull(domainHandlers)) { Class<?> handlerClass = domainHandler.getClass(); String domainName = handlerClass.getSimpleName(); for (Method method : handlerClass.getDeclaredMethods()) { if (isDevtoolsMethod(method)) { MethodDispatchHelper dispatchHelper = new MethodDispatchHelper(objectMapper, domainHandler, method);// ww w . j a v a 2 s .c om methods.put(domainName + "." + method.getName(), dispatchHelper); } } } return Collections.unmodifiableMap(methods); }
From source file:net.ripe.rpki.commons.crypto.util.Asn1Util.java
/** * Checks if <code>value</code> is an instance of the * <code>expectedClass</code>. * * @throws IllegalArgumentException the instance is null or not an instance of the expected * class. *///from w w w .j av a2 s .c o m public static <T extends ASN1Encodable> T expect(ASN1Encodable value, Class<? extends T> expectedClass) { Validate.notNull(value, expectedClass.getSimpleName() + " expected, got null"); Validate.isTrue(expectedClass.isInstance(value), expectedClass.getSimpleName() + " expected, got " + value.getClass().getSimpleName() + " with value: " + value); return expectedClass.cast(value); }
From source file:app.core.Db.java
public static String dump() { StringBuilder strBuf = new StringBuilder(); for (Class clazz : Db.getEntityClassList()) { strBuf.append('\n').append(clazz.getSimpleName()).append('\n'); strBuf.append(ORMUtils.toResultString( Db.getSession().createQuery("from" + WHITESPACE + clazz.getSimpleName()).list())); }//w ww. ja v a2 s. c om return strBuf.toString(); }
From source file:com.mycomm.dao.mydao.base.MyDaoSupport.java
/** * ???/*from w w w. ja v a 2s .c o m*/ * * @param <E> * @param clazz * @return */ protected static <E> String getEntityName(Class<E> clazz) { String entityname = clazz.getSimpleName(); Entity entity = clazz.getAnnotation(Entity.class); if (entity.name() != null && !"".equals(entity.name())) { entityname = entity.name(); } return entityname; }
From source file:com.nabla.wapp.server.database.SqlInsert.java
@SuppressWarnings("unchecked") protected static IRecordTable getTable(final Class clazz) { Assert.notNull(clazz, "have you forgotten to set @IRecordTable for record " + clazz.getSimpleName()); final IRecordTable t = (IRecordTable) clazz.getAnnotation(IRecordTable.class); return (t != null) ? t : getTable(clazz.getSuperclass()); }
From source file:blue.lapis.pore.impl.event.PoreEventImplTest.java
private static void checkSpongeEvent(Class<?> eventImpl, Class<?> type) { assertTrue(eventImpl.getSimpleName() + ": " + type.getSimpleName() + " is not a sponge event", org.spongepowered.api.event.Event.class.isAssignableFrom(type)); }
From source file:com.weibo.api.motan.config.AbstractConfig.java
private static String getTagName(Class<?> cls) { String tag = cls.getSimpleName(); for (String suffix : SUFFIXS) { if (tag.endsWith(suffix)) { tag = tag.substring(0, tag.length() - suffix.length()); break; }//from www. ja v a 2 s . c om } tag = tag.toLowerCase(); return tag; }
From source file:org.sakuli.loader.BeanLoader.java
/** * load a singleton bean like {@link #loadBean(Class)}, but with an additional qualifier. *///from w ww . j av a 2 s. c o m public static <T> T loadBean(String qualifier, Class<T> classDef) { logger.debug("load Bean '{}' with qualifier '{}' from application context", classDef.getSimpleName(), qualifier); return getBeanFactory().getBean(qualifier, classDef); }
From source file:com.examples.with.different.packagename.ClassPublicInterface.java
public static <L> void addEventListener(final Object eventSource, final Class<L> listenerType, final L listener) { try {/*from ww w .j a va2s.c o m*/ MethodUtils.invokeMethod(eventSource, "add" + listenerType.getSimpleName(), listener); } catch (final NoSuchMethodException e) { throw new IllegalArgumentException("Class " + eventSource.getClass().getName() + " does not have a public add" + listenerType.getSimpleName() + " method which takes a parameter of type " + listenerType.getName() + "."); } catch (final IllegalAccessException e) { throw new IllegalArgumentException("Class " + eventSource.getClass().getName() + " does not have an accessible add" + listenerType.getSimpleName() + " method which takes a parameter of type " + listenerType.getName() + "."); } catch (final InvocationTargetException e) { throw new RuntimeException("Unable to add listener.", e.getCause()); } }
From source file:io.devcon5.pageobjects.tx.TransactionHelper.java
/** * Determines the transaction name for the class. The class must be annoted with {@link Transaction} otherwise an * empty optional is returned. The name of the transaction is either the value of the annotation of the simple name * of the class itself//from ww w.j av a2 s .c om * * @param type * the type for which a transaction name should be determined * * @return the name of the transaction of the empty optional if the class is not transactional */ public static Optional<String> getClassTxName(final Class<?> type) { return Optional.ofNullable(type.getAnnotation(Transaction.class)) .map(t -> isEmpty(t.value()) ? type.getSimpleName() : t.value()); }