本文整理汇总了Java中org.springframework.beans.PropertyAccessor.getPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyAccessor.getPropertyValue方法的具体用法?Java PropertyAccessor.getPropertyValue怎么用?Java PropertyAccessor.getPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.PropertyAccessor
的用法示例。
在下文中一共展示了PropertyAccessor.getPropertyValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deepValue
import org.springframework.beans.PropertyAccessor; //导入方法依赖的package包/类
/**
* This follows a path (like object.childobject.value), to its end value, so it can compare the values of two
* paths.
* This method follows the path recursively until it reaches the end value.
*
* @param object object to search
* @param path path of value
* @return result
*/
private Object deepValue(final Object object, final String path) {
final List<String> paths = new LinkedList<>(Arrays.asList(path.split("\\.")));
final String currentPath = paths.get(0);
final PropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(object);
Object field = accessor.getPropertyValue(currentPath);
paths.remove(0);
if ((field != null) && (!paths.isEmpty())) {
field = deepValue(field, String.join(".", paths));
}
return field;
}
示例2: autobind
import org.springframework.beans.PropertyAccessor; //导入方法依赖的package包/类
public void autobind(Object view) {
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(getModel());
PropertyAccessor viewPropertyAccessor = new DirectFieldAccessor(view);
// iterate on model properties
for (PropertyDescriptor pd : bw.getPropertyDescriptors()) {
String propertyName = pd.getName();
if ( !ignoredProperties.contains(propertyName) && viewPropertyAccessor.isReadableProperty(propertyName)) {
Object control = viewPropertyAccessor.getPropertyValue(propertyName);
if (control != null) {
if (log.isDebugEnabled())
log.debug("Found control: " + control.getClass().getSimpleName() +
" for property: " + propertyName);
bind(control, propertyName);
}
}
}
}
示例3: isFieldEditable
import org.springframework.beans.PropertyAccessor; //导入方法依赖的package包/类
/**
* Is the field editable according to the SchemaView annotation
*
* @param accessor the accessor
* @param key the key
* @return boolean boolean
*/
private Boolean isFieldEditable(final PropertyAccessor accessor, final String key) {
final SchemaView schemaView = accessor.getPropertyTypeDescriptor(key).getAnnotation(SchemaView.class);
if (schemaView != null) {
final boolean isLocked = schemaView.locked() && accessor.getPropertyValue(key) != null;
final boolean isVisible = schemaView.visible();
return !isLocked && isVisible;
}
return false;
}
示例4: populateBackReferencesOne2Many
import org.springframework.beans.PropertyAccessor; //导入方法依赖的package包/类
private void populateBackReferencesOne2Many(EntityTypeToObjectsMap rowsMap, Map<Ref, Set<Object>> refs,
DataSet dataSet) {
for (Entry<String, List<HasId>> entry : rowsMap.entrySet()) {
for (HasId row : entry.getValue()) {
PropertyAccessor propertyAccessor = PropertyAccessorFactory.forBeanPropertyAccess(row);
for (Ref ref : refs.keySet()) {
if (!ref.getToEntity().equals(entry.getKey())) {
continue;
}
Object referencedId = null;
try {
referencedId = propertyAccessor.getPropertyValue(ref.getToField());
} catch (Throwable t) {
throw new RuntimeException("Failed to read property " + ref.getFromField() + " from " + row, t);
}
if (referencedId == null) {
continue;
}
RowIdToBackReferencesMap backRefs = dataSet.get(ref.getFromEntity()).getBackRefs();
if (backRefs.get(referencedId) == null) {
backRefs.put(referencedId, new RefToReferencedObjectsIdsMap());
}
RefToReferencedObjectsIdsMap refToObjsMap = backRefs.get(referencedId);
if (refToObjsMap.get(ref.getName()) == null) {
refToObjsMap.put(ref.getName(), new HashSet<>());
}
refToObjsMap.get(ref.getName()).add(row.getId());
}
}
}
}
示例5: enumerateOutgoingReferences
import org.springframework.beans.PropertyAccessor; //导入方法依赖的package包/类
/**
* @param scanForReferences
* dataSet to scan for Many2one & One2one referenced objects
* @param checkForExistence
* data set that contains already loaded objects so that we can
* skip loading these objects again
* @param references
* references to use
* @return map entityTypeCode to list of ids of these entities to be loaded
*/
private Map<String, Set<Object>> enumerateOutgoingReferences(DataSet scanForReferences, DataSet checkForExistence,
Ref[] references) {
Map<String, Set<Object>> ret = new HashMap<>();
for (DataTable table : scanForReferences.getTables().values()) {
List<Ref> outgoingRefs = enumOutgoingRefsToTableOrNull(references, table.getName());
if (outgoingRefs == null) {
continue;
}
for (Object rowObj : table.getRows().values()) {
HasId row = (HasId) rowObj;
PropertyAccessor propertyAccessor = PropertyAccessorFactory.forBeanPropertyAccess(row);
for (Ref ref : outgoingRefs) {
Object referencedId = null;
try {
referencedId = propertyAccessor.getPropertyValue(ref.getFromField());
} catch (Throwable t) {
throw new RuntimeException("Failed to read property " + ref.getFromField() + " from " + row, t);
}
if (referencedId == null) {
continue;
}
if (checkForExistence.get(ref.getToEntity()).find(referencedId) != null) {
// that one is already loaded, skip
continue;
}
Set<Object> referencedIds = ret.get(ref.getToEntity());
if (referencedIds == null) {
ret.put(ref.getToEntity(), referencedIds = new HashSet<>());
}
referencedIds.add(referencedId);
}
}
}
return ret;
}
示例6: intializeCollection
import org.springframework.beans.PropertyAccessor; //导入方法依赖的package包/类
/**
* Initialize collection
* @param em
* @param entity
* @param a
* @param i
*/
@SuppressWarnings("rawtypes")
private static void intializeCollection(EntityManager em, Object entity, Object attached,
Attribute a, int depth) {
PropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(attached);
Collection c = (Collection) accessor.getPropertyValue(a.getName());
for (Object o : c)
initialize(em, o, depth -1);
PropertyAccessorFactory.forDirectFieldAccess(entity).setPropertyValue(a.getName(), c);
}
示例7: isNew
import org.springframework.beans.PropertyAccessor; //导入方法依赖的package包/类
/**
* Test if entity is New
* @param entity
* @return true if entity is new, ie not detached
*/
@SuppressWarnings("unchecked")
protected boolean isNew(T entity) {
SingularAttribute<?, ?> id = getIdAttribute(entity.getClass());
// try field
PropertyAccessor pa = PropertyAccessorFactory.forDirectFieldAccess(entity);
PK key = (PK) pa.getPropertyValue(id.getName());
if (key == null)
key = (PK) PropertyAccessorFactory.forBeanPropertyAccess(entity).getPropertyValue(id.getName());
return key == null || !exists(key, entity.getClass());
}