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  import java.util.Objects;
23  
24  import org.apache.maven.plugins.annotations.Execute;
25  import org.apache.maven.plugins.annotations.LifecyclePhase;
26  
27  /**
28   * @author Olivier Lamy
29   * @since 3.0
30   */
31  public class ExecuteAnnotationContent implements Execute {
32      private String goal;
33  
34      private String lifecycle;
35  
36      private LifecyclePhase phase;
37  
38      private String customPhase;
39  
40      @Override
41      public LifecyclePhase phase() {
42          return this.phase;
43      }
44  
45      @Override
46      public String customPhase() {
47          return customPhase;
48      }
49  
50      @Override
51      public String goal() {
52          return this.goal;
53      }
54  
55      @Override
56      public String lifecycle() {
57          return this.lifecycle;
58      }
59  
60      public void phase(String phase) {
61          if (phase != null && !phase.isEmpty()) {
62              for (LifecyclePhase p : LifecyclePhase.values()) {
63                  if (Objects.equals(phase, p.id()) || Objects.equals(phase, p.name())) {
64                      this.phase = p;
65                      this.customPhase = null;
66                      return;
67                  }
68              }
69              this.phase = null;
70              this.customPhase = phase;
71          } else {
72              this.phase = null;
73              this.customPhase = null;
74          }
75          this.phase = LifecyclePhase.valueOf(phase);
76      }
77  
78      public void customPhase(String customPhase) {
79          this.customPhase = customPhase;
80      }
81  
82      public void goal(String goal) {
83          this.goal = goal;
84      }
85  
86      public void lifecycle(String lifecycle) {
87          this.lifecycle = lifecycle;
88      }
89  
90      @Override
91      public Class<? extends Annotation> annotationType() {
92          return null;
93      }
94  
95      @Override
96      public String toString() {
97          final StringBuilder sb = new StringBuilder();
98          sb.append("ExecuteAnnotationContent");
99          sb.append("{goal='").append(goal).append('\'');
100         sb.append(", lifecycle='").append(lifecycle).append('\'');
101         sb.append(", phase=").append(phase);
102         sb.append(", customPhase=").append(customPhase);
103         sb.append('}');
104         return sb.toString();
105     }
106 }