Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Core/3.3/Constraints/ConstraintOperation.cs @ 17228

Last change on this file since 17228 was 17180, checked in by swagner, 5 years ago

#2875: Removed years in copyrights

File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HEAL.Attic;
23namespace HeuristicLab.Core {
24  [StorableType("8518F185-8222-414D-8AAF-0273D7B09A0E")]
25  public class ConstraintOperation {
26    public static readonly ConstraintOperation Equal = new ConstraintOperation(0, "Equal");
27    public static readonly ConstraintOperation NotEqual = new ConstraintOperation(1, "Not equal");
28    public static readonly ConstraintOperation Less = new ConstraintOperation(2, "Less than");
29    public static readonly ConstraintOperation LessOrEqual = new ConstraintOperation(3, "Less than or equal");
30    public static readonly ConstraintOperation Greater = new ConstraintOperation(4, "Greater than");
31    public static readonly ConstraintOperation GreaterOrEqual = new ConstraintOperation(5, "Greater than or equal");
32    public static readonly ConstraintOperation IsTypeCompatible = new ConstraintOperation(6, "Is type compatible to");
33    public static readonly ConstraintOperation IsTypeNotCompatible = new ConstraintOperation(7, "Is type not compatible to");
34
35    [Storable]
36    private int value;
37    [Storable]
38    private string name;
39
40    [StorableConstructor]
41    protected ConstraintOperation(StorableConstructorFlag _) { }
42    protected ConstraintOperation(int value, string name) {
43      this.value = value;
44      this.name = name;
45    }
46
47    public override string ToString() {
48      return name;
49    }
50
51    public override bool Equals(object obj) {
52      if (obj is ConstraintOperation)
53        return this == (ConstraintOperation)obj;
54
55      return false;
56    }
57    public override int GetHashCode() {
58      return value;
59    }
60    public static bool operator ==(ConstraintOperation co1, ConstraintOperation co2) {
61      if (object.ReferenceEquals(co1, co2))
62        return true;
63
64      if ((object)co1 == null || (object)co2 == null)
65        return false;
66
67      return co1.value == co2.value;
68    }
69    public static bool operator !=(ConstraintOperation co1, ConstraintOperation co2) {
70      return !(co1 == co2);
71    }
72  }
73}
Note: See TracBrowser for help on using the repository browser.