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