UnaryIntConstraint.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. import org.csp.constraint.model.UnaryConstraint;

  19. /**
  20.  * Unary constraint between an integer variable and a fixed value.
  21.  */
  22. public abstract class UnaryIntConstraint extends UnaryConstraint<IntValue> {

  23.     /**
  24.      * Value constraining the variable.
  25.      */
  26.     private IntValue value_;

  27.     /**
  28.      * Constructor of the constraint.
  29.      * @param name
  30.      *            Name of the constraint
  31.      * @param variable
  32.      *            Constrained variable
  33.      * @param value
  34.      *            Fixed value
  35.      */
  36.     public UnaryIntConstraint(final String name, final IntVar variable,
  37.             final IntValue value) {
  38.         super(name, variable);
  39.         value_ = value;
  40.     }

  41.     /**
  42.      * Get the value constraining the variable.
  43.      * @return Constraining value
  44.      */
  45.     public IntValue getValue() {
  46.         return value_;
  47.     }

  48. }