View Javadoc
1   /**
2    * Copyright (c) 2013-2017 Polago AB
3    * All rights reserved.
4    *
5    * Permission is hereby granted, free of charge, to any person obtaining
6    * a copy of this software and associated documentation files (the
7    * "Software"), to deal in the Software without restriction, including
8    * without limitation the rights to use, copy, modify, merge, publish,
9    * distribute, sublicense, and/or sell copies of the Software, and to
10   * permit persons to whom the Software is furnished to do so, subject to
11   * the following conditions:
12   *
13   * The above copyright notice and this permission notice shall be
14   * included in all copies or substantial portions of the Software.
15   *
16   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17   * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19   * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20   * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21   * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22   * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23   */
24  
25  package org.polago.deployconf.task.filter;
26  
27  import java.util.regex.Pattern;
28  
29  /**
30   * A single Token in a Filter Task.
31   */
32  public class FilterToken {
33  
34      private String name;
35  
36      private Pattern regex;
37  
38      private String description;
39  
40      private String value;
41  
42      private String defaultValue;
43  
44      private String group;
45  
46      private String condition;
47  
48      /**
49       * Public Constructor.
50       *
51       * @param name the name of this token
52       * @param regex the token Pattern
53       * @param description the token description
54       * @param defaultValue the token default value
55       * @param value the token value
56       */
57      public FilterToken(String name, String regex, String description, String defaultValue, String value) {
58  
59          this.name = name;
60          this.regex = Pattern.compile(regex);
61          this.description = description;
62          this.defaultValue = defaultValue;
63          this.value = value;
64      }
65  
66      /**
67       * Gets the name property value.
68       *
69       * @return the current value of the name property
70       */
71      public String getName() {
72          return name;
73      }
74  
75      /**
76       * Sets the name property.
77       *
78       * @param name the new property value
79       */
80      public void setName(String name) {
81          this.name = name;
82      }
83  
84      /**
85       * Gets the regex property value.
86       *
87       * @return the current value of the regex property
88       */
89      public Pattern getRegex() {
90          return regex;
91      }
92  
93      /**
94       * Sets the regex property.
95       *
96       * @param regex the new property value
97       */
98      public void setRegex(Pattern regex) {
99          this.regex = regex;
100     }
101 
102     /**
103      * Gets the description property value.
104      *
105      * @return the current value of the description property
106      */
107     public String getDescription() {
108         return description;
109     }
110 
111     /**
112      * Sets the description property.
113      *
114      * @param description the new property value
115      */
116     public void setDescription(String description) {
117         this.description = description;
118     }
119 
120     /**
121      * Gets the value property value.
122      *
123      * @return the current value of the value property
124      */
125     public String getValue() {
126         return value;
127     }
128 
129     /**
130      * Sets the value property.
131      *
132      * @param value the new property value
133      */
134     public void setValue(String value) {
135         this.value = value;
136     }
137 
138     /**
139      * Gets the defaultValue property value.
140      *
141      * @return the current value of the defaultValue property
142      */
143     public String getDefaultValue() {
144         return defaultValue;
145     }
146 
147     /**
148      * Sets the defaultValue property.
149      *
150      * @param defaultValue the new property value
151      */
152     public void setDefaultValue(String defaultValue) {
153         this.defaultValue = defaultValue;
154     }
155 
156     /**
157      * Gets the group property value.
158      *
159      * @return the current value of the group property
160      */
161     public String getGroup() {
162         return group;
163     }
164 
165     /**
166      * Sets the group property.
167      *
168      * @param group the new property value
169      */
170     public void setGroup(String group) {
171         this.group = group;
172     }
173 
174     /**
175      * Gets the condition property value.
176      *
177      * @return the current value of the condition property
178      */
179     public String getCondition() {
180         return condition;
181     }
182 
183     /**
184      * Sets the condition property.
185      *
186      * @param condition the new property value
187      */
188     public void setCondition(String condition) {
189         this.condition = condition;
190     }
191 
192     /**
193      * {@inheritDoc}
194      */
195     @Override
196     public int hashCode() {
197         return getName().hashCode();
198     }
199 
200     /**
201      * {@inheritDoc}
202      */
203     @Override
204     public boolean equals(Object other) {
205         boolean result = false;
206 
207         if (other instanceof FilterToken) {
208             FilterToken otherToken = (FilterToken) other;
209             result = getName().equals(otherToken.getName());
210         }
211 
212         return result;
213     }
214 
215     /**
216      * {@inheritDoc}
217      */
218     @Override
219     public String toString() {
220         return "FilterToken [name=" + name + ", regex=" + regex + ", description=" + description + ", value=" + value
221             + ", defaultValue=" + defaultValue + ", group=" + group + ", condition=" + condition + "]";
222     }
223 
224 }