当前位置: 首页>>代码示例>>Java>>正文


Java PropertyAccessor.getPropertyValue方法代码示例

本文整理汇总了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;
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:25,代码来源:EntitySearch.java

示例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);
			}
		}
	}
}
 
开发者ID:chelu,项目名称:jdal,代码行数:18,代码来源:CompositeBinder.java

示例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;
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:20,代码来源:FormParse.java

示例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());
			}
		}
	}
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:36,代码来源:DataSetLoaderImpl.java

示例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;
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:50,代码来源:DataSetLoaderImpl.java

示例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);
}
 
开发者ID:chelu,项目名称:jdal,代码行数:19,代码来源:JpaUtils.java

示例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());
}
 
开发者ID:chelu,项目名称:jdal,代码行数:18,代码来源:JpaDao.java


注:本文中的org.springframework.beans.PropertyAccessor.getPropertyValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。