ObjectPropertyDecorator.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.ObjectProperty;
022 import javafx.beans.property.Property;
023 import javafx.beans.value.ChangeListener;
024 import javafx.beans.value.ObservableObjectValue;
025 import javafx.beans.value.ObservableValue;
026 
027 import javax.annotation.Nonnull;
028 import java.util.Locale;
029 
030 import static java.util.Objects.requireNonNull;
031 
032 /**
033  @author Andres Almiray
034  @since 2.11.0
035  */
036 public class ObjectPropertyDecorator<T> extends ObjectProperty<T> {
037     private final ObjectProperty<T> delegate;
038 
039     public ObjectPropertyDecorator(@Nonnull ObjectProperty<T> delegate) {
040         this.delegate = requireNonNull(delegate, "Argument 'delegate' must not be null");
041     }
042 
043     @Nonnull
044     protected final ObjectProperty<T> getDelegate() {
045         return delegate;
046     }
047 
048     @Override
049     public void setValue(T v) {
050         delegate.setValue(v);
051     }
052 
053     @Override
054     public void bindBidirectional(Property<T> other) {
055         delegate.bindBidirectional(other);
056     }
057 
058     @Override
059     public void unbindBidirectional(Property<T> 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 T getValue() {
080         return delegate.getValue();
081     }
082 
083     @Override
084     public BooleanBinding isEqualTo(ObservableObjectValue<?> other) {
085         return delegate.isEqualTo(other);
086     }
087 
088     @Override
089     public BooleanBinding isEqualTo(Object other) {
090         return delegate.isEqualTo(other);
091     }
092 
093     @Override
094     public BooleanBinding isNotEqualTo(ObservableObjectValue<?> other) {
095         return delegate.isNotEqualTo(other);
096     }
097 
098     @Override
099     public BooleanBinding isNotEqualTo(Object other) {
100         return delegate.isNotEqualTo(other);
101     }
102 
103     @Override
104     public BooleanBinding isNull() {
105         return delegate.isNull();
106     }
107 
108     @Override
109     public BooleanBinding isNotNull() {
110         return delegate.isNotNull();
111     }
112 
113     @Override
114     public StringBinding asString() {
115         return delegate.asString();
116     }
117 
118     @Override
119     public StringBinding asString(String format) {
120         return delegate.asString(format);
121     }
122 
123     @Override
124     public StringBinding asString(Locale locale, String format) {
125         return delegate.asString(locale, format);
126     }
127 
128     @Override
129     public T get() {
130         return delegate.get();
131     }
132 
133     @Override
134     public void addListener(ChangeListener<? super T> listener) {
135         delegate.addListener(listener);
136     }
137 
138     @Override
139     public void removeListener(ChangeListener<? super T> listener) {
140         delegate.removeListener(listener);
141     }
142 
143     @Override
144     public void addListener(InvalidationListener listener) {
145         delegate.addListener(listener);
146     }
147 
148     @Override
149     public void removeListener(InvalidationListener listener) {
150         delegate.removeListener(listener);
151     }
152 
153     @Override
154     public Object getBean() {
155         return delegate.getBean();
156     }
157 
158     @Override
159     public String getName() {
160         return delegate.getName();
161     }
162 
163     @Override
164     public void bind(ObservableValue<? extends T> observable) {
165         delegate.bind(observable);
166     }
167 
168     @Override
169     public void unbind() {
170         delegate.unbind();
171     }
172 
173     @Override
174     public boolean isBound() {
175         return delegate.isBound();
176     }
177 
178     @Override
179     public void set(T value) {
180         delegate.set(value);
181     }
182 }