1 /**
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.apache.geronimo.naming.deployment.jsr88;
19
20 import java.io.Serializable;
21
22 /**
23 * Holds the elements that make up an ObjectName. This class exists
24 * so that the bundle of elements can be get, set, and edited together
25 * separate from any other elements that may be on the parent.
26 *
27 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
28 */
29 public class Pattern implements Serializable {
30 private String groupId;
31 private String artifactId;
32 private String version;
33 private String module;
34 private String name;
35 private String type;
36
37 public String getGroupId() {
38 return groupId;
39 }
40
41 public void setGroupId(String groupId) {
42 this.groupId = groupId;
43 }
44
45 public String getArtifactId() {
46 return artifactId;
47 }
48
49 public void setArtifactId(String artifactId) {
50 this.artifactId = artifactId;
51 }
52
53 public String getVersion() {
54 return version;
55 }
56
57 public void setVersion(String version) {
58 this.version = version;
59 }
60
61 public String getModule() {
62 return module;
63 }
64
65 public void setModule(String module) {
66 this.module = module;
67 }
68
69 public String getName() {
70 return name;
71 }
72
73 public void setName(String name) {
74 this.name = name;
75 }
76
77
78 public String getType() {
79 return type;
80 }
81
82 public void setType(String type) {
83 this.type = type;
84 }
85
86 public boolean empty() {
87 return (groupId == null || groupId.trim().equals("")) &&
88 (artifactId == null || artifactId.trim().equals("")) &&
89 (version == null || version.trim().equals("")) &&
90 (module == null || module.trim().equals("")) &&
91 (name == null || name.trim().equals("")) &&
92 (type == null || type.trim().equals(""));
93 }
94
95 public boolean equals(Object o) {
96 if (this == o) return true;
97 if (o == null || getClass() != o.getClass()) return false;
98
99 final Pattern pattern = (Pattern) o;
100
101 if (artifactId != null ? !artifactId.equals(pattern.artifactId) : pattern.artifactId != null) return false;
102 if (groupId != null ? !groupId.equals(pattern.groupId) : pattern.groupId != null) return false;
103 if (module != null ? !module.equals(pattern.module) : pattern.module != null) return false;
104 if (name != null ? !name.equals(pattern.name) : pattern.name != null) return false;
105 if (type != null ? !type.equals(pattern.type) : pattern.type != null) return false;
106 if (version != null ? !version.equals(pattern.version) : pattern.version != null) return false;
107
108 return true;
109 }
110
111 public int hashCode() {
112 int result;
113 result = (groupId != null ? groupId.hashCode() : 0);
114 result = 29 * result + (artifactId != null ? artifactId.hashCode() : 0);
115 result = 29 * result + (version != null ? version.hashCode() : 0);
116 result = 29 * result + (module != null ? module.hashCode() : 0);
117 result = 29 * result + (name != null ? name.hashCode() : 0);
118 result = 29 * result + (type != null ? type.hashCode() : 0);
119 return result;
120 }
121 }