List of usage examples for java.lang Class getName
public String getName()
From source file:Main.java
public static boolean classEquals(final Class<?> cls1, final Class<?> cls2) { if (cls1 == null || cls2 == null) return cls1 == cls2; return cls1.getName().equals(cls2.getName()); }
From source file:org.spring.data.gemfire.AbstractGemFireTest.java
protected static String toPathname(Class<?> type) { return type.getName().replaceAll("\\.", File.separator); }
From source file:com.basistech.rosette.examples.ExampleBase.java
/** * Prints out how to run the program//from www . j a v a 2s .co m * @param commandClass the class to use in the usage message. */ protected static void showUsage(Class<? extends ExampleBase> commandClass) { System.err.println(USAGE_STR + commandClass.getName()); }
From source file:Main.java
public static void dumpMethod(final Method method) { final StringBuilder builder = new StringBuilder(); builder.append("------------------------------\n"); builder.append("MethodName: ").append(method.getName()).append("\n"); builder.append("ParameterTypes:{"); for (Class<?> cls : method.getParameterTypes()) { builder.append(cls.getName()).append(", "); }/*from w w w . j a v a2 s . co m*/ builder.append("}\n"); builder.append("GenericParameterTypes:{"); for (Type cls : method.getGenericParameterTypes()) { builder.append(cls.getClass()).append(", "); } builder.append("}\n"); builder.append("TypeParameters:{"); for (TypeVariable<Method> cls : method.getTypeParameters()) { builder.append(cls.getName()).append(", "); } builder.append("}\n"); builder.append("DeclaredAnnotations:{"); for (Annotation cls : method.getDeclaredAnnotations()) { builder.append(cls).append(", "); } builder.append("}\n"); builder.append("Annotations:{"); for (Annotation cls : method.getAnnotations()) { builder.append(cls).append(", "); } builder.append("}\n"); builder.append("ExceptionTypes:{"); for (Class<?> cls : method.getExceptionTypes()) { builder.append(cls.getName()).append(", "); ; } builder.append("}\n"); builder.append("ReturnType: ").append(method.getReturnType()); builder.append("\nGenericReturnType: ").append(method.getGenericReturnType()); builder.append("\nDeclaringClass: ").append(method.getDeclaringClass()); builder.append("\n"); System.out.println(builder.toString()); }
From source file:io.dyn.el.SpelExpression.java
public static Expression T(Class<?> clazz) { return $("T(" + clazz.getName() + ")"); }
From source file:com.glaf.jbpm.factory.JbpmActionHandlerTypes.java
public static void addHandler(Class<?> clazz) { String name = clazz.getName(); actionHandles.put(name, clazz); }
From source file:cz.cuni.mff.d3s.spl.example.newton.app.Main.java
private static void inspectClass(Object obj) { if (!INSPECT) { return;/*from w w w .j ava2 s. c o m*/ } System.out.printf("Inspecting %s:\n", obj); Class<?> klass = obj.getClass(); System.out.printf(" Class: %s\n", klass.getName()); for (Field f : klass.getDeclaredFields()) { Object value; boolean accessible = f.isAccessible(); try { f.setAccessible(true); value = f.get(obj); } catch (IllegalArgumentException | IllegalAccessException e) { value = String.format("<failed to read: %s>", e.getMessage()); } f.setAccessible(accessible); System.out.printf(" Field %s: %s\n", f.getName(), value); } for (Method m : klass.getDeclaredMethods()) { System.out.printf(" Method %s\n", m.getName()); } System.out.printf("-------\n"); System.out.flush(); }
From source file:GenericReflectionTest.java
public static void printType(Type type, boolean isDefinition) { if (type instanceof Class) { Class<?> t = (Class<?>) type; System.out.print(t.getName()); } else if (type instanceof TypeVariable) { TypeVariable<?> t = (TypeVariable<?>) type; System.out.print(t.getName()); if (isDefinition) printTypes(t.getBounds(), " extends ", " & ", "", false); } else if (type instanceof WildcardType) { WildcardType t = (WildcardType) type; System.out.print("?"); printTypes(t.getUpperBounds(), " extends ", " & ", "", false); printTypes(t.getLowerBounds(), " super ", " & ", "", false); } else if (type instanceof ParameterizedType) { ParameterizedType t = (ParameterizedType) type; Type owner = t.getOwnerType(); if (owner != null) { printType(owner, false);//from ww w . j a v a2s. c o m System.out.print("."); } printType(t.getRawType(), false); printTypes(t.getActualTypeArguments(), "<", ", ", ">", false); } else if (type instanceof GenericArrayType) { GenericArrayType t = (GenericArrayType) type; System.out.print(""); printType(t.getGenericComponentType(), isDefinition); System.out.print("[]"); } }
From source file:Main.java
/** * Helper method used to construct appropriate description * when passed either type (Class) or an instance; in latter * case, class of instance is to be used. *//*ww w. ja v a 2 s . c o m*/ public static String getClassDescription(Object classOrInstance) { if (classOrInstance == null) { return "unknown"; } Class<?> cls = (classOrInstance instanceof Class<?>) ? (Class<?>) classOrInstance : classOrInstance.getClass(); return cls.getName(); }
From source file:Main.java
public static int[] getAppWidgetIds(final Context context, final AppWidgetManager appWidgetManager, final Class<? extends AppWidgetProvider> widgetProviderClass) { ComponentName thisAppWidget = new ComponentName(context.getPackageName(), widgetProviderClass.getName()); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget); return appWidgetIds; }