List of usage examples for java.lang Class getName
public String getName()
From source file:com.qrmedia.commons.test.annotation.processing.AbstractAnnotationProcessorTest.java
private static String toResourcePath(Class<?> clazz) { return ClassUtils.convertClassNameToResourcePath(clazz.getName()) + SOURCE_FILE_SUFFIX; }
From source file:cop.raml.mocks.MockUtils.java
private static TypeElementMock createEnumElement(@NotNull Class<?> cls) { TypeElementMock element = new TypeElementMock(cls.getName(), ElementKind.ENUM); element.setType(new TypeMirrorMock(element, TypeKind.DECLARED)); element.addEnclosedElement(new TypeElementMock("values()", ElementKind.METHOD)); for (Object obj : cls.getEnumConstants()) element.addEnclosedElement(new VariableElementMock(obj.toString(), ElementKind.ENUM_CONSTANT)); return setAnnotations(element, cls); }
From source file:GetColor.java
public static void setObjectColor(Object obj, Color color) { Class cls = obj.getClass(); //#1 try {/* w w w . j a va 2 s.c o m*/ Method method = cls.getMethod("setColor", //#2 new Class[] { Color.class }); method.invoke(obj, new Object[] { color }); //#3 } catch (NoSuchMethodException ex) { //#4 throw new IllegalArgumentException(cls.getName() + " does not support" + "method setColor(:Color)"); } catch (IllegalAccessException ex) { //#5 throw new IllegalArgumentException( "Insufficient access permissions to call" + "setColor(:Color) in class " + cls.getName()); } catch (InvocationTargetException ex) { //#6 throw new RuntimeException(ex); } }
From source file:com.payu.ratel.client.RemoteAutowireCandidateResolver.java
private static Optional<Annotation> getAnnotationWithType(DependencyDescriptor descriptor, final Class clazz) { return Iterables.tryFind(Arrays.asList(descriptor.getAnnotations()), new Predicate<Annotation>() { @Override//w w w . jav a 2 s. c o m public boolean apply(Annotation input) { return clazz.getName().equals(input.annotationType().getName()); } }); }
From source file:be.fedict.eid.applet.service.impl.tlv.TlvParser.java
/** * Parses the given file using the meta-data annotations within the tlvClass * parameter./*from ww w . j a va2 s . com*/ * * @param <T> * @param file * @param tlvClass * @return */ public static <T> T parse(byte[] file, Class<T> tlvClass) { T t; try { t = parseThrowing(file, tlvClass); } catch (Exception e) { throw new RuntimeException("error parsing file: " + tlvClass.getName(), e); } return t; }
From source file:com.atlassian.jira.rest.client.TestUtil.java
@SuppressWarnings("unused") public static <T extends Throwable> void assertThrows(Class<T> clazz, String regexp, Runnable runnable) { try {//from w w w.ja v a 2 s .co m runnable.run(); Assert.fail(clazz.getName() + " exception expected"); } catch (Throwable e) { Assert.assertTrue( "Expected exception of class " + clazz.getName() + " but was caught " + e.getClass().getName(), clazz.isInstance(e)); if (e.getMessage() == null && regexp != null) { Assert.fail("Exception with no message caught, while expected regexp [" + regexp + "]"); } if (regexp != null && e.getMessage() != null) { Assert.assertTrue("Message [" + e.getMessage() + "] does not match regexp [" + regexp + "]", e.getMessage().matches(regexp)); } } }
From source file:net.librec.util.DriverClassUtil.java
/** * get Driver Name by clazz/*from w w w . ja v a 2s . co m*/ * * @param clazz clazz name * @return driver name * @throws ClassNotFoundException if can't find the Class */ public static String getDriverName(Class<? extends Recommender> clazz) throws ClassNotFoundException { if (clazz == null) { return null; } else { String driverName = driverClassInverseBiMap.get(clazz.getName()); if (StringUtils.isNotBlank(driverName)) { return driverName; } else { return clazz.getSimpleName().toLowerCase().replace("recommender", ""); } } }
From source file:guru.qas.martini.i18n.MessageSources.java
public static MessageSource getMessageSource(Class c) { return INDEX.computeIfAbsent(c, r -> { ResourceBundleMessageSource source = new ResourceBundleMessageSource(); source.setFallbackToSystemLocale(true); source.setBundleClassLoader(c.getClassLoader()); source.setBasename(c.getName()); source.setUseCodeAsDefaultMessage(true); source.setCacheSeconds(-1);// w ww . j av a 2s . c om return source; }); }
From source file:gemlite.core.util.Util.java
/** * gemlite/core/util/Util//from w w w . ja va 2s . com * * @param cls * @return */ public final static String getInternalName(Class<?> cls) { String name = cls.getName(); StringBuilder builder = new StringBuilder(); builder.append(name.replaceAll("\\.", "\\/")); return builder.toString(); }
From source file:Main.java
public static boolean isServiceRunning(Class<? extends Service> service, Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo runningServiceInfo : manager .getRunningServices(Integer.MAX_VALUE)) { if (service.getName().equals(runningServiceInfo.service.getClassName())) { return true; }/*from ww w .j a v a 2 s .c o m*/ } return false; }