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

devutility.internal.lang.models.EntityField Maven / Gradle / Ivy

There is a newer version: 1.3.8.1
Show newest version
package devutility.internal.lang.models;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;

import devutility.internal.lang.reflect.FieldUtils;
import devutility.internal.lang.reflect.MethodUtils;

/**
 * 
 * EntityField
 * 
 * @author: Aldwin Su
 * @version: 2019-06-05 15:24:00
 */
public class EntityField {
	private Field field;
	private Method setter;
	private Method getter;
	private int order;

	public Field getField() {
		return field;
	}

	public void setField(Field field) {
		this.field = field;
	}

	public Method getSetter() {
		return setter;
	}

	public void setSetter(Method setter) {
		this.setter = setter;
	}

	public Method getGetter() {
		return getter;
	}

	public void setGetter(Method getter) {
		this.getter = getter;
	}

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public Object getValue(Object model) throws ReflectiveOperationException {
		return getter.invoke(model);
	}

	public boolean containAnnotations(List annotations) {
		if (FieldUtils.contain(field, annotations)) {
			return true;
		}

		if (MethodUtils.contain(setter, annotations)) {
			return true;
		}

		if (MethodUtils.contain(getter, annotations)) {
			return true;
		}

		return false;
	}

	public Class fieldType() {
		return getField() != null ? getField().getType() : null;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy