/** * Add a {@link MetaProperty} to a {@link MetaBean}. * @param parentMetaBean * @param access * @return the created {@link MetaProperty} */ public static MetaProperty addMetaProperty(MetaBean parentMetaBean, AccessStrategy access) { final MetaProperty result = new MetaProperty(); final String name = access.getPropertyName(); result.setName(name); result.setType(access.getJavaType()); parentMetaBean.putProperty(name, result); return result; }
/** * Create a {@link MetaProperty} from the specified {@link PropertyDescriptor}. * * @param pd * @param existing * @return MetaProperty */ protected MetaProperty buildMetaProperty(PropertyDescriptor pd, MetaProperty existing) { MetaProperty meta = new MetaProperty(); meta.setName(pd.getName()); meta.setType(determineGenericPropertyType(pd)); if (pd.isHidden()) { meta.putFeature(HIDDEN, Boolean.TRUE); } if (pd.isPreferred()) { meta.putFeature(PREFERRED, Boolean.TRUE); } if (pd.isConstrained()) { meta.putFeature(READONLY, Boolean.TRUE); } Enumeration<String> enumeration = pd.attributeNames(); while (enumeration.hasMoreElements()) { String key = enumeration.nextElement(); Object value = pd.getValue(key); meta.putFeature(key, value); } return meta; }
public void mergeInto(MetaProperty prop) throws ClassNotFoundException { mergeFeaturesInto(prop); if (getType() != null && getType().length() > 0) { prop.setType(Reflection.toClass(getType())); // enhancement: or use getGenericType() ? } if (getHidden() != null) { prop.putFeature(HIDDEN, getHidden().booleanValue()); } if (getMandatory() != null) { prop.putFeature(MANDATORY, getMandatory().equals("true")); } if (getMaxLength() != null) { prop.putFeature(MAX_LENGTH, getMaxLength()); } if (getMinLength() != null) { prop.putFeature(MIN_LENGTH, getMinLength()); } if (getReadonly() != null) { prop.putFeature(READONLY, getReadonly()); } if (getDenied() != null) { prop.putFeature(DENIED, getDenied()); } } }