All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dooapp.gaedo.properties.BeanBackedPropertyProvider Maven / Gradle / Ivy

package com.dooapp.gaedo.properties;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.Collection;
import java.util.LinkedList;


public class BeanBackedPropertyProvider implements PropertyProvider {
	/**
	 * get properties from given class only
	 */
	@Override
	public Property[] get(Class containedClass) {
		try {
			BeanInfo info = Introspector.getBeanInfo(containedClass, containedClass.getSuperclass());
			PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
			Collection returned = new LinkedList();
			for(PropertyDescriptor descriptor : descriptors) {
				returned.add(new DescribedProperty(descriptor, containedClass));
			}
			return returned.toArray(new Property[returned.size()]);
		} catch (IntrospectionException e) {
			throw new NotABeanException(containedClass, e);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy