View Javadoc
1   /**
2    * This file Copyright (c) 2011-2017 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.module.model;
35  
36  import java.lang.annotation.Annotation;
37  
38  /**
39   * Component as defined in module descriptor.
40   *
41   * @see ModuleDefinition
42   */
43  public class ComponentDefinition {
44  
45      public static final String SCOPE_SINGLETON = "singleton";
46      public static final String SCOPE_LOCAL = "local";
47      public static final String SCOPE_SESSION = "session";
48  
49      private String type;
50      private String implementation;
51      private String observed;
52      private String workspace;
53      private String path;
54      private String provider;
55      private String scope;
56      private String lazy;
57      private Annotation bindingContext;
58  
59      public String getType() {
60          return type;
61      }
62  
63      public void setType(String type) {
64          this.type = type;
65      }
66  
67      public String getImplementation() {
68          return implementation;
69      }
70  
71      public void setImplementation(String implementation) {
72          this.implementation = implementation;
73      }
74  
75      public String getObserved() {
76          return observed;
77      }
78  
79      public void setObserved(String observed) {
80          this.observed = observed;
81      }
82  
83      public String getWorkspace() {
84          return workspace;
85      }
86  
87      public void setWorkspace(String workspace) {
88          this.workspace = workspace;
89      }
90  
91      public String getPath() {
92          return path;
93      }
94  
95      public void setPath(String path) {
96          this.path = path;
97      }
98  
99      public String getProvider() {
100         return provider;
101     }
102 
103     public void setProvider(String provider) {
104         this.provider = provider;
105     }
106 
107     public String getScope() {
108         return scope;
109     }
110 
111     public void setScope(String scope) {
112         this.scope = scope;
113     }
114 
115     public String getLazy() {
116         return lazy;
117     }
118 
119     public void setLazy(String lazy) {
120         this.lazy = lazy;
121     }
122 
123     public Annotation getBindingContext() {
124         return this.bindingContext;
125     }
126 
127     public void setBindingContext(Annotation appScope) {
128         this.bindingContext = appScope;
129     }
130 
131     @Override
132     public boolean equals(Object o) {
133         if (this == o) return true;
134         if (!(o instanceof ComponentDefinition)) return false;
135 
136         ComponentDefinition that = (ComponentDefinition) o;
137 
138         if (!type.equals(that.type)) return false;
139         if (!implementation.equals(that.implementation)) return false;
140         if (observed != null ? !observed.equals(that.observed) : that.observed != null) return false;
141         if (workspace != null ? !workspace.equals(that.workspace) : that.workspace != null) return false;
142         if (path != null ? !path.equals(that.path) : that.path != null) return false;
143         if (provider != null ? !provider.equals(that.provider) : that.provider != null) return false;
144         if (scope != null ? !scope.equals(that.scope) : that.scope != null) return false;
145         if (lazy != null ? !lazy.equals(that.lazy) : that.lazy != null) return false;
146         return bindingContext != null ? bindingContext.equals(that.bindingContext) : that.bindingContext == null;
147     }
148 
149     @Override
150     public int hashCode() {
151         int result = type.hashCode();
152         result = 31 * result + implementation.hashCode();
153         result = 31 * result + (observed != null ? observed.hashCode() : 0);
154         result = 31 * result + (workspace != null ? workspace.hashCode() : 0);
155         result = 31 * result + (path != null ? path.hashCode() : 0);
156         result = 31 * result + (provider != null ? provider.hashCode() : 0);
157         result = 31 * result + (scope != null ? scope.hashCode() : 0);
158         result = 31 * result + (lazy != null ? lazy.hashCode() : 0);
159         result = 31 * result + (bindingContext != null ? bindingContext.hashCode() : 0);
160         return result;
161     }
162 }