List of usage examples for java.lang Class getName
public String getName()
From source file:Main.java
/** * <p>Given a {@code List} of {@code Class} objects, this method converts * them into class names.</p>/*from www . j a v a2 s. c o m*/ * * <p>A new {@code List} is returned. {@code null} objects will be copied into * the returned list as {@code null}.</p> * * @param classes the classes to change * @return a {@code List} of class names corresponding to the Class objects, * {@code null} if null input * @throws ClassCastException if {@code classes} contains a non-{@code Class} entry */ public static List<String> convertClassesToClassNames(List<Class<?>> classes) { if (classes == null) { return null; } List<String> classNames = new ArrayList<String>(classes.size()); for (Class<?> cls : classes) { if (cls == null) { classNames.add(null); } else { classNames.add(cls.getName()); } } return classNames; }
From source file:com.mtgi.analytics.aop.BehaviorTrackingAdvice.java
private static final boolean shouldLog(Class<?> type) { return (type.isPrimitive()) || type.isEnum() || type.getName().startsWith("java.lang"); }
From source file:org.key2gym.client.ContextManager.java
/** * Looks up the bean using the current context. * * @deprecated Use Main.getContext.getBean instead * @param <T>/*from ww w .j a v a2 s . co m*/ * the type to lookup * @param clazz * the class of the type to lookup * @return an instance of the bean */ @Deprecated public static <T> T lookup(Class<T> clazz) { return Main.getContext().getBean(clazz.getName(), clazz); }
From source file:com.groupon.jenkins.util.ResourceUtils.java
private static String getTemplateFile(Class<?> resourceClass, String resourceName) { while (resourceClass != Object.class && resourceClass != null) { String name = resourceClass.getName().replace('.', '/').replace('$', '/') + "/" + resourceName; if (resourceClass.getClassLoader().getResource(name) != null) return '/' + name; resourceClass = resourceClass.getSuperclass(); }// ww w . j a v a2 s . c om return null; }
From source file:net.orfjackal.retrolambda.test.Java5BytecodeTest.java
private static String javap(Class<?> aClass) throws IOException { Process process = new ProcessBuilder().directory(TestEnv.testClassesDir) .command("javap", "-v", "-p", aClass.getName()).redirectErrorStream(true).start(); return CharStreams.toString(new InputStreamReader(process.getInputStream())); }
From source file:org.springframework.data.web.config.SpringDataWebConfigurationIntegrationTests.java
/** * Creates a {@link Condition} that checks if an object is an instance of a class with the same name as the provided * class. This is necessary since we are dealing with multiple classloaders which would make a simple instanceof fail * all the time// www .j ava2s.c om * * @param expectedClass the class that is expected (possibly loaded by a different classloader). * @return a {@link Condition} */ private static Condition<Object> instanceWithClassName(Class<?> expectedClass) { return new Condition<>(it -> it.getClass().getName().equals(expectedClass.getName()), // "with class name %s!", expectedClass.getName()); }
From source file:at.ac.tuwien.photohawk.taverna.model.evaluation.MeasurementsDescriptorParser.java
private static void addCreateScale(Digester digester, Class c) { String name = c.getName(); name = name.substring(name.lastIndexOf(".") + 1); name = name.substring(0, 1).toLowerCase() + name.substring(1); String pattern = "*/" + name; digester.addObjectCreate(pattern, c); digester.addSetProperties(pattern);//from w w w . j a v a2 s . co m digester.addBeanPropertySetter(pattern + "/unit"); digester.addSetNext(pattern, "setScale"); }
From source file:Main.java
/** * <p>Given a {@code List} of {@code Class} objects, this method converts * them into class names.</p>// w ww.j a v a2 s .c o m * * <p>A new {@code List} is returned. {@code null} objects will be copied into * the returned list as {@code null}.</p> * * @param classes the classes to change * @return a {@code List} of class names corresponding to the Class objects, * {@code null} if null input * @throws ClassCastException if {@code classes} contains a non-{@code Class} entry */ public static List<String> convertClassesToClassNames(final List<Class<?>> classes) { if (classes == null) { return null; } final List<String> classNames = new ArrayList<String>(classes.size()); for (final Class<?> cls : classes) { if (cls == null) { classNames.add(null); } else { classNames.add(cls.getName()); } } return classNames; }
From source file:de.decidr.model.logging.DefaultLogger.java
/** * Retrieve a logger named according to the full class name of the clazz * parameter. If the named logger already exists, then the existing instance * will be returned. Otherwise, a new instance is created. * //from w w w . j av a2s . co m * @param clazz * class whose full name should be used as the name of the * returned logger * @return a logger that uses the name of the given class */ public static Logger getLogger(Class<?> clazz) { return getLogger(clazz.getName()); }
From source file:Main.java
@SuppressLint("SimpleDateFormat") @SuppressWarnings("unchecked") public static <T> T convert(String string, Class<T> type) { try {//w w w . j a v a 2s . com if (string == null || string.trim().length() == 0) { return null; } if (type.getName().equals("java.util.Date")) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return (T) dateFormat.parse(string); } if (type.getName().equals("java.sql.Date")) { return (T) new java.sql.Date(java.sql.Date.parse(string)); } if (type.getSimpleName().equals("Calendar")) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); calendar.setTime(dateFormat.parse(string)); return (T) calendar; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }