View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: ModelColumnParameter.java
13   * Created: 2008-11-20
14   * Author: bmilos
15   * $Id: ModelColumnParameter.java 2361 2009-01-18 20:03:25Z awos $
16   */
17  
18  package pl.edu.agh.cast.model;
19  
20  import java.util.HashSet;
21  import java.util.Set;
22  
23  /**
24   *
25   * @author AGH CAST Team
26   *
27   */
28  public class ModelColumnParameter {
29      private String id;
30  
31      private String name;
32  
33      private Set<String> possibleValues;
34  
35      public ModelColumnParameter(String id) {
36          this(id, null);
37      }
38  
39      public ModelColumnParameter(String newId, String newName) {
40          id = newId;
41          name = newName;
42          possibleValues = new HashSet<String>();
43      }
44  
45      /**
46       * {@inheritDoc}
47       *
48       * @see java.lang.Object#equals(java.lang.Object)
49       */
50      @Override
51      public boolean equals(Object obj) {
52          if (this == obj) { // the same object
53              return true;
54          }
55  
56          if (!(obj instanceof ModelColumnParameter)) {
57              return false;
58          }
59          ModelColumnParameter other = (ModelColumnParameter)obj;
60  
61          if (id == null) {
62              if (other.id != null) {
63                  return false;
64              }
65          } else if (!id.equals(other.id)) {
66              return false;
67          }
68          if (name == null) {
69              if (other.name != null) {
70                  return false;
71              }
72          } else if (!name.equals(other.name)) {
73              return false;
74          }
75          if (!possibleValues.equals(other.possibleValues)) {
76              return false;
77          }
78  
79          return true;
80      }
81  
82      /**
83       * {@inheritDoc}
84       *
85       * @see java.lang.Object#hashCode()
86       */
87      @Override
88      public int hashCode() {
89          StringBuilder hash = new StringBuilder();
90          if (id != null) {
91              hash.append(id);
92          }
93          if (name != null) {
94              hash.append(name);
95          }
96          hash.append(possibleValues.hashCode());
97          return hash.toString().hashCode();
98      }
99  
100     public String getId() {
101         return id;
102     }
103 
104     public String getName() {
105         return name;
106     }
107 
108     public Set<String> getPossibleValues() {
109         return possibleValues;
110     }
111 
112     public void addPossibleValue(String possibleValue) {
113         possibleValues.add(possibleValue);
114     }
115 
116     public void removePossibleValue(String possibleValue) {
117         possibleValues.remove(possibleValue);
118     }
119 
120 }