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.LongProperty;
21 import javafx.beans.property.Property;
22 import javafx.beans.property.ReadOnlyLongProperty;
23 import javafx.beans.property.ReadOnlyProperty;
24 import javafx.beans.property.SimpleLongProperty;
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 ResetableLongProperty extends AbstractResetableProperty<Number> {
34 private LongProperty baseValue;
35 private LongProperty value;
36
37 public ResetableLongProperty() {
38 super(null);
39 }
40
41 public ResetableLongProperty(@Nullable Long value) {
42 super(value);
43 }
44
45 public ResetableLongProperty(@Nullable Object bean, @Nonnull String name) {
46 super(bean, name);
47 }
48
49 public ResetableLongProperty(@Nullable Object bean, @Nonnull String name, @Nullable Long baseValue) {
50 super(bean, name, baseValue);
51 }
52
53 @Nonnull
54 @Override
55 protected Property<Number> writableBaseValueProperty() {
56 return writableBaseValueLongProperty();
57 }
58
59 @Nonnull
60 protected LongProperty writableBaseValueLongProperty() {
61 if (baseValue == null) {
62 baseValue = new SimpleLongProperty(this, "baseValue");
63 }
64 return baseValue;
65 }
66
67 @Nonnull
68 @Override
69 public ReadOnlyProperty<Number> baseValueProperty() {
70 return writableBaseValueProperty();
71 }
72
73 @Nonnull
74 public ReadOnlyLongProperty baseValueLongProperty() {
75 return writableBaseValueLongProperty();
76 }
77
78 @Nonnull
79 @Override
80 public Property<Number> valueProperty() {
81 return valueLongProperty();
82 }
83
84 @Nonnull
85 public LongProperty valueLongProperty() {
86 if (value == null) {
87 value = new SimpleLongProperty(this, "value");
88 }
89 return value;
90 }
91 }
|