Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.javafx.binding;
import javafx.beans.WeakListener;
import javafx.collections.*;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
*/
public class ContentBinding {
private static void checkParameters(Object property1, Object property2) {
if ((property1 == null) || (property2 == null)) {
throw new NullPointerException("Both parameters must be specified.");
}
if (property1 == property2) {
throw new IllegalArgumentException("Cannot bind object to itself");
}
}
public static Object bind(List list1, ObservableList extends E> list2) {
checkParameters(list1, list2);
final ListContentBinding contentBinding = new ListContentBinding<>(list1);
if (list1 instanceof ObservableList observableList) {
observableList.setAll(list2);
} else {
list1.clear();
list1.addAll(list2);
}
list2.removeListener(contentBinding);
list2.addListener(contentBinding);
return contentBinding;
}
public static Object bind(Set set1, ObservableSet extends E> set2) {
checkParameters(set1, set2);
final SetContentBinding contentBinding = new SetContentBinding<>(set1);
set1.clear();
set1.addAll(set2);
set2.removeListener(contentBinding);
set2.addListener(contentBinding);
return contentBinding;
}
public static Object bind(Map map1, ObservableMap extends K, ? extends V> map2) {
checkParameters(map1, map2);
final MapContentBinding contentBinding = new MapContentBinding<>(map1);
map1.clear();
map1.putAll(map2);
map2.removeListener(contentBinding);
map2.addListener(contentBinding);
return contentBinding;
}
public static void unbind(Object obj1, Object obj2) {
checkParameters(obj1, obj2);
if ((obj1 instanceof List> list1) && (obj2 instanceof ObservableList> list2)) {
@SuppressWarnings("unchecked")
ListContentBinding