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.ObjectBinding;
023 import javafx.beans.binding.StringBinding;
024 import javafx.beans.value.ChangeListener;
025 import javafx.beans.value.ObservableObjectValue;
026 import javafx.collections.ObservableList;
027
028 import javax.annotation.Nonnull;
029 import java.util.Locale;
030
031 import static java.util.Objects.requireNonNull;
032
033 /**
034 * @author Andres Almiray
035 * @since 2.13.0
036 */
037 public class ObjectBindingDecorator<T> extends ObjectBinding<T> {
038 private final ObjectBinding<T> delegate;
039
040 public ObjectBindingDecorator(@Nonnull ObjectBinding<T> delegate) {
041 this.delegate = requireNonNull(delegate, "Argument 'delegate' must not be null");
042 }
043
044 @Nonnull
045 protected final ObjectBinding<T> getDelegate() {
046 return delegate;
047 }
048
049 @Override
050 protected T computeValue() {
051 return delegate.get();
052 }
053
054 @Override
055 public String toString() {
056 return getDelegate().toString();
057 }
058
059 @Override
060 public T getValue() {
061 return getDelegate().getValue();
062 }
063
064 @Override
065 public BooleanBinding isEqualTo(ObservableObjectValue other) {
066 return getDelegate().isEqualTo(other);
067 }
068
069 @Override
070 public BooleanBinding isEqualTo(Object other) {
071 return getDelegate().isEqualTo(other);
072 }
073
074 @Override
075 public BooleanBinding isNotEqualTo(ObservableObjectValue other) {
076 return getDelegate().isNotEqualTo(other);
077 }
078
079 @Override
080 public BooleanBinding isNotEqualTo(Object other) {
081 return getDelegate().isNotEqualTo(other);
082 }
083
084 @Override
085 public BooleanBinding isNull() {
086 return getDelegate().isNull();
087 }
088
089 @Override
090 public BooleanBinding isNotNull() {
091 return getDelegate().isNotNull();
092 }
093
094 @Override
095 public StringBinding asString() {
096 return getDelegate().asString();
097 }
098
099 @Override
100 public StringBinding asString(String format) {
101 return getDelegate().asString(format);
102 }
103
104 @Override
105 public StringBinding asString(Locale locale, String format) {
106 return getDelegate().asString(locale, format);
107 }
108
109 @Override
110 public void addListener(InvalidationListener listener) {
111 getDelegate().addListener(listener);
112 }
113
114 @Override
115 public void removeListener(InvalidationListener listener) {
116 getDelegate().removeListener(listener);
117 }
118
119 @Override
120 public void addListener(ChangeListener<? super T> listener) {
121 getDelegate().addListener(listener);
122 }
123
124 @Override
125 public void removeListener(ChangeListener<? super T> listener) {
126 getDelegate().removeListener(listener);
127 }
128
129 @Override
130 public void dispose() {
131 getDelegate().dispose();
132 }
133
134 @Override
135 public ObservableList<?> getDependencies() {
136 return getDelegate().getDependencies();
137 }
138 }
|