List of usage examples for java.lang Object getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.ginema.api.reflection.ReflectionUtils.java
public static boolean isACollection(Object c) { return ClassUtils.isAssignable(c.getClass(), Collection.class); }
From source file:com.hurence.logisland.utils.JsonUtil.java
public static String convertToJson(Object value) { if (mapper.canSerialize(value.getClass())) { try {/*from w w w. ja va 2 s.c om*/ return mapper.writeValueAsString(value); } catch (IOException e) { logger.warn("Error while serializing " + value + " to JSON", e); return null; } } else { throw new IllegalArgumentException( "Value of type " + value.getClass().getName() + " can not be serialized to JSON."); } }
From source file:de.cbb.mplayer.mapping.MappingUtil.java
public static void mapToEntity(Object presenter, Object entity) { for (Field field : presenter.getClass().getDeclaredFields()) { mapFieldToEntity(field, presenter, entity); }/*from w ww. ja v a 2s . c om*/ }
From source file:de.cbb.mplayer.mapping.MappingUtil.java
public static void mapToPresenter(Object entity, Object presenter) { for (Field field : entity.getClass().getDeclaredFields()) { mapFieldToPresenter(field, entity, presenter); }/* w w w. j a v a 2 s . c om*/ }
From source file:de.cbb.mplayer.mapping.MappingUtil.java
public static Object getAccessableControl(String fieldname, Object presenter) throws Exception { Field cbField = presenter.getClass().getDeclaredField(fieldname); cbField.setAccessible(true);//from w w w. ja v a 2s.co m Object control = cbField.get(presenter); return control; }
From source file:com.ht.halo.dorado.util.proxy.ProxyBeanUtils.java
public static Class<?> getProxyTargetType(Object bean) { Class<?> cl = bean.getClass(); while (ProxyBeanUtils.isProxy(cl)) { cl = cl.getSuperclass();//w w w . j a va2 s . c om } return cl; }
From source file:Main.java
/** * find all getter and is method and return the value by map. *///from w w w . ja v a 2s. c o m public static Map<String, Object> getProperties(Object bean) { Map<String, Object> map = new HashMap<>(); for (Method method : bean.getClass().getMethods()) { String name = method.getName(); if (((name.length() > 3 && name.startsWith("get")) || (name.length() > 2 && name.startsWith("is"))) && Modifier.isPublic(method.getModifiers()) && method.getParameterTypes().length == 0 && method.getDeclaringClass() != Object.class) { int i = name.startsWith("get") ? 3 : 2; String key = name.substring(i, i + 1).toLowerCase() + name.substring(i + 1); try { map.put(key, method.invoke(bean, new Object[0])); } catch (Exception e) { } } } return map; }
From source file:net.projectmonkey.spring.acl.util.reflect.FieldUtil.java
public static Object getFieldValue(final Object domainObject, final String fieldName) { Field field = ReflectionUtils.findField(domainObject.getClass(), fieldName); field.setAccessible(true);// ww w . j a v a 2 s.com try { return field.get(domainObject); } catch (Exception e) { throw new AuthenticationServiceException("Exception retrieving field " + fieldName, e); } }
From source file:com.ginema.api.reflection.ReflectionUtils.java
public static <T extends Annotation> T getAnnotation(Object c, Class<T> annotationClass) { return c.getClass().getAnnotation(annotationClass); }
From source file:Main.java
private static Object combineArray(Object arrayLhs, Object arrayRhs) { Class<?> localClass = arrayLhs.getClass().getComponentType(); int i = Array.getLength(arrayLhs); int j = i + Array.getLength(arrayRhs); Object result = Array.newInstance(localClass, j); for (int k = 0; k < j; ++k) { if (k < i) { Array.set(result, k, Array.get(arrayLhs, k)); } else {//from ww w . j a v a 2s.c o m Array.set(result, k, Array.get(arrayRhs, k - i)); } } return result; }