IntValueHelper.java 521 B

123456789101112131415
  1. package org.leumasjaffe.charsheet.observer.helper;
  2. import java.util.function.BiFunction;
  3. import org.leumasjaffe.charsheet.model.observable.IntValue;
  4. public class IntValueHelper implements BiFunction<String, IntValue, Boolean> {
  5. public Boolean apply( final String str, final IntValue ref ) {
  6. if ( ! Character.isDigit(str.charAt(0)) ) return false;
  7. final int newValue = Integer.parseInt( str );
  8. if ( newValue == ref.value( ) ) return false;
  9. ref.value( newValue );
  10. return true;
  11. }
  12. }