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.plugin.descriptor;
20  
21  /**
22   */
23  public class Parameter implements Cloneable {
24      private String alias;
25  
26      private String name;
27  
28      private String type;
29  
30      private boolean required;
31  
32      private boolean editable = true;
33  
34      private String description;
35  
36      private String expression;
37  
38      private String deprecated;
39  
40      private String defaultValue;
41  
42      private String implementation;
43  
44      private Requirement requirement;
45  
46      private String since;
47  
48      // ----------------------------------------------------------------------
49      //
50      // ----------------------------------------------------------------------
51  
52      public Parameter() {}
53  
54      public Parameter(org.apache.maven.api.plugin.descriptor.Parameter p) {
55          this.setAlias(p.getAlias());
56          this.setName(p.getName());
57          this.setRequired(p.isRequired());
58          this.setEditable(p.isEditable());
59          this.setDescription(p.getDescription());
60          this.setExpression(p.getExpression());
61          this.setDeprecated(p.getDeprecated());
62          this.setDefaultValue(p.getDefaultValue());
63          this.setType(p.getType());
64          this.setSince(p.getSince());
65      }
66  
67      // ----------------------------------------------------------------------
68      //
69      // ----------------------------------------------------------------------
70  
71      public String getName() {
72          return name;
73      }
74  
75      public void setName(String name) {
76          this.name = name;
77      }
78  
79      public String getType() {
80          return type;
81      }
82  
83      public void setType(String type) {
84          this.type = type;
85      }
86  
87      public boolean isRequired() {
88          return required;
89      }
90  
91      public void setRequired(boolean required) {
92          this.required = required;
93      }
94  
95      public String getDescription() {
96          return description;
97      }
98  
99      public void setDescription(String description) {
100         this.description = description;
101     }
102 
103     public String getExpression() {
104         return expression;
105     }
106 
107     public void setExpression(String expression) {
108         this.expression = expression;
109     }
110 
111     public String getDeprecated() {
112         return deprecated;
113     }
114 
115     public void setDeprecated(String deprecated) {
116         this.deprecated = deprecated;
117     }
118 
119     public int hashCode() {
120         return name.hashCode();
121     }
122 
123     public boolean equals(Object other) {
124         return (other instanceof Parameter) && getName().equals(((Parameter) other).getName());
125     }
126 
127     public String getAlias() {
128         return alias;
129     }
130 
131     public void setAlias(String alias) {
132         this.alias = alias;
133     }
134 
135     public boolean isEditable() {
136         return editable;
137     }
138 
139     public void setEditable(boolean editable) {
140         this.editable = editable;
141     }
142 
143     public void setDefaultValue(String defaultValue) {
144         this.defaultValue = defaultValue;
145     }
146 
147     public String getDefaultValue() {
148         return defaultValue;
149     }
150 
151     public String toString() {
152         return "Mojo parameter [name: '" + getName() + "'; alias: '" + getAlias() + "']";
153     }
154 
155     public Requirement getRequirement() {
156         return requirement;
157     }
158 
159     public void setRequirement(Requirement requirement) {
160         this.requirement = requirement;
161     }
162 
163     public String getImplementation() {
164         return implementation;
165     }
166 
167     public void setImplementation(String implementation) {
168         this.implementation = implementation;
169     }
170 
171     public String getSince() {
172         return since;
173     }
174 
175     public void setSince(String since) {
176         this.since = since;
177     }
178 
179     /**
180      * Creates a shallow copy of this parameter.
181      */
182     @Override
183     public Parameter clone() {
184         try {
185             return (Parameter) super.clone();
186         } catch (CloneNotSupportedException e) {
187             throw new UnsupportedOperationException(e);
188         }
189     }
190 
191     public org.apache.maven.api.plugin.descriptor.Parameter getParameterV4() {
192         return org.apache.maven.api.plugin.descriptor.Parameter.newBuilder()
193                 .alias(alias)
194                 .name(name)
195                 .type(type)
196                 .required(required)
197                 .editable(editable)
198                 .description(description)
199                 .expression(expression)
200                 .deprecated(deprecated)
201                 .defaultValue(defaultValue)
202                 .since(since)
203                 .build();
204     }
205 }