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

net.sf.staccatocommons.defs.predicate.Predicate2 Maven / Gradle / Ivy

Go to download

Minimal definitions library that provides very abstract interfaces with well defined but generic semantics, focused on code reuse.

The newest version!
/**
 *  Copyright (c) 2010-2012, The StaccatoCommons Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation; version 3 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 */


package net.sf.staccatocommons.defs.predicate;

import net.sf.staccatocommons.defs.Applicable;
import net.sf.staccatocommons.defs.Applicable2;
import net.sf.staccatocommons.defs.Evaluable2;
import net.sf.staccatocommons.defs.NullSafe;
import net.sf.staccatocommons.defs.partial.NullSafeAware;
import net.sf.staccatocommons.defs.tuple.Tuple2;
import net.sf.staccatocommons.restrictions.check.NonNull;

/**
 * A rich {@link Evaluable2}
 * 
 * @author flbulgarelli
 */
public interface Predicate2 extends Evaluable2, Applicable2,
  Applicable>, NullSafeAware> {

  /**
   * Negates this {@link Predicate}
   * 
   * @return a {@link Predicate2} that negates this {@link Predicate2}'s result.
   */
  Predicate2 not();

  /**
   * Returns a predicate that, performs a short-circuit logical-or between this
   * {@link Predicate2}'s {@link #eval(Object,Object)} and other
   * 
   * @param other
   *          another {@link Evaluable2}. Non null.
   * @return A new predicate that performs the short circuited or between this
   *         and other when evaluated.
   */
  Predicate2 or(@NonNull final Evaluable2 other);

  /**
   * Returns a predicate that performs a short-circuit logical-and between this
   * {@link Predicate2}'s {@link #eval(Object,Object)} and other
   * 
   * @param other
   *          another {@link Evaluable2}. Non null.
   * @return A new predicate that performs the short circuited logical-and
   *         between this and other when evaluated. Non Null
   */
  Predicate2 and(@NonNull final Evaluable2 other);

  /**
   * Answers a {@link Predicate2} that returns true if both
   * arguments are null, false if only one of them is
   * null, or evalutes this predicate, otherwise.
   */
  @NullSafe
  Predicate2 nullSafe();

  /**
   * Uncurries this
   * predicate, by returning a {@link Predicate} that takes a single pair, being
   * its components each of the original predicate parameters
   * 
   * @return a new {@link Predicate}
   */
  Predicate> uncurry();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy