001/* $Id: Address.java 1102402 2011-05-12 18:03:26Z simonetripodi $ 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.commons.digester3.annotations.employee; 019 020import org.apache.commons.digester3.annotations.rules.BeanPropertySetter; 021import org.apache.commons.digester3.annotations.rules.ObjectCreate; 022import org.apache.commons.digester3.annotations.rules.SetProperty; 023import org.apache.commons.digester3.annotations.rules.SetTop; 024 025/** 026 * @since 2.1 027 */ 028@ObjectCreate( pattern = "employee/address" ) 029public class Address 030{ 031 032 @BeanPropertySetter( pattern = "employee/address/city" ) 033 private String city; 034 035 @BeanPropertySetter( pattern = "employee/address/state" ) 036 private String state; 037 038 @BeanPropertySetter( pattern = "employee/address/street" ) 039 private String street; 040 041 @SetProperty( pattern = "employee/address", attributeName = "place" ) 042 private String type; 043 044 @BeanPropertySetter( pattern = "employee/address/zip-code" ) 045 private String zipCode; 046 047 @SetTop( pattern = "employee/address" ) 048 public void setEmployee( Employee employee ) 049 { 050 employee.addAddress( this ); 051 } 052 053 public String getCity() 054 { 055 return this.city; 056 } 057 058 public void setCity( String city ) 059 { 060 this.city = city; 061 } 062 063 public String getState() 064 { 065 return this.state; 066 } 067 068 public void setState( String state ) 069 { 070 this.state = state; 071 } 072 073 public String getStreet() 074 { 075 return this.street; 076 } 077 078 public void setStreet( String street ) 079 { 080 this.street = street; 081 } 082 083 public String getType() 084 { 085 return this.type; 086 } 087 088 public void setType( String type ) 089 { 090 this.type = type; 091 } 092 093 public String getZipCode() 094 { 095 return this.zipCode; 096 } 097 098 public void setZipCode( String zipCode ) 099 { 100 this.zipCode = zipCode; 101 } 102 103 @Override 104 public boolean equals( Object obj ) 105 { 106 if ( this == obj ) 107 return true; 108 if ( obj == null ) 109 return false; 110 if ( getClass() != obj.getClass() ) 111 return false; 112 Address other = (Address) obj; 113 if ( this.city == null ) 114 { 115 if ( other.getCity() != null ) 116 return false; 117 } 118 else if ( !this.city.equals( other.getCity() ) ) 119 return false; 120 if ( this.state == null ) 121 { 122 if ( other.getState() != null ) 123 return false; 124 } 125 else if ( !this.state.equals( other.getState() ) ) 126 return false; 127 if ( this.street == null ) 128 { 129 if ( other.getStreet() != null ) 130 return false; 131 } 132 else if ( !this.street.equals( other.getStreet() ) ) 133 return false; 134 if ( this.type == null ) 135 { 136 if ( other.getType() != null ) 137 return false; 138 } 139 else if ( !this.type.equals( other.getType() ) ) 140 return false; 141 if ( this.zipCode == null ) 142 { 143 if ( other.getZipCode() != null ) 144 return false; 145 } 146 else if ( !this.zipCode.equals( other.getZipCode() ) ) 147 return false; 148 return true; 149 } 150 151 @Override 152 public String toString() 153 { 154 return "Address [city=" + city + ", state=" + state + ", street=" + street + ", type=" + type + ", zipCode=" 155 + zipCode + "]"; 156 } 157 158}