001 package org.apache.maven.tools.plugin.annotations.datamodel;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements. See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership. The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License. You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied. See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022 import org.apache.maven.plugins.annotations.Parameter;
023
024 import java.lang.annotation.Annotation;
025
026 /**
027 * @author Olivier Lamy
028 * @since 3.0
029 */
030 public class ParameterAnnotationContent
031 extends AnnotatedField
032 implements Parameter
033 {
034
035 private String alias;
036
037 private String property;
038
039 private String defaultValue;
040
041 private boolean required = false;
042
043 private boolean readonly = false;
044
045 private String className;
046
047 public ParameterAnnotationContent( String fieldName, String className )
048 {
049 super( fieldName );
050 this.className = className;
051 }
052
053 public ParameterAnnotationContent( String fieldName, String alias, String property, String defaultValue,
054 boolean required, boolean readonly, String className )
055 {
056 this( fieldName, className );
057 this.alias = alias;
058 this.property = property;
059 this.defaultValue = defaultValue;
060 this.required = required;
061 this.readonly = readonly;
062 }
063
064 public String alias()
065 {
066 return alias;
067 }
068
069 public void alias( String alias )
070 {
071 this.alias = alias;
072 }
073
074 public String property()
075 {
076 return property;
077 }
078
079 public void property( String property )
080 {
081 this.property = property;
082 }
083
084 public String defaultValue()
085 {
086 return defaultValue;
087 }
088
089 public void defaultValue( String defaultValue )
090 {
091 this.defaultValue = defaultValue;
092 }
093
094 public boolean required()
095 {
096 return required;
097 }
098
099 public void required( boolean required )
100 {
101 this.required = required;
102 }
103
104 public boolean readonly()
105 {
106 return readonly;
107 }
108
109 public void readonly( boolean readonly )
110 {
111 this.readonly = readonly;
112 }
113
114 public Class<? extends Annotation> annotationType()
115 {
116 return null;
117 }
118
119 public String getClassName()
120 {
121 return className;
122 }
123
124 public void setClassName( String className )
125 {
126 this.className = className;
127 }
128
129 @Override
130 public String toString()
131 {
132 final StringBuilder sb = new StringBuilder();
133 sb.append( super.toString() );
134 sb.append( "ParameterAnnotationContent" );
135 sb.append( "{alias='" ).append( alias ).append( '\'' );
136 sb.append( ", property='" ).append( property ).append( '\'' );
137 sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' );
138 sb.append( ", required=" ).append( required );
139 sb.append( ", readonly=" ).append( readonly );
140 sb.append( '}' );
141 return sb.toString();
142 }
143
144 @Override
145 public boolean equals( Object o )
146 {
147 if ( this == o )
148 {
149 return true;
150 }
151 if ( !( o instanceof ParameterAnnotationContent ) )
152 {
153 return false;
154 }
155
156 ParameterAnnotationContent that = (ParameterAnnotationContent) o;
157
158 if ( readonly != that.readonly )
159 {
160 return false;
161 }
162 if ( required != that.required )
163 {
164 return false;
165 }
166
167 if ( getFieldName() != null ? !getFieldName().equals( that.getFieldName() ) : that.getFieldName() != null )
168 {
169 return false;
170 }
171
172 if ( alias != null ? !alias.equals( that.alias ) : that.alias != null )
173 {
174 return false;
175 }
176 if ( defaultValue != null ? !defaultValue.equals( that.defaultValue ) : that.defaultValue != null )
177 {
178 return false;
179 }
180 if ( property != null ? !property.equals( that.property ) : that.property != null )
181 {
182 return false;
183 }
184
185 return true;
186 }
187
188 @Override
189 public int hashCode()
190 {
191 int result = alias != null ? alias.hashCode() : 0;
192 result = 31 * result + ( getFieldName() != null ? getFieldName().hashCode() : 0 );
193 result = 31 * result + ( property != null ? property.hashCode() : 0 );
194 result = 31 * result + ( defaultValue != null ? defaultValue.hashCode() : 0 );
195 result = 31 * result + ( required ? 1 : 0 );
196 result = 31 * result + ( readonly ? 1 : 0 );
197 return result;
198 }
199 }