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