package com.github.frtu.smartscan.spring.navigator;

import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;

/**
 * Represent one tag &lt;bean&gt;
 * 
 * @author fred
 */
public class BeanNav extends AbtractBaseNavigator {
	private BeanDefinition beanDefinition;

	private BeanNav(BeanDefinitionRegistry registry, BeanDefinition beanDefinition) {
		super(registry);
		this.beanDefinition = beanDefinition;
	}

	static BeanNav build(BeanDefinitionRegistry registry, String beanName) throws NoSuchBeanDefinitionException {
		BeanDefinition beanDefinition = registry.getBeanDefinition(beanName);
		return build(registry, beanDefinition);
	}

	static BeanNav build(BeanDefinitionRegistry registry, BeanDefinition beanDefinition) {
		return new BeanNav(registry, beanDefinition);
	}

	public boolean isClass(Class<?> clazz) {
		return isClass((clazz == null) ? null : clazz.getCanonicalName());
	}

	public boolean isClass(String className) {
		if (beanDefinition.getBeanClassName() != null) {
			return beanDefinition.getBeanClassName().equals(className);
		}
		return (className == null);
	}

	public BeanDefinition getBeanDefinition() {
		return beanDefinition;
	}

	public PropertyNav property(String propertyName) {
		PropertyValue propertyValue = beanDefinition.getPropertyValues().getPropertyValue(propertyName);
		return new PropertyNav(super.getRegistry(), propertyValue);
	}
}

@@ -418,16 +418,36 @@
 gator %7B%0A
+%09private String id;%0A
 %09private
@@ -478,16 +478,17 @@
 nition;%0A
+%09
 %0A%09privat
@@ -521,32 +521,43 @@
 gistry registry,
+ String id,
  BeanDefinition 
@@ -593,16 +593,32 @@
 istry);%0A
+%09%09this.id = id;%0A
 %09%09this.b
@@ -852,32 +852,42 @@
  build(registry,
+ beanName,
  beanDefinition)
@@ -976,24 +976,176 @@
 finition) %7B%0A
+%09%09return build(registry, null, beanDefinition);%0A%09%7D%0A%09%0A%09static BeanNav build(BeanDefinitionRegistry registry, String id, BeanDefinition beanDefinition) %7B%0A
 %09%09return new
@@ -1158,24 +1158,28 @@
 av(registry,
+ id,
  beanDefinit
@@ -1540,24 +1540,24 @@
 inition() %7B%0A
-
 %09%09return bea
@@ -1567,24 +1567,64 @@
 finition;%0A%09%7D
+%0A%09%0A%09public String id() %7B%0A%09%09return id;%0A%09%7D
 %0A%0A%09public Pr

Allow to get the <bean id=""/> attribute id when it's possible