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

it.amattioli.common.properties.PropertyDescriptor Maven / Gradle / Ivy

The newest version!
package it.amattioli.common.properties;

import static org.apache.commons.lang.StringUtils.capitalize;

import java.lang.reflect.Method;

public class PropertyDescriptor {
	private Method getter;
	private Method setter;
	
	public PropertyDescriptor(Class beanClass, String propertyName) {
		try {
			getter = beanClass.getMethod("get"+capitalize(propertyName));
			setter = beanClass.getMethod("set"+capitalize(propertyName), getter.getReturnType());
		} catch (SecurityException e) {
			throw new RuntimeException(e);
		} catch (NoSuchMethodException e) {
			throw new UnknownPropertyException();
		}
	}
	
	public Class getType() {
		//return String.class;
		return getter.getReturnType();
	}

	public Method getGetter() {
		return getter;
	}

	public Method getSetter() {
		return setter;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy