Package org.springframework.beans.factory.config

# Class RuntimeBeanReference

java.lang.Object
org.springframework.beans.factory.config.RuntimeBeanReference

All Implemented Interfaces:
  `BeanMetadataElement`, `BeanReference`

public class RuntimeBeanReference extends Object implements BeanReference
Immutable placeholder class used for a property value object when it's a reference to another bean in the factory, to be resolved at runtime.

Author:
  Rod Johnson, Juergen Hoeller
See Also:
  - `BeanDefinition.getPropertyValues()`
  - `BeanFactory.getBean(String)`
  - `BeanFactory.getBean(Class)`

## Constructor Summary

Constructors
Constructor
Description
`RuntimeBeanReference(Class<?> beanType)`
Create a new RuntimeBeanReference to a bean of the given type.
`RuntimeBeanReference(Class<?> beanType, boolean toParent)`
Create a new RuntimeBeanReference to a bean of the given type, with the option to mark it as reference to a bean in the parent factory.
`RuntimeBeanReference(String beanName)`
Create a new RuntimeBeanReference to the given bean name.
`RuntimeBeanReference(String beanName, boolean toParent)`
Create a new RuntimeBeanReference to the given bean name, with the option to mark it as reference to a bean in the parent factory.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object other)`
`String`
`getBeanName()`
Return the requested bean name, or the fully-qualified type name in case of by-type resolution.
`Class<?>`
`getBeanType()`
Return the requested bean type if resolution by type is demanded.
`Object`
`getSource()`
Return the configuration source `Object` for this metadata element (may be `null`).
`int`
`hashCode()`
`boolean`
`isToParent()`
Return whether this is an explicit reference to a bean in the parent factory.
`void`
`setSource(Object source)`
Set the configuration source `Object` for this metadata element.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### RuntimeBeanReference

public RuntimeBeanReference(String beanName)
Create a new RuntimeBeanReference to the given bean name.

Parameters:
  `beanName` - name of the target bean

### RuntimeBeanReference

public RuntimeBeanReference(String beanName, boolean toParent)
Create a new RuntimeBeanReference to the given bean name, with the option to mark it as reference to a bean in the parent factory.

Parameters:
  `beanName` - name of the target bean
  `toParent` - whether this is an explicit reference to a bean in the parent factory

### RuntimeBeanReference

public RuntimeBeanReference(Class<?> beanType)
Create a new RuntimeBeanReference to a bean of the given type.

Parameters:
  `beanType` - type of the target bean
Since:
  5.2

### RuntimeBeanReference

public RuntimeBeanReference(Class<?> beanType, boolean toParent)
Create a new RuntimeBeanReference to a bean of the given type, with the option to mark it as reference to a bean in the parent factory.

Parameters:
  `beanType` - type of the target bean
  `toParent` - whether this is an explicit reference to a bean in the parent factory
Since:
  5.2

## Method Details

### getBeanName

public String getBeanName()
Return the requested bean name, or the fully-qualified type name in case of by-type resolution.

Specified by:
  `getBeanName` in interface `BeanReference`
See Also:
  - `getBeanType()`

### getBeanType

@Nullable public Class<?> getBeanType()
Return the requested bean type if resolution by type is demanded.

Since:
  5.2

### isToParent

public boolean isToParent()
Return whether this is an explicit reference to a bean in the parent factory.

### setSource

public void setSource(@Nullable Object source)
Set the configuration source `Object` for this metadata element.

The exact type of the object will depend on the configuration mechanism used.

### getSource

@Nullable public Object getSource()
Description copied from interface: `BeanMetadataElement`
Return the configuration source `Object` for this metadata element (may be `null`).

Specified by:
  `getSource` in interface `BeanMetadataElement`

### equals

public boolean equals(@Nullable Object other)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`