001 /*
002 * SPDX-License-Identifier: Apache-2.0
003 *
004 * Copyright 2008-2017 the original author or authors.
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package griffon.javafx.beans.binding;
019
020 import javafx.beans.InvalidationListener;
021 import javafx.beans.binding.BooleanBinding;
022 import javafx.beans.binding.ObjectExpression;
023 import javafx.beans.binding.StringBinding;
024 import javafx.beans.value.ChangeListener;
025 import javafx.beans.value.ObservableBooleanValue;
026 import javafx.collections.ObservableList;
027
028 import javax.annotation.Nonnull;
029
030 import static java.util.Objects.requireNonNull;
031
032 /**
033 * @author Andres Almiray
034 * @since 2.13.0
035 */
036 public class BooleanBindingDecorator extends BooleanBinding {
037 private final BooleanBinding delegate;
038
039 public BooleanBindingDecorator(@Nonnull BooleanBinding delegate) {
040 this.delegate = requireNonNull(delegate, "Argument 'delegate' must not be null");
041 }
042
043 @Nonnull
044 protected final BooleanBinding getDelegate() {
045 return delegate;
046 }
047
048 @Override
049 protected boolean computeValue() {
050 return delegate.get();
051 }
052
053 @Override
054 public String toString() {
055 return getDelegate().toString();
056 }
057
058 @Override
059 public Boolean getValue() {
060 return getDelegate().getValue();
061 }
062
063 @Override
064 public BooleanBinding and(ObservableBooleanValue other) {
065 return getDelegate().and(other);
066 }
067
068 @Override
069 public BooleanBinding or(ObservableBooleanValue other) {
070 return getDelegate().or(other);
071 }
072
073 @Override
074 public BooleanBinding not() {
075 return getDelegate().not();
076 }
077
078 @Override
079 public BooleanBinding isEqualTo(ObservableBooleanValue other) {
080 return getDelegate().isEqualTo(other);
081 }
082
083 @Override
084 public BooleanBinding isNotEqualTo(ObservableBooleanValue other) {
085 return getDelegate().isNotEqualTo(other);
086 }
087
088 @Override
089 public StringBinding asString() {
090 return getDelegate().asString();
091 }
092
093 @Override
094 public ObjectExpression<Boolean> asObject() {
095 return getDelegate().asObject();
096 }
097
098 @Override
099 public void addListener(InvalidationListener listener) {
100 getDelegate().addListener(listener);
101 }
102
103 @Override
104 public void removeListener(InvalidationListener listener) {
105 getDelegate().removeListener(listener);
106 }
107
108 @Override
109 public void addListener(ChangeListener<? super Boolean> listener) {
110 getDelegate().addListener(listener);
111 }
112
113 @Override
114 public void removeListener(ChangeListener<? super Boolean> listener) {
115 getDelegate().removeListener(listener);
116 }
117
118 @Override
119 public void dispose() {
120 getDelegate().dispose();
121 }
122
123 @Override
124 public ObservableList<?> getDependencies() {
125 return getDelegate().getDependencies();
126 }
127 }
|