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      @Override
67      public String name()
68      {
69          return name;
70      }
71  
72      public void name( String name )
73      {
74          this.name = name;
75      }
76  
77      @Override
78      public String alias()
79      {
80          return alias;
81      }
82  
83      public void alias( String alias )
84      {
85          this.alias = alias;
86      }
87  
88      @Override
89      public String property()
90      {
91          return property;
92      }
93  
94      public void property( String property )
95      {
96          this.property = property;
97      }
98  
99      @Override
100     public String defaultValue()
101     {
102         return defaultValue;
103     }
104 
105     public void defaultValue( String defaultValue )
106     {
107         this.defaultValue = defaultValue;
108     }
109 
110     @Override
111     public boolean required()
112     {
113         return required;
114     }
115 
116     public void required( boolean required )
117     {
118         this.required = required;
119     }
120 
121     @Override
122     public boolean readonly()
123     {
124         return readonly;
125     }
126 
127     public void readonly( boolean readonly )
128     {
129         this.readonly = readonly;
130     }
131 
132     @Override
133     public Class<? extends Annotation> annotationType()
134     {
135         return null;
136     }
137 
138     public String getClassName()
139     {
140         return className;
141     }
142 
143     public void setClassName( String className )
144     {
145         this.className = className;
146     }
147 
148     @Override
149     public String toString()
150     {
151         final StringBuilder sb = new StringBuilder();
152         sb.append( super.toString() );
153         sb.append( "ParameterAnnotationContent" );
154         sb.append( "{name='" ).append( name ).append( '\'' );
155         sb.append( ", alias='" ).append( alias ).append( '\'' );
156         sb.append( ", property='" ).append( property ).append( '\'' );
157         sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' );
158         sb.append( ", required=" ).append( required );
159         sb.append( ", readonly=" ).append( readonly );
160         sb.append( '}' );
161         return sb.toString();
162     }
163 
164     @Override
165     public boolean equals( Object o )
166     {
167         if ( this == o )
168         {
169             return true;
170         }
171         if ( !( o instanceof ParameterAnnotationContent ) )
172         {
173             return false;
174         }
175 
176         ParameterAnnotationContent that = (ParameterAnnotationContent) o;
177 
178         if ( readonly != that.readonly )
179         {
180             return false;
181         }
182         if ( required != that.required )
183         {
184             return false;
185         }
186 
187         if ( getFieldName() != null ? !getFieldName().equals( that.getFieldName() ) : that.getFieldName() != null )
188         {
189             return false;
190         }
191 
192         if ( alias != null ? !alias.equals( that.alias ) : that.alias != null )
193         {
194             return false;
195         }
196         if ( defaultValue != null ? !defaultValue.equals( that.defaultValue ) : that.defaultValue != null )
197         {
198             return false;
199         }
200         if ( property != null ? !property.equals( that.property ) : that.property != null )
201         {
202             return false;
203         }
204 
205         return true;
206     }
207 
208     @Override
209     public int hashCode()
210     {
211         int result = alias != null ? alias.hashCode() : 0;
212         result = 31 * result + ( getFieldName() != null ? getFieldName().hashCode() : 0 );
213         result = 31 * result + ( property != null ? property.hashCode() : 0 );
214         result = 31 * result + ( defaultValue != null ? defaultValue.hashCode() : 0 );
215         result = 31 * result + ( required ? 1 : 0 );
216         result = 31 * result + ( readonly ? 1 : 0 );
217         return result;
218     }
219 }