Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 4068 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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 HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
23namespace HeuristicLab.Core {
24  [StorableClass]
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(bool deserializing) {
42    }
43    protected ConstraintOperation(int value, string name) {
44      this.value = value;
45      this.name = name;
46    }
47
48    public override string ToString() {
49      return name;
50    }
51
52    public override bool Equals(object obj) {
53      if (obj is ConstraintOperation)
54        return this == (ConstraintOperation)obj;
55
56      return false;
57    }
58    public override int GetHashCode() {
59      return value;
60    }
61    public static bool operator ==(ConstraintOperation co1, ConstraintOperation co2) {
62      if (object.ReferenceEquals(co1, co2))
63        return true;
64
65      if ((object)co1 == null || (object)co2 == null)
66        return false;
67
68      return co1.value == co2.value;
69    }
70    public static bool operator !=(ConstraintOperation co1, ConstraintOperation co2) {
71      return !(co1 == co2);
72    }
73  }
74}
Note: See TracBrowser for help on using the repository browser.