List of usage examples for java.lang Object getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
public static int indexOfLast(Object[] array, Class<?> type) { if (!isEmpty(array)) { for (int N = array.length; N > 0; N--) { Object one = array[N - 1]; if (one != null && one.getClass() == type) { return N - 1; }//from w w w .ja v a 2 s. c om } } return -1; }
From source file:Main.java
public static Field fieldGetOrg(Object object, String name) throws Exception { Field field = object.getClass().getDeclaredField(name); field.setAccessible(true);/*from w ww . j av a2 s . c o m*/ return field; }
From source file:com.flipkart.foxtrot.client.util.TypeChecker.java
public static boolean isPrimitive(Object object) { return ClassUtils.isPrimitiveOrWrapper(object.getClass()); }
From source file:Main.java
public static Object getValueFromCollection(Object collection, int index) { if (isArray(collection.getClass())) { return Array.get(collection, index); } else {/* w w w . ja va 2 s. c o m*/ return ((Collection<?>) collection).toArray()[index]; } }
From source file:Main.java
public static void e(Object object, String msg) { if (isDebug) { Log.e(object.getClass().getSimpleName(), msg); }// ww w. j ava2 s . c o m }
From source file:Main.java
public static void copyBeanWithOutNull(Object from, Object to) { Class<?> beanClass = from.getClass(); Field[] fields = beanClass.getFields(); for (int i = 0; i < fields.length; i++) { Field field = fields[i];/* www. j a v a 2 s. c om*/ field.setAccessible(true); try { Object value = field.get(from); if (value != null) { field.set(to, value); } } catch (Exception e) { } } }
From source file:Main.java
public static void copyBeanWithOutNull(Object from, Object to) { Class<?> beanClass = from.getClass(); Field[] fields = beanClass.getFields(); for (int i = 0; i < fields.length; i++) { Field field = fields[i];/*from ww w .j av a 2 s.co m*/ field.setAccessible(true); try { Object value = field.get(from); if (value != null) { field.set(to, value); } } catch (Exception e) { } } }
From source file:Main.java
public static <T> T firstOfType(List<Object> list, Class<T> targetClass) { for (Object object : list) { boolean isTargetClass = object.getClass().equals(targetClass); if (isTargetClass) { return targetClass.cast(object); }//from w ww . j ava 2 s. co m } return null; }
From source file:Main.java
@NonNull private static String getTag(@NonNull Object object) { return RETAIN_FRAGMENT_TAG + object.getClass().getCanonicalName(); }
From source file:Main.java
public static Object arrayExpandAddSingle(Object array, Object elementsToAdd) { Class cl = array.getClass(); if (!cl.isArray()) return null; int length = Array.getLength(array); int newLength = length + 1; Class componentType = array.getClass().getComponentType(); Object newArray = Array.newInstance(componentType, newLength); System.arraycopy(array, 0, newArray, 0, length); Array.set(newArray, length, elementsToAdd); return newArray; }