Example usage for org.springframework.ide.eclipse.beans.core.internal.model BeansModelUtils getBeanClass

List of usage examples for org.springframework.ide.eclipse.beans.core.internal.model BeansModelUtils getBeanClass

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.beans.core.internal.model BeansModelUtils getBeanClass.

Prototype

public static String getBeanClass(IBean bean, IModelElement context) 

Source Link

Document

Returns the given bean's class name.

Usage

From source file:org.dozer.eclipse.plugin.sourcepage.util.DozerPluginUtils.java

protected static IBean getDozerBeanFromBeans(Set<IBean> beans, String mappingFileName) {
    //get first bean that uses our mapping file
    for (IBean bean : beans) {
        String className = BeansModelUtils.getBeanClass(bean, null);
        if ("org.dozer.util.mapping.DozerBeanMapper".equals(className)) {
            //get mappingFiles-property
            IBeanProperty mappingFilesProperty = bean.getProperty("mappingFiles");
            if (mappingFilesProperty == null)
                continue;

            BeansList mappingFilesPropertyValues = (BeansList) mappingFilesProperty.getValue();
            IModelElement[] modelElements = mappingFilesPropertyValues.getElementChildren();

            //find reference to our mapping file
            for (IModelElement modelElement : modelElements) {
                String configFilePath = ((BeansTypedString) modelElement).getString();
                File configFile = new File(configFilePath);

                //property with mapping file found, so this is our target bean
                if (mappingFileName.equals(configFile.getName())) {
                    return bean;
                }//from w w w  . j  av  a  2 s  .c o m
            }
        }
    }

    return null;
}