List of usage examples for java.lang Object getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
public static Boolean isListOrArray(Object object) { return object instanceof List || object.getClass().isArray(); }
From source file:Main.java
public static void getAnnotations(Object object) { Annotation[] annotations = object.getClass().getAnnotations(); for (Annotation annotation : annotations) { // annotation. }/*from ww w. j a v a 2 s . co m*/ }
From source file:Main.java
public static void printObject(Object object) { Class<?> class1 = object.getClass(); Field[] fields = class1.getDeclaredFields(); for (Field field : fields) { try {//from ww w . j a v a 2 s . co m field.setAccessible(true); } catch (IllegalArgumentException e) { e.printStackTrace(); } } }
From source file:Main.java
public static void reflect(Object o) throws Exception { Class cls = o.getClass(); Field[] fields = cls.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { Field f = fields[i];/*from w ww . ja v a2s . c o m*/ f.setAccessible(true); } }
From source file:Main.java
public static String getClassNameInStr(Object obj) { Class<?> enclosingClass = obj.getClass().getEnclosingClass(); if (enclosingClass != null) { return enclosingClass.getName(); } else {// w w w.j av a 2s .c o m return obj.getClass().getName(); } }
From source file:Main.java
private static String getClassName(Object obj) { String fullPathClassName = obj.getClass().getName(); String className = fullPathClassName.substring(fullPathClassName.lastIndexOf(".") + 1, fullPathClassName.length()); return className; }
From source file:Main.java
public static ImageIcon createIcon(Object context, String file) { return new ImageIcon(context.getClass().getResource(file)); }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T setEmptyIfNullObject(final Object value) { return (T) (value == null ? "" : value.getClass().cast(value)); }
From source file:Main.java
public static void log(Object o, String msg) { String tag = o != null ? o.getClass().getSimpleName() : ""; log(tag, msg);/*from ww w . j ava 2s .co m*/ }
From source file:Main.java
public static int getDim(Object array) { int dim = 0;/*w w w.j a v a 2 s . c om*/ Class c = array.getClass(); while (c.isArray()) { c = c.getComponentType(); dim++; } return (dim); }