View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with 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,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.tools.plugin.extractor.annotations.datamodel;
20  
21  import java.lang.annotation.Annotation;
22  
23  import org.apache.maven.plugins.annotations.InstantiationStrategy;
24  import org.apache.maven.plugins.annotations.LifecyclePhase;
25  import org.apache.maven.plugins.annotations.Mojo;
26  import org.apache.maven.plugins.annotations.ResolutionScope;
27  
28  /**
29   * @author Olivier Lamy
30   * @since 3.0
31   */
32  public class MojoAnnotationContent extends AnnotatedContent implements Mojo {
33      private String name;
34  
35      private LifecyclePhase defaultPhase = LifecyclePhase.NONE;
36  
37      private ResolutionScope requiresDependencyResolution = ResolutionScope.NONE;
38  
39      private ResolutionScope requiresDependencyCollection = ResolutionScope.NONE;
40  
41      private InstantiationStrategy instantiationStrategy = InstantiationStrategy.PER_LOOKUP;
42  
43      private String executionStrategy = "once-per-session";
44  
45      private boolean requiresProject = true;
46  
47      private boolean requiresReports = false;
48  
49      private boolean aggregator = false;
50  
51      private boolean requiresDirectInvocation = false;
52  
53      private boolean requiresOnline = false;
54  
55      private boolean inheritByDefault = true;
56  
57      private String configurator;
58  
59      private boolean threadSafe = false;
60  
61      @Override
62      public Class<? extends Annotation> annotationType() {
63          return null;
64      }
65  
66      @Override
67      public LifecyclePhase defaultPhase() {
68          return defaultPhase;
69      }
70  
71      public void defaultPhase(String phase) {
72          this.defaultPhase = LifecyclePhase.valueOf(phase);
73      }
74  
75      @Override
76      public ResolutionScope requiresDependencyResolution() {
77          return requiresDependencyResolution;
78      }
79  
80      public void requiresDependencyResolution(String requiresDependencyResolution) {
81          this.requiresDependencyResolution = ResolutionScope.valueOf(requiresDependencyResolution);
82      }
83  
84      @Override
85      public ResolutionScope requiresDependencyCollection() {
86          return requiresDependencyCollection;
87      }
88  
89      public void requiresDependencyCollection(String requiresDependencyCollection) {
90          this.requiresDependencyCollection = ResolutionScope.valueOf(requiresDependencyCollection);
91      }
92  
93      @Override
94      public InstantiationStrategy instantiationStrategy() {
95          return instantiationStrategy;
96      }
97  
98      public void instantiationStrategy(String instantiationStrategy) {
99          this.instantiationStrategy = InstantiationStrategy.valueOf(instantiationStrategy);
100     }
101 
102     @Override
103     public String executionStrategy() {
104         return executionStrategy;
105     }
106 
107     public void executionStrategy(String executionStrategy) {
108         this.executionStrategy = executionStrategy;
109     }
110 
111     @Override
112     public boolean requiresProject() {
113         return requiresProject;
114     }
115 
116     public void requiresProject(boolean requiresProject) {
117         this.requiresProject = requiresProject;
118     }
119 
120     @Override
121     public boolean requiresReports() {
122         return requiresReports;
123     }
124 
125     public void requiresReports(boolean requiresReports) {
126         this.requiresReports = requiresReports;
127     }
128 
129     @Override
130     public boolean aggregator() {
131         return aggregator;
132     }
133 
134     public void aggregator(boolean aggregator) {
135         this.aggregator = aggregator;
136     }
137 
138     @Override
139     public boolean requiresDirectInvocation() {
140         return requiresDirectInvocation;
141     }
142 
143     public void requiresDirectInvocation(boolean requiresDirectInvocation) {
144         this.requiresDirectInvocation = requiresDirectInvocation;
145     }
146 
147     @Override
148     public boolean requiresOnline() {
149         return requiresOnline;
150     }
151 
152     public void requiresOnline(boolean requiresOnline) {
153         this.requiresOnline = requiresOnline;
154     }
155 
156     @Override
157     public boolean inheritByDefault() {
158         return inheritByDefault;
159     }
160 
161     public void inheritByDefault(boolean inheritByDefault) {
162         this.inheritByDefault = inheritByDefault;
163     }
164 
165     @Override
166     public String configurator() {
167         return configurator;
168     }
169 
170     public void configurator(String configurator) {
171         this.configurator = configurator;
172     }
173 
174     @Override
175     public boolean threadSafe() {
176         return threadSafe;
177     }
178 
179     public void threadSafe(boolean threadSafe) {
180         this.threadSafe = threadSafe;
181     }
182 
183     @Override
184     public String name() {
185         return this.name;
186     }
187 
188     public void name(String name) {
189         this.name = name;
190     }
191 
192     @Override
193     public String toString() {
194         final StringBuilder sb = new StringBuilder();
195         sb.append("MojoAnnotationContent");
196         sb.append("{name='").append(name).append('\'');
197         sb.append(", defaultPhase=").append(defaultPhase);
198         sb.append(", requiresDependencyResolution='")
199                 .append(requiresDependencyResolution)
200                 .append('\'');
201         sb.append(", requiresDependencyCollection='")
202                 .append(requiresDependencyCollection)
203                 .append('\'');
204         sb.append(", instantiationStrategy='").append(instantiationStrategy).append('\'');
205         sb.append(", executionStrategy='").append(executionStrategy).append('\'');
206         sb.append(", requiresProject=").append(requiresProject);
207         sb.append(", requiresReports=").append(requiresReports);
208         sb.append(", aggregator=").append(aggregator);
209         sb.append(", requiresDirectInvocation=").append(requiresDirectInvocation);
210         sb.append(", requiresOnline=").append(requiresOnline);
211         sb.append(", inheritByDefault=").append(inheritByDefault);
212         sb.append(", configurator='").append(configurator).append('\'');
213         sb.append(", threadSafe=").append(threadSafe);
214         sb.append('}');
215         return sb.toString();
216     }
217 }