01 /*
02 * SPDX-License-Identifier: Apache-2.0
03 *
04 * Copyright 2008-2017 the original author or authors.
05 *
06 * Licensed under the Apache License, Version 2.0 (the "License");
07 * you may not use this file except in compliance with the License.
08 * You may obtain a copy of the License at
09 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package griffon.javafx.beans.property;
19
20 import javafx.beans.property.Property;
21 import javafx.beans.property.ReadOnlyProperty;
22 import javafx.beans.property.ReadOnlyStringProperty;
23 import javafx.beans.property.SimpleStringProperty;
24 import javafx.beans.property.StringProperty;
25
26 import javax.annotation.Nonnull;
27 import javax.annotation.Nullable;
28
29 /**
30 * @author Andres Almiray
31 * @since 2.10.0
32 */
33 public class ResetableStringProperty extends AbstractResetableProperty<String> {
34 private StringProperty baseValue;
35 private StringProperty value;
36
37 public ResetableStringProperty() {
38 super(null);
39 }
40
41 public ResetableStringProperty(@Nullable String value) {
42 super(value);
43 }
44
45 public ResetableStringProperty(@Nullable Object bean, @Nonnull String name) {
46 super(bean, name);
47 }
48
49 public ResetableStringProperty(@Nullable Object bean, @Nonnull String name, @Nullable String baseValue) {
50 super(bean, name, baseValue);
51 }
52
53 @Nonnull
54 @Override
55 protected Property<String> writableBaseValueProperty() {
56 return writableBaseValueStringProperty();
57 }
58
59 @Nonnull
60 protected StringProperty writableBaseValueStringProperty() {
61 if (baseValue == null) {
62 baseValue = new SimpleStringProperty(this, "baseValue");
63 }
64 return baseValue;
65 }
66
67 @Nonnull
68 @Override
69 public ReadOnlyProperty<String> baseValueProperty() {
70 return writableBaseValueProperty();
71 }
72
73 @Nonnull
74 public ReadOnlyStringProperty baseValueStringProperty() {
75 return writableBaseValueStringProperty();
76 }
77
78 @Nonnull
79 @Override
80 public Property<String> valueProperty() {
81 return valueStringProperty();
82 }
83
84 @Nonnull
85 public StringProperty valueStringProperty() {
86 if (value == null) {
87 value = new SimpleStringProperty(this, "value");
88 }
89 return value;
90 }
91 }
|