001    /**
002     *
003     *  Licensed to the Apache Software Foundation (ASF) under one or more
004     *  contributor license agreements.  See the NOTICE file distributed with
005     *  this work for additional information regarding copyright ownership.
006     *  The ASF licenses this file to You under the Apache License, Version 2.0
007     *  (the "License"); you may not use this file except in compliance with
008     *  the License.  You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     *  Unless required by applicable law or agreed to in writing, software
013     *  distributed under the License is distributed on an "AS IS" BASIS,
014     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     *  See the License for the specific language governing permissions and
016     *  limitations under the License.
017     */
018    package org.apache.geronimo.naming.deployment.jsr88;
019    
020    import java.io.Serializable;
021    
022    /**
023     * Holds the elements that make up an ObjectName.  This class exists
024     * so that the bundle of elements can be get, set, and edited together
025     * separate from any other elements that may be on the parent.
026     *
027     * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
028     */
029    public class Pattern implements Serializable {
030        private String groupId;
031        private String artifactId;
032        private String version;
033        private String module;
034        private String name;
035        private String type;
036    
037        public String getGroupId() {
038            return groupId;
039        }
040    
041        public void setGroupId(String groupId) {
042            this.groupId = groupId;
043        }
044    
045        public String getArtifactId() {
046            return artifactId;
047        }
048    
049        public void setArtifactId(String artifactId) {
050            this.artifactId = artifactId;
051        }
052    
053        public String getVersion() {
054            return version;
055        }
056    
057        public void setVersion(String version) {
058            this.version = version;
059        }
060    
061        public String getModule() {
062            return module;
063        }
064    
065        public void setModule(String module) {
066            this.module = module;
067        }
068    
069        public String getName() {
070            return name;
071        }
072    
073        public void setName(String name) {
074            this.name = name;
075        }
076    
077    
078        public String getType() {
079            return type;
080        }
081    
082        public void setType(String type) {
083            this.type = type;
084        }
085    
086        public boolean empty() {
087            return (groupId == null || groupId.trim().equals("")) &&
088                    (artifactId == null || artifactId.trim().equals("")) &&
089                    (version == null || version.trim().equals("")) &&
090                    (module == null || module.trim().equals("")) &&
091                    (name == null || name.trim().equals("")) &&
092                    (type == null || type.trim().equals(""));
093        }
094    
095        public boolean equals(Object o) {
096            if (this == o) return true;
097            if (o == null || getClass() != o.getClass()) return false;
098    
099            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    }