01: // Copyright 2006 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.internal.services;
16:
17: /** Validator type and constraint values parsed from a validator specification. */
18: class ValidatorSpecification {
19: private final String _validatorType;
20:
21: private final String _constraintValue;
22:
23: public ValidatorSpecification(String validatorType) {
24: this (validatorType, null);
25: }
26:
27: public ValidatorSpecification(String validatorType,
28: String constraintValue) {
29: _validatorType = validatorType;
30: _constraintValue = constraintValue;
31: }
32:
33: public String getConstraintValue() {
34: return _constraintValue;
35: }
36:
37: public String getValidatorType() {
38: return _validatorType;
39: }
40:
41: @Override
42: public String toString() {
43: return String.format("ValidatorSpecification[%s %s]",
44: _validatorType, _constraintValue);
45: }
46:
47: @Override
48: public boolean equals(Object other) {
49: if (other == null || other.getClass() != getClass())
50: return false;
51:
52: ValidatorSpecification ov = (ValidatorSpecification) other;
53:
54: if (!_validatorType.equals(ov._validatorType))
55: return false;
56:
57: if (_constraintValue == ov._constraintValue)
58: return true;
59:
60: if (_constraintValue == null)
61: return false;
62:
63: return _constraintValue.equals(ov._constraintValue);
64: }
65: }
|