< prev index next >

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

Print this page




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

  82      * @param property
  83      *            The source {@code ReadOnlyProperty}
  84      * @return A {@code ReadOnlyIntegerProperty} 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> ReadOnlyIntegerProperty readOnlyIntegerProperty(final ReadOnlyProperty<T> property) {
  91         if (property == null) {
  92             throw new NullPointerException("Property cannot be null");
  93         }
  94 
  95         return property instanceof ReadOnlyIntegerProperty ? (ReadOnlyIntegerProperty) property:
  96            new ReadOnlyIntegerPropertyBase() {
  97             private boolean valid = true;
  98             private final InvalidationListener listener = observable -> {
  99                 if (valid) {
 100                     valid = false;
 101                     fireValueChangedEvent();




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


< prev index next >