001package 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 022import org.apache.maven.plugins.annotations.Parameter; 023import org.codehaus.plexus.util.StringUtils; 024 025import java.lang.annotation.Annotation; 026 027/** 028 * @author Olivier Lamy 029 * @since 3.0 030 */ 031public class ParameterAnnotationContent 032 extends AnnotatedField 033 implements Parameter 034{ 035 036 private String name; 037 038 private String alias; 039 040 private String property; 041 042 private String defaultValue; 043 044 private boolean required = false; 045 046 private boolean readonly = false; 047 048 private String className; 049 050 public ParameterAnnotationContent( String fieldName, String className ) 051 { 052 super( fieldName ); 053 this.className = className; 054 } 055 056 public ParameterAnnotationContent( String fieldName, String alias, String property, String defaultValue, 057 boolean required, boolean readonly, String className ) 058 { 059 this( fieldName, className ); 060 this.alias = alias; 061 this.property = property; 062 this.defaultValue = defaultValue; 063 this.required = required; 064 this.readonly = readonly; 065 } 066 067 public String name() 068 { 069 return name; 070 } 071 072 public void name( String name ) 073 { 074 this.name = name; 075 } 076 077 public String alias() 078 { 079 return alias; 080 } 081 082 public void alias( String alias ) 083 { 084 this.alias = alias; 085 } 086 087 public String property() 088 { 089 return property; 090 } 091 092 public void property( String property ) 093 { 094 this.property = property; 095 } 096 097 public String defaultValue() 098 { 099 return defaultValue; 100 } 101 102 public void defaultValue( String defaultValue ) 103 { 104 this.defaultValue = defaultValue; 105 } 106 107 public boolean required() 108 { 109 return required; 110 } 111 112 public void required( boolean required ) 113 { 114 this.required = required; 115 } 116 117 public boolean readonly() 118 { 119 return readonly; 120 } 121 122 public void readonly( boolean readonly ) 123 { 124 this.readonly = readonly; 125 } 126 127 public Class<? extends Annotation> annotationType() 128 { 129 return null; 130 } 131 132 public String getClassName() 133 { 134 return className; 135 } 136 137 public void setClassName( String className ) 138 { 139 this.className = className; 140 } 141 142 @Override 143 public String toString() 144 { 145 final StringBuilder sb = new StringBuilder(); 146 sb.append( super.toString() ); 147 sb.append( "ParameterAnnotationContent" ); 148 sb.append( "{name='" ).append( name ).append( '\'' ); 149 sb.append( ", alias='" ).append( alias ).append( '\'' ); 150 sb.append( ", property='" ).append( property ).append( '\'' ); 151 sb.append( ", defaultValue='" ).append( defaultValue ).append( '\'' ); 152 sb.append( ", required=" ).append( required ); 153 sb.append( ", readonly=" ).append( readonly ); 154 sb.append( '}' ); 155 return sb.toString(); 156 } 157 158 @Override 159 public boolean equals( Object o ) 160 { 161 if ( this == o ) 162 { 163 return true; 164 } 165 if ( !( o instanceof ParameterAnnotationContent ) ) 166 { 167 return false; 168 } 169 170 ParameterAnnotationContent that = (ParameterAnnotationContent) o; 171 172 if ( readonly != that.readonly ) 173 { 174 return false; 175 } 176 if ( required != that.required ) 177 { 178 return false; 179 } 180 181 if ( getFieldName() != null ? !getFieldName().equals( that.getFieldName() ) : that.getFieldName() != null ) 182 { 183 return false; 184 } 185 186 if ( alias != null ? !alias.equals( that.alias ) : that.alias != null ) 187 { 188 return false; 189 } 190 if ( defaultValue != null ? !defaultValue.equals( that.defaultValue ) : that.defaultValue != null ) 191 { 192 return false; 193 } 194 if ( property != null ? !property.equals( that.property ) : that.property != null ) 195 { 196 return false; 197 } 198 199 return true; 200 } 201 202 @Override 203 public int hashCode() 204 { 205 int result = alias != null ? alias.hashCode() : 0; 206 result = 31 * result + ( getFieldName() != null ? getFieldName().hashCode() : 0 ); 207 result = 31 * result + ( property != null ? property.hashCode() : 0 ); 208 result = 31 * result + ( defaultValue != null ? defaultValue.hashCode() : 0 ); 209 result = 31 * result + ( required ? 1 : 0 ); 210 result = 31 * result + ( readonly ? 1 : 0 ); 211 return result; 212 } 213}