org.cpsolver.ifs.model

## Class BinaryConstraint<V extends Variable<V,T>,T extends Value<V,T>>

- java.lang.Object
- - org.cpsolver.ifs.model.Constraint<V,T>
  - - org.cpsolver.ifs.model.BinaryConstraint<V,T>

- Type Parameters:
    `V` - Variable
    `T` - Value
  All Implemented Interfaces:
    Comparable<Constraint<V,T>>
  Direct Known Subclasses:
    BinaryConstraintWithContext, CSPBinaryConstraint, Dependence

      public abstract class BinaryConstraint<V extends Variable<V,T>,T extends Value<V,T>>
      extends Constraint<V,T>

  Binary constraint.
  Extension of `Constraint` that links exactly two variables.
  Version:
    IFS 1.3 (Iterative Forward Search)
    Copyright (C) 2006 - 2014 Tomáš Müller
    muller@unitime.org
    http://muller.unitime.org
    This library 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; either version 3 of the License, or (at your option) any later version.
    This library 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.
    You should have received a copy of the GNU Lesser General Public License along with this library; if not see http://www.gnu.org/licenses/.
  Author:
    Tomáš Müller
  See Also:
    `Variable`, `Constraint`, `Model`

- - ### Field Summary

    - ### Fields inherited from class org.cpsolver.ifs.model.Constraint

      `iConstraintListeners, iId`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BinaryConstraint()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addVariable(V var)` Add a variable to this constraint
    `V` | `another(V variable)` Returns the variable out of the constraints variables which is different from the given variable.
    `V` | `first()` First variable
    `boolean` | `isFirst(V variable)` True, id the given variable is the first one
    `V` | `second()` Second variable

    - ### Methods inherited from class org.cpsolver.ifs.model.Constraint

      `addConstraintListener, assigned, assignedVariables, compareTo, computeConflicts, computeConflictsNoForwardCheck, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, getName, hashCode, inConflict, isConsistent, isHard, removeConstraintListener, removeVariable, setModel, unassigned, variables`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BinaryConstraint

          public BinaryConstraint()

  - ### Method Detail

    - #### addVariable

          public void addVariable(V var)

      Description copied from class: `Constraint`
      Add a variable to this constraint
      Overrides:
        `addVariable` in class `Constraint<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `var` - a variable

    - #### first

          public V first()

      First variable
      Returns:
        first variable of the constraint

    - #### second

          public V second()

      Second variable
      Returns:
        second variable of the constraint

    - #### isFirst

          public boolean isFirst(V variable)

      True, id the given variable is the first one
      Parameters:
        `variable` - given variable
      Returns:
        true if the given variable is the first variable of the constraint

    - #### another

          public V another(V variable)

      Returns the variable out of the constraints variables which is different from the given variable.
      Parameters:
        `variable` - given variable
      Returns:
        the other variable of the constraint