< prev index next >

modules/javafx.base/src/main/java/javafx/beans/property/ReadOnlyDoubleProperty.java

Print this page




  61         if (bean != null) {
  62             result.append("bean: ").append(bean).append(", ");
  63         }
  64         if ((name != null) && !name.equals("")) {
  65             result.append("name: ").append(name).append(", ");
  66         }
  67         result.append("value: ").append(get()).append("]");
  68         return result.toString();
  69     }
  70 
  71     /**
  72      * Returns a {@code ReadOnlyDoubleProperty} that wraps a
  73      * {@link javafx.beans.property.ReadOnlyProperty}. If the
  74      * {@code ReadOnlyProperty} is already a {@code ReadOnlyDoubleProperty}, it
  75      * will be returned. Otherwise a new
  76      * {@code ReadOnlyDoubleProperty} is created that is bound to
  77      * the {@code ReadOnlyProperty}.
  78      *
  79      * Note: null values will be interpreted as 0.0
  80      *

  81      * @param property
  82      *            The source {@code ReadOnlyProperty}
  83      * @return A {@code ReadOnlyDoubleProperty} that wraps the
  84      *         {@code ReadOnlyProperty} if necessary
  85      * @throws NullPointerException
  86      *             if {@code property} is {@code null}
  87      * @since JavaFX 8.0
  88      */
  89     public static <T extends Number> ReadOnlyDoubleProperty readOnlyDoubleProperty(final ReadOnlyProperty<T> property) {
  90         if (property == null) {
  91             throw new NullPointerException("Property cannot be null");
  92         }
  93 
  94         return property instanceof ReadOnlyDoubleProperty ? (ReadOnlyDoubleProperty) property:
  95            new ReadOnlyDoublePropertyBase() {
  96             private boolean valid = true;
  97             private final InvalidationListener listener = observable -> {
  98                 if (valid) {
  99                     valid = false;
 100                     fireValueChangedEvent();




  61         if (bean != null) {
  62             result.append("bean: ").append(bean).append(", ");
  63         }
  64         if ((name != null) && !name.equals("")) {
  65             result.append("name: ").append(name).append(", ");
  66         }
  67         result.append("value: ").append(get()).append("]");
  68         return result.toString();
  69     }
  70 
  71     /**
  72      * Returns a {@code ReadOnlyDoubleProperty} that wraps a
  73      * {@link javafx.beans.property.ReadOnlyProperty}. If the
  74      * {@code ReadOnlyProperty} is already a {@code ReadOnlyDoubleProperty}, it
  75      * will be returned. Otherwise a new
  76      * {@code ReadOnlyDoubleProperty} is created that is bound to
  77      * the {@code ReadOnlyProperty}.
  78      *
  79      * Note: null values will be interpreted as 0.0
  80      *
  81      * @param <T> The type of Number to be wrapped
  82      * @param property
  83      *            The source {@code ReadOnlyProperty}
  84      * @return A {@code ReadOnlyDoubleProperty} that wraps the
  85      *         {@code ReadOnlyProperty} if necessary
  86      * @throws NullPointerException
  87      *             if {@code property} is {@code null}
  88      * @since JavaFX 8.0
  89      */
  90     public static <T extends Number> ReadOnlyDoubleProperty readOnlyDoubleProperty(final ReadOnlyProperty<T> property) {
  91         if (property == null) {
  92             throw new NullPointerException("Property cannot be null");
  93         }
  94 
  95         return property instanceof ReadOnlyDoubleProperty ? (ReadOnlyDoubleProperty) property:
  96            new ReadOnlyDoublePropertyBase() {
  97             private boolean valid = true;
  98             private final InvalidationListener listener = observable -> {
  99                 if (valid) {
 100                     valid = false;
 101                     fireValueChangedEvent();


< prev index next >