1 16 17 package org.springframework.beans.factory.support; 18 19 import org.springframework.beans.MutablePropertyValues; 20 import org.springframework.beans.factory.config.ConstructorArgumentValues; 21 import org.springframework.util.ObjectUtils; 22 23 43 public class ChildBeanDefinition extends AbstractBeanDefinition { 44 45 private final String parentName; 46 47 48 60 public ChildBeanDefinition(String parentName) { 61 super(); 62 this.parentName = parentName; 63 } 64 65 70 public ChildBeanDefinition(String parentName, MutablePropertyValues pvs) { 71 super(null, pvs); 72 this.parentName = parentName; 73 } 74 75 81 public ChildBeanDefinition( 82 String parentName, ConstructorArgumentValues cargs, MutablePropertyValues pvs) { 83 84 super(cargs, pvs); 85 this.parentName = parentName; 86 } 87 88 96 public ChildBeanDefinition( 97 String parentName, Class beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs) { 98 99 super(cargs, pvs); 100 this.parentName = parentName; 101 setBeanClass(beanClass); 102 } 103 104 113 public ChildBeanDefinition( 114 String parentName, String beanClassName, ConstructorArgumentValues cargs, MutablePropertyValues pvs) { 115 116 super(cargs, pvs); 117 this.parentName = parentName; 118 setBeanClassName(beanClassName); 119 } 120 121 126 public ChildBeanDefinition(ChildBeanDefinition original) { 127 super(original); 128 this.parentName = original.getParentName(); 129 } 130 131 132 135 public String getParentName() { 136 return this.parentName; 137 } 138 139 public void validate() throws BeanDefinitionValidationException { 140 super.validate(); 141 if (this.parentName == null) { 142 throw new BeanDefinitionValidationException("'parentName' must be set in ChildBeanDefinition"); 143 } 144 } 145 146 147 public boolean equals(Object other) { 148 if (this == other) { 149 return true; 150 } 151 if (!(other instanceof ChildBeanDefinition)) { 152 return false; 153 } 154 ChildBeanDefinition that = (ChildBeanDefinition) other; 155 return (ObjectUtils.nullSafeEquals(this.parentName, that.parentName) && super.equals(other)); 156 } 157 158 public int hashCode() { 159 return ObjectUtils.nullSafeHashCode(this.parentName) * 29 + super.hashCode(); 160 } 161 162 public String toString() { 163 StringBuffer sb = new StringBuffer ("Child bean with parent '"); 164 sb.append(this.parentName).append("': ").append(super.toString()); 165 return sb.toString(); 166 } 167 168 } 169 | Popular Tags |