1 16 17 package org.springframework.beans.factory.config; 18 19 import org.springframework.util.Assert; 20 21 30 public class RuntimeBeanReference implements BeanReference { 31 32 private final String beanName; 33 34 private final boolean toParent; 35 36 private Object source; 37 38 39 45 public RuntimeBeanReference(String beanName) { 46 this(beanName, false); 47 } 48 49 57 public RuntimeBeanReference(String beanName, boolean toParent) { 58 Assert.hasText(beanName, "'beanName' must not be empty"); 59 this.beanName = beanName; 60 this.toParent = toParent; 61 } 62 63 64 public String getBeanName() { 65 return beanName; 66 } 67 68 72 public boolean isToParent() { 73 return toParent; 74 } 75 76 80 public void setSource(Object source) { 81 this.source = source; 82 } 83 84 public Object getSource() { 85 return source; 86 } 87 88 89 public boolean equals(Object other) { 90 if (this == other) { 91 return true; 92 } 93 if (!(other instanceof RuntimeBeanReference)) { 94 return false; 95 } 96 RuntimeBeanReference that = (RuntimeBeanReference) other; 97 return (this.beanName.equals(that.beanName) && this.toParent == that.toParent); 98 } 99 100 public int hashCode() { 101 int result = this.beanName.hashCode(); 102 result = 29 * result + (this.toParent ? 1 : 0); 103 return result; 104 } 105 106 public String toString() { 107 return '<' + getBeanName() + '>'; 108 } 109 110 } 111 | Popular Tags |