List of usage examples for java.lang Object getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
public static boolean isArray(Object object) { return object.getClass().isArray(); }
From source file:Main.java
public static void initIntFields(final Object obj) { try {/*www . ja va 2s. c o m*/ Field[] fields = obj.getClass().getDeclaredFields(); for (int idx = 0; idx < fields.length; idx++) { if (fields[idx].getType() == int.class) { fields[idx].setAccessible(true); fields[idx].setInt(obj, 0); } } } catch (final IllegalAccessException ex) { throw new RuntimeException(ex); } }
From source file:ArrayEnumerationFactory.java
static public Enumeration makeEnumeration(final Object obj) { Class type = obj.getClass(); if (!type.isArray()) { throw new IllegalArgumentException(obj.getClass().toString()); } else {/*from w ww.ja v a 2 s. co m*/ return (new Enumeration() { int size = Array.getLength(obj); int cursor; public boolean hasMoreElements() { return (cursor < size); } public Object nextElement() { return Array.get(obj, cursor++); } }); } }
From source file:Main.java
@SuppressWarnings("rawtypes") public static String getObjShortClassName(Object object) { Class clazz = object.getClass(); return clazz.getName().substring(clazz.getName().lastIndexOf(".") + 1); }
From source file:Main.java
public static boolean isToString(Object valueObj) { if (valueObj.getClass().getPackage().getName().startsWith("java.")) return true; else//from www. j a v a 2 s . c o m return false; }
From source file:Main.java
public static String getName(Object obj) { String name = obj.getClass().getName(); int dotPos = name.lastIndexOf("."); if (dotPos != -1 && dotPos < name.length() - 1) { return name.substring(dotPos + 1); } else {//from w w w. ja v a2 s . c om return name; } }
From source file:Main.java
public static Object addInUpperCase(Object c, String s) { if (c.getClass().isAssignableFrom(List.class)) { ((List) c).add(s.toUpperCase()); } else if (c.getClass().isAssignableFrom(ArrayList.class)) { ((ArrayList) c).add(s.toUpperCase()); }//w ww. j a v a 2 s . c o m return c; }
From source file:Main.java
public static String getClassBasename(Object object) { return getBasename(object.getClass()); }
From source file:Main.java
public static String getFullClassName(Object o) { return getFullClassName(o.getClass()); }
From source file:Main.java
public static void log(Object obj, String msg) { log(obj.getClass().getSimpleName(), msg); }