001package org.apache.maven.tools.plugin.extractor.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
022import org.apache.maven.plugins.annotations.Parameter;
023
024import java.lang.annotation.Annotation;
025
026/**
027 * @author Olivier Lamy
028 * @since 3.0
029 */
030public class ParameterAnnotationContent
031    extends AnnotatedField
032    implements Parameter
033{
034
035    private String name;
036
037    private String alias;
038
039    private String property;
040
041    private String defaultValue;
042
043    private boolean required = false;
044
045    private boolean readonly = false;
046
047    private String className;
048
049    public ParameterAnnotationContent( String fieldName, String className )
050    {
051        super( fieldName );
052        this.className = className;
053    }
054
055    public ParameterAnnotationContent( String fieldName, String alias, String property, String defaultValue,
056                                       boolean required, boolean readonly, String className )
057    {
058        this( fieldName, className );
059        this.alias = alias;
060        this.property = property;
061        this.defaultValue = defaultValue;
062        this.required = required;
063        this.readonly = readonly;
064    }
065
066    @Override
067    public String name()
068    {
069        return name;
070    }
071
072    public void name( String name )
073    {
074        this.name = name;
075    }
076
077    @Override
078    public String alias()
079    {
080        return alias;
081    }
082
083    public void alias( String alias )
084    {
085        this.alias = alias;
086    }
087
088    @Override
089    public String property()
090    {
091        return property;
092    }
093
094    public void property( String property )
095    {
096        this.property = property;
097    }
098
099    @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}