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.Parameter;
23  
24  import java.lang.annotation.Annotation;
25  
26  /**
27   * @author Olivier Lamy
28   * @since 3.0
29   */
30  public class ParameterAnnotationContent
31      extends AnnotatedField
32      implements Parameter
33  {
34  
35      private String name;
36  
37      private String alias;
38  
39      private String property;
40  
41      private String defaultValue;
42  
43      private boolean required = false;
44  
45      private boolean readonly = false;
46  
47      private String className;
48  
49      public ParameterAnnotationContent( String fieldName, String className )
50      {
51          super( fieldName );
52          this.className = className;
53      }
54  
55      public ParameterAnnotationContent( String fieldName, String alias, String property, String defaultValue,
56                                         boolean required, boolean readonly, String className )
57      {
58          this( fieldName, className );
59          this.alias = alias;
60          this.property = property;
61          this.defaultValue = defaultValue;
62          this.required = required;
63          this.readonly = readonly;
64      }
65  
66      public String name()
67      {
68          return name;
69      }
70  
71      public void name( String name )
72      {
73          this.name = name;
74      }
75  
76      public String alias()
77      {
78          return alias;
79      }
80  
81      public void alias( String alias )
82      {
83          this.alias = alias;
84      }
85  
86      public String property()
87      {
88          return property;
89      }
90  
91      public void property( String property )
92      {
93          this.property = property;
94      }
95  
96      public String defaultValue()
97      {
98          return defaultValue;
99      }
100 
101     public void defaultValue( String defaultValue )
102     {
103         this.defaultValue = defaultValue;
104     }
105 
106     public boolean required()
107     {
108         return required;
109     }
110 
111     public void required( boolean required )
112     {
113         this.required = required;
114     }
115 
116     public boolean readonly()
117     {
118         return readonly;
119     }
120 
121     public void readonly( boolean readonly )
122     {
123         this.readonly = readonly;
124     }
125 
126     public Class<? extends Annotation> annotationType()
127     {
128         return null;
129     }
130 
131     public String getClassName()
132     {
133         return className;
134     }
135 
136     public void setClassName( String className )
137     {
138         this.className = className;
139     }
140 
141     @Override
142     public String toString()
143     {
144         final StringBuilder sb = new StringBuilder();
145         sb.append( super.toString() );
146         sb.append( "ParameterAnnotationContent" );
147         sb.append( "{name='" ).append( name ).append( '\'' );
148         sb.append( ", alias='" ).append( alias ).append( '\'' );
149         sb.append( ", property='" ).append( property ).append( '\'' );
150         sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' );
151         sb.append( ", required=" ).append( required );
152         sb.append( ", readonly=" ).append( readonly );
153         sb.append( '}' );
154         return sb.toString();
155     }
156 
157     @Override
158     public boolean equals( Object o )
159     {
160         if ( this == o )
161         {
162             return true;
163         }
164         if ( !( o instanceof ParameterAnnotationContent ) )
165         {
166             return false;
167         }
168 
169         ParameterAnnotationContent that = (ParameterAnnotationContent) o;
170 
171         if ( readonly != that.readonly )
172         {
173             return false;
174         }
175         if ( required != that.required )
176         {
177             return false;
178         }
179 
180         if ( getFieldName() != null ? !getFieldName().equals( that.getFieldName() ) : that.getFieldName() != null )
181         {
182             return false;
183         }
184 
185         if ( alias != null ? !alias.equals( that.alias ) : that.alias != null )
186         {
187             return false;
188         }
189         if ( defaultValue != null ? !defaultValue.equals( that.defaultValue ) : that.defaultValue != null )
190         {
191             return false;
192         }
193         if ( property != null ? !property.equals( that.property ) : that.property != null )
194         {
195             return false;
196         }
197 
198         return true;
199     }
200 
201     @Override
202     public int hashCode()
203     {
204         int result = alias != null ? alias.hashCode() : 0;
205         result = 31 * result + ( getFieldName() != null ? getFieldName().hashCode() : 0 );
206         result = 31 * result + ( property != null ? property.hashCode() : 0 );
207         result = 31 * result + ( defaultValue != null ? defaultValue.hashCode() : 0 );
208         result = 31 * result + ( required ? 1 : 0 );
209         result = 31 * result + ( readonly ? 1 : 0 );
210         return result;
211     }
212 }