All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.methylene.args.predicate.IntegerPredicates Maven / Gradle / Ivy

The newest version!
package com.github.methylene.args.predicate;

import com.github.methylene.args.Predicate;

public class IntegerPredicates {

  public static Predicate even() {
    return new Predicate() {
      @Override
      public boolean matches(Integer arg) {
        return arg != null && arg % 2 == 0;
      }
    };
  }

  public static Predicate odd() {
    return new Predicate() {
      @Override
      public boolean matches(Integer arg) {
        return arg != null && arg % 2 != 0;
      }
    };
  }

  public static Predicate exactly(int n) {
    return Predicates.is(n);
  }

  public static Predicate geq(final int n) {
    return new Predicate() {
      @Override
      public boolean matches(Integer arg) {
        return arg != null && arg >= n;
      }
    };
  }

  public static Predicate leq(final int n) {
    return new Predicate() {
      @Override
      public boolean matches(Integer arg) {
        return arg != null && arg <= n;
      }
    };
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy