public List<Property> getProperties(Class<?> entityClass) { return reflection.findSerializableProperties(entityClass); }
@SuppressWarnings("unchecked") public <T> T newInstance(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException { return newInstance((Class<T>)loadClass(className)); }
public Platform(ClassLoader reflectionClassLoader) { this(new Reflection(reflectionClassLoader)); }
@Override public ClassDescriptor getClassDescriptor(String className) throws ClassNotFoundException { ClassDescriptor desc = classDescriptors.get(className); if (desc == null) { Class<?> cls = context.getReflection().loadClass(className); desc = context.getReflection().getDescriptor(cls); classDescriptors.put(className, desc); } return desc; }
!field.isAnnotationPresent(Exclude.class)) { field.setAccessible(true); serializableProperties.add(reflection.newFieldProperty(field)); continue; serializableProperties.add(reflection.newMethodProperty(method, null, name)); Collections.sort(serializableProperties, reflection.getLexicalPropertyComparator());
protected List<Property> findSerializableDeclaredProperties(Class<?> cls) throws SecurityException { if (!isRegularClass(cls)) throw new IllegalArgumentException("Not a regular class: " + cls); if ((modifiers & STATIC_TRANSIENT_MASK) == 0 && !field.isAnnotationPresent(Exclude.class)) { field.setAccessible(true); serializableProperties.add(newFieldProperty(field)); continue; serializableProperties.add(newMethodProperty(method, null, name));
public boolean canDecode(ExtendedObjectInput in, String className) throws ClassNotFoundException { Class<?> cls = in.getReflection().loadClass(className); return (cls.isAnnotationPresent(Entity.class) || cls.isAnnotationPresent(MappedSuperclass.class)); }
property = newMethodProperty(getter, method, name); break classLoop; property = newMethodProperty(method, setter, name); break classLoop; for (Field field : c.getDeclaredFields()) { if ((field.getModifiers() & Modifier.STATIC) == 0 && field.isAnnotationPresent(annotationClass)) { property = newFieldProperty(field); break classLoop;
protected Property getIdProperty(Class<?> entityClass, boolean throwIfNotFound) { checkEntity(entityClass); Property property = reflection.findProperty(entityClass, Id.class); if (property == null && throwIfNotFound) throw new PropertyNotFoundException("No property annotated with " + Id.class.getName() + " in " + entityClass); return property; }
public <T> Comparator<T> newComparator(ObjectInput in) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException { if (comparatorClassName == null) return null; return ((ExtendedObjectInput)in).getReflection().newInstance(comparatorClassName); }
public Class<?> loadClass(String className) throws ClassNotFoundException { return getClassLoader().loadClass(className); }
property = NULL_PROPERTY; else property = newFieldProperty(field);
public void setPropertyValue(Object entity, String name, Object value) { Property property = reflection.findSerializableProperty(entity.getClass(), name); try { property.setObject(entity, value); } catch (Exception e) { throw new RuntimeException("Could not set " + property + " of object " + entity); } }
public ClassDescriptor getDescriptor(Class<?> cls) { if (cls == null || cls == Object.class || !isRegularClass(cls)) return null; ClassDescriptor descriptor = descriptorCache.get(cls); if (descriptor == null) { descriptor = new ClassDescriptor(this, cls); ClassDescriptor previousDescriptor = descriptorCache.putIfAbsent(cls, descriptor); if (previousDescriptor != null) descriptor = previousDescriptor; } return descriptor; }
!field.isAnnotationPresent(Exclude.class)) { field.setAccessible(true); serializableProperties.add(reflection.newFieldProperty(field)); continue; serializableProperties.add(reflection.newMethodProperty(method, null, name)); Collections.sort(serializableProperties, reflection.getLexicalPropertyComparator());
public boolean canDecode(ExtendedObjectInput in, String className) throws ClassNotFoundException { String alias = in.getAlias(className); Class<?> cls = in.getReflection().loadClass(alias); return cls.isAnnotationPresent(Entity.class); }
property = newMethodProperty(getter, method, name); break classLoop; property = newMethodProperty(method, setter, name); break classLoop; for (Field field : c.getDeclaredFields()) { if ((field.getModifiers() & Modifier.STATIC) == 0 && field.isAnnotationPresent(annotationClass)) { property = newFieldProperty(field); break classLoop;
@Override public ClassDescriptor getClassDescriptor(String className) throws ClassNotFoundException { ClassDescriptor desc = classDescriptors.get(className); if (desc == null) { Class<?> cls = context.getReflection().loadClass(className); desc = context.getReflection().getDescriptor(cls); classDescriptors.put(className, desc); } return desc; }
protected Property getVersionProperty(Class<?> entityClass, boolean throwIfNotFound) { checkEntity(entityClass); Property property = reflection.findProperty(entityClass, Version.class); if (property == null && throwIfNotFound) throw new PropertyNotFoundException("No property annotated with " + Version.class.getName() + " in " + entityClass); return property; }
public <T> Comparator<T> newComparator(ObjectInput in) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException { if (comparatorClassName == null) return null; return ((ExtendedObjectInput)in).getReflection().newInstance(comparatorClassName); }