java类javafx.collections.WeakSetChangeListener的实例源码

ObservableSetBuffering.java 文件源码 项目:reta 阅读 25 收藏 0 点赞 0 评论 0
/**
 * @param newBeanType
 *            bean type
 * @param newPropertyName
 *            bean property name
 * @param newSubject
 *            property value
 */
public ObservableSetBuffering(final Class<?> newBeanType, final String newPropertyName,
        final ObservableSet<E> newSubject)
{
    super(FXCollections.observableSet(new HashSet<>(newSubject != null ? newSubject.size() : 0)));

    if (newBeanType != null || !(newSubject instanceof ReadOnlyProperty<?>))
    {
        beanType = newBeanType;
    }
    else
    {
        final Object bean = ((ReadOnlyProperty<?>) newSubject).getBean();
        beanType = (bean != null ? bean.getClass() : null);
    }

    if (newPropertyName != null || !(newSubject instanceof ReadOnlyProperty<?>))
    {
        propertyName = newPropertyName;
    }
    else
    {
        propertyName = ((ReadOnlyProperty<?>) newSubject).getName();
    }

    subject = Objects.requireNonNull(newSubject);

    addAll(subject);

    thisListener = c -> {
        if (equalsBuffering)
        {
            buffering.setValue(!equalsSubject());
        }
        else
        {
            buffering.setValue(true);
        }
        validate();
    };

    subjectListener = c -> {
        if (!buffering.getValue())
        {
            revert();
        }
    };

    addListener(thisListener);

    weakSubjectListener = new WeakSetChangeListener<E>(subjectListener);
    subject.addListener(weakSubjectListener);

    validate();
}


问题


面经


文章

微信
公众号

扫码关注公众号