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 public String name() 067 { 068 return name; 069 } 070 071 public void name( String name ) 072 { 073 this.name = name; 074 } 075 076 public String alias() 077 { 078 return alias; 079 } 080 081 public void alias( String alias ) 082 { 083 this.alias = alias; 084 } 085 086 public String property() 087 { 088 return property; 089 } 090 091 public void property( String property ) 092 { 093 this.property = property; 094 } 095 096 public String defaultValue() 097 { 098 return defaultValue; 099 } 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}