EqualToIntValue.java

  1. /* Copyright 2015 Laurent COCAULT
  2.  * Licensed to Laurent COCAULT under one or more contributor license agreements.
  3.  * See the NOTICE file distributed with this work for additional information
  4.  * regarding copyright ownership. Laurent COCAULT licenses this file to You
  5.  * under the Apache License, Version 2.0 (the "License"); you may not use this
  6.  * file except in compliance with the License.  You may obtain a copy of the
  7.  * License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.csp.constraint.model.integer;

  18. /**
  19.  * Constraint specifying that one specific integer variable is equal to a value.
  20.  */
  21. public class EqualToIntValue extends UnaryIntConstraint {

  22.     /**
  23.      * Constructor of the constraint "VAR = VALUE".
  24.      * @param variable
  25.      *            Variable constrained
  26.      * @param value
  27.      *            Fixed value for the constraint
  28.      */
  29.     public EqualToIntValue(final IntVar variable, final IntValue value) {
  30.         super(variable.getName() + "=" + value, variable, value);
  31.     }

  32.     /**
  33.      * {@inheritDoc}
  34.      */
  35.     @Override
  36.     public void propagate() {
  37.         getVariable().setValue(getValue());
  38.     }

  39. }