BooleanPropertyDecorator.java
001 /*
002  * Copyright 2008-2017 the original author or authors.
003  *
004  * Licensed under the Apache License, Version 2.0 (the "License");
005  * you may not use this file except in compliance with the License.
006  * You may obtain a copy of the License at
007  *
008  *     http://www.apache.org/licenses/LICENSE-2.0
009  *
010  * Unless required by applicable law or agreed to in writing, software
011  * distributed under the License is distributed on an "AS IS" BASIS,
012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013  * See the License for the specific language governing permissions and
014  * limitations under the License.
015  */
016 package griffon.javafx.beans.binding;
017 
018 import javafx.beans.InvalidationListener;
019 import javafx.beans.binding.BooleanBinding;
020 import javafx.beans.binding.StringBinding;
021 import javafx.beans.property.BooleanProperty;
022 import javafx.beans.property.ObjectProperty;
023 import javafx.beans.property.Property;
024 import javafx.beans.value.ChangeListener;
025 import javafx.beans.value.ObservableBooleanValue;
026 import javafx.beans.value.ObservableValue;
027 
028 import javax.annotation.Nonnull;
029 
030 import static java.util.Objects.requireNonNull;
031 
032 /**
033  @author Andres Almiray
034  @since 2.11.0
035  */
036 public class BooleanPropertyDecorator extends BooleanProperty {
037     private final BooleanProperty delegate;
038 
039     public BooleanPropertyDecorator(@Nonnull BooleanProperty delegate) {
040         this.delegate = requireNonNull(delegate, "Argument 'delegate' must not be null");
041     }
042 
043     @Nonnull
044     protected final BooleanProperty getDelegate() {
045         return delegate;
046     }
047 
048     @Override
049     public void setValue(Boolean v) {
050         delegate.setValue(v);
051     }
052 
053     @Override
054     public void bindBidirectional(Property<Boolean> other) {
055         delegate.bindBidirectional(other);
056     }
057 
058     @Override
059     public void unbindBidirectional(Property<Boolean> other) {
060         delegate.unbindBidirectional(other);
061     }
062 
063     @Override
064     public boolean equals(Object o) {
065         return this == o || delegate.equals(o);
066     }
067 
068     @Override
069     public int hashCode() {
070         return delegate.hashCode();
071     }
072 
073     @Override
074     public String toString() {
075         return getClass().getName() ":" + delegate.toString();
076     }
077 
078     @Override
079     public ObjectProperty<Boolean> asObject() {
080         return delegate.asObject();
081     }
082 
083     @Override
084     public Boolean getValue() {
085         return delegate.getValue();
086     }
087 
088     @Override
089     public BooleanBinding and(ObservableBooleanValue other) {
090         return delegate.and(other);
091     }
092 
093     @Override
094     public BooleanBinding or(ObservableBooleanValue other) {
095         return delegate.or(other);
096     }
097 
098     @Override
099     public BooleanBinding not() {
100         return delegate.not();
101     }
102 
103     @Override
104     public BooleanBinding isEqualTo(ObservableBooleanValue other) {
105         return delegate.isEqualTo(other);
106     }
107 
108     @Override
109     public BooleanBinding isNotEqualTo(ObservableBooleanValue other) {
110         return delegate.isNotEqualTo(other);
111     }
112 
113     @Override
114     public StringBinding asString() {
115         return delegate.asString();
116     }
117 
118     @Override
119     public boolean get() {
120         return delegate.get();
121     }
122 
123     @Override
124     public void addListener(ChangeListener<? super Boolean> listener) {
125         delegate.addListener(listener);
126     }
127 
128     @Override
129     public void removeListener(ChangeListener<? super Boolean> listener) {
130         delegate.removeListener(listener);
131     }
132 
133     @Override
134     public void addListener(InvalidationListener listener) {
135         delegate.addListener(listener);
136     }
137 
138     @Override
139     public void removeListener(InvalidationListener listener) {
140         delegate.removeListener(listener);
141     }
142 
143     @Override
144     public Object getBean() {
145         return delegate.getBean();
146     }
147 
148     @Override
149     public String getName() {
150         return delegate.getName();
151     }
152 
153     @Override
154     public void bind(ObservableValue<? extends Boolean> observable) {
155         delegate.bind(observable);
156     }
157 
158     @Override
159     public void unbind() {
160         delegate.unbind();
161     }
162 
163     @Override
164     public boolean isBound() {
165         return delegate.isBound();
166     }
167 
168     @Override
169     public void set(boolean value) {
170         delegate.set(value);
171     }
172 }