package com.kylietech.oaj.common.util;
import org.springframework.beans.BeanWrapperImpl;
public class OABeanUtil {
public static final String NAME_FIELD = "name";
public static final String ID_FIELD = "id";
public static final String TOTAL_FIELD = "total";
public static final String REF_FIELD = "ref";
public static final String REF2_FIELD = "ref2";
public static final String REF3_FIELD = "ref3";
public static final String REF4_FIELD = "ref4";
public static final String FACILITY_FIELD = "facility";
public static final String LINES_FIELD = "lines";
public static final String PRODUCT_FIELD = "product";
public static final String CATEGORY_FIELD = "category";
public static final String QUANTITY_FIELD = "quantity";
public static final String PRODUCT_CODE_FIELD = "product.ref";
public static final String INACTIVE_FIELD = "inactive";
public static final String CLOSED_FIELD = "closed";
public static final String COMMENTS_FIELD = "comments";
public static final String DESCRIPTION_FIELD = "description";
public static final String TYPE_FIELD = "type";
public static final String STATUS_FIELD = "status";
public static final String DATE_ENTRY_FIELD = "dateEntry";
public static final String DATE_DELIVERY_FIELD = "dateDelivery";
public static final String DATE_REQUIRED_FIELD = "dateRequiredBy";
public static final String VERSION_FIELD = "version";
public static final String TIMESTAMP_FIELD = "timeStamp";
public static final String LAST_UPDATE_FIELD = "lastUpdate";
public static final String LAST_UPDATER_FIELD = "lastUpdater";
public static final String CLASS_FIELD = "clazz";
public static final String POSITION_FIELD = "position";
public static final String PARENT_FIELD = "parent";
public static final String LOGIN_FIELD = "login";
public static final String INVENTORYITEM_FIELD = "inventoryItem";
public static final String PARTYFROM_FIELD = "partyFrom";
public static final String PARTYTO_FIELD = "partyTo";
public static final String TAKENBY_FIELD = "takenBy";
public static final String PLACEDBY_FIELD = "placedBy";
public static final String SHIPPEDFROM_FIELD = "shippedFrom";
public static final String SHIPPEDTO_FIELD = "shippedTo";
public static Class getPropertyType(Object obj, String prop) {
return (new BeanWrapperImpl(obj)).getPropertyType(prop);
}
public static Object getPropertyValue(Object obj, String prop) {
return (new BeanWrapperImpl(obj)).getPropertyValue(prop);
}
public static void setPropertyValue(Object obj, String prop, Object value) {
(new BeanWrapperImpl(obj)).setPropertyValue(prop, value);
}
public static boolean hasProperty(Object obj, String prop) {
return (new BeanWrapperImpl(obj)).isReadableProperty(prop);
}
public static String getName(Object obj) {
return (String) getPropertyValue(obj, NAME_FIELD);
}
public static Integer getId(Object obj) {
return (Integer) getPropertyValue(obj, ID_FIELD);
}
public static Integer getVersion(Object obj) {
return (Integer) getPropertyValue(obj, VERSION_FIELD);
}
public static String makeIndexedPropertyName(String parentProperty, String childProperty, int index) {
return parentProperty + "[" + index + "]." + childProperty;
}
public static String makePropertyName(String parentProperty, String childProperty) {
return parentProperty + "." + childProperty;
}
public static String makeNamePropertyName(String property) {
return makePropertyName(property, NAME_FIELD);
}
public static String makeParentProperty(String property) {
return makePropertyName(PARENT_FIELD, property);
}
public static Object getParent(Object obj) {
return getPropertyValue(obj, PARENT_FIELD);
}
}