BeanPathAdapter.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:Java-9-Programming-Blueprints 作者:
/**
 * Binds a {@link ObservableSet} by traversing the bean's field tree. An
 * additional item path can be specified when the path points to a
 * {@link Collection} that contains beans that also need traversed in order
 * to establish the final value. For example: If a field path points to
 * <code>phoneNumbers</code> (relative to the {@link #getBean()}) where
 * <code>phoneNumbers</code> is a {@link Collection} that contains
 * <code>PhoneNumber</code> instances which in turn have a field called
 * <code>areaCode</code> then an item path can be passed in addition to the
 * field path with <code>areaCode</code> as it's value.
 * 
 * @param fieldPath
 *            the <b><code>.</code></b> separated field paths relative to
 *            the {@link #getBean()} that will be traversed
 * @param itemFieldPath
 *            the <b><code>.</code></b> separated field paths relative to
 *            each item in the bean's underlying {@link Collection} that
 *            will be traversed (empty/null when each item value does not
 *            need traversed)
 * @param itemFieldPathType
 *            the {@link Class} of that the item path points to
 * @param set
 *            the {@link ObservableSet} to bind to the field class type of
 *            the property
 * @param setValueType
 *            the class type of the {@link ObservableSet} value
 * @param selectionModel
 *            the {@link SelectionModel} used to set the values within the
 *            {@link ObservableSet} <b>only applicable when the
 *            {@link ObservableSet} is used for selection(s) and therefore
 *            cannot be updated directly because it is read-only</b>
 * @param selectionModelItemMasterPath
 *            when binding to {@link SelectionModel} items, this will be the
 *            optional path to the collection field that contains all the
 *            items to select from
 */
public <E> void bindContentBidirectional(final String fieldPath,
        final String itemFieldPath, final Class<?> itemFieldPathType,
        final ObservableSet<E> set, final Class<E> setValueType,
        final SelectionModel<E> selectionModel,
        final String selectionModelItemMasterPath) {
    FieldProperty<?, ?, ?> itemMaster = null;
    if (selectionModelItemMasterPath != null
            && !selectionModelItemMasterPath.isEmpty()) {
        itemMaster = getRoot().performOperation(
                selectionModelItemMasterPath, set, setValueType,
                itemFieldPath, itemFieldPathType, null, null,
                FieldBeanOperation.CREATE_OR_FIND);
    }
    getRoot().performOperation(fieldPath, set, setValueType, itemFieldPath,
            itemFieldPathType, selectionModel, itemMaster,
            FieldBeanOperation.BIND);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号