Marshals the given bean into the given map.
@param bean the bean
@return the content builder
@throws StorageException when a storage problem occurs while storing a bean
187941
public static XContentBuilder marshall(RoleMembershipBean bean) throws StorageException {
        try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
            preMarshall(bean);
            builder
                .startObject()
                    .field("id", bean.getId())
                    .field("organizationId", bean.getOrganizationId())
                    .field("roleId", bean.getRoleId())
                    .field("userId", bean.getUserId())
                    .field("createdOn", bean.getCreatedOn().getTime())
                .endObject();
            postMarshall(bean);
            return builder;
        } catch (IOException e) {
            throw new StorageException(e);
        }
    }
272017
private void beanToBean(Object providerBean, Object destBean) {
		valueProviderToBean(new BeanValueProvider(providerBean, this.copyOptions.ignoreCase, this.copyOptions.ignoreError), destBean);
	}
334534
@Override
	public void setBeanProvider(final BeanProvider beanProvider) {
		if (isLocked() && beanProvider != null && !(beanProvider instanceof Serializable)) {
			throw new SystemException(
					"Unable to store bean provider in user's session as it is not serializable: " + beanProvider.
					getClass());
		}

		getOrCreateComponentModel().setBeanProvider(beanProvider);
		String beanProperty = getBeanProperty();

		if (beanProperty == null) {
			setBeanProperty(".");
		}

		// Remove values in scratch map
		removeBeanFromScratchMap();
	}
398544
public static Map describe(Object src) throws BeanMappingException {
        BeanMap map = BeanMap.create(src.getClass());
        return map.describe(src);
    }
981997
public static ApiDefinitionBean unmarshallApiDefinition(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        ApiDefinitionBean bean = new ApiDefinitionBean();
        bean.setData(asString(source.get("data")));
        postMarshall(bean);
        return bean;
    }
330303
@SuppressWarnings("unchecked")
    public Workbook create(Object bean) {
        optionsSheet = sheet.getWorkbook().getSheet("Options");

        for (val field : bean.getClass().getDeclaredFields()) {
            if (Fields.shouldIgnored(field, ExcelColIgnore.class)) continue;
            if (field.getName().endsWith("Tmpl")) continue;

            processExcelCellAnnotation(field, bean);
            processExcelRowsAnnotation(field, bean);
        }

        fixRowsHeight();
        PoiUtil.removeOtherSheets(sheet);


        val wb = sheet.getWorkbook();
        wb.setPrintArea(0, 0, PoiUtil.findMaxCol(sheet), 0, sheet.getLastRowNum());
        return wb;
    }
66180
public JettyServiceBuilder bean(Object bean, boolean managed) {
        beans.add(new Bean(bean, managed));
        return this;
    }
663320
public static Map<String, String> mapBean(final Object bean, 
        final Set<String> excludes)
        {
        excludes.add("getClass");
        final Object[] emptyParams = new Object[0];
        final Method[] methods = bean.getClass().getMethods();
        
        final Map<String, String> fields = new HashMap<String, String>();
        for (final Method method : methods) {
            if (method.getParameterTypes().length > 0) {
                continue;
            }
            final String name = method.getName();
            if (name.startsWith("get") && !excludes.contains(name))  {
                LOG.debug("Calling method: {}", name);
                try {
                    final Object returnVal = method.invoke(bean, emptyParams);
                    LOG.debug("Got: {}", returnVal);
                    final String beanValue = String.valueOf(returnVal);
                    final String beanData = 
                        StringUtils.substringAfter(name, "get");
                    fields.put(StringUtils.uncapitalize(beanData), beanValue);
                }
                catch (final IllegalAccessException e) {
                    LOG.debug("Could not access method: "+
                        method.toGenericString(), e);
                }
                catch (final InvocationTargetException e) {
                    LOG.debug("Could not invoke method: "+
                        method.toGenericString(), e);
                }
            }
        }
        return fields;
    }
908024
public static Map<String, Object> beanToMap(Object bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
		return beanToMap(bean, new LinkedHashMap<String, Object>(), isToUnderlineCase, ignoreNullValue);
	}
798592
public Object toBean(final String group, Object bean) {
		return BeanUtil.fillBean(bean, new ValueProvider<String>(){

			@Override
			public Object value(String key, Type valueType) {
				final String value = getByGroup(key, group);
//				if (null != value) {
//					log.debug("Parse setting to object field [{}={}]", key, value);
//				}
				return value;
			}

			@Override
			public boolean containsKey(String key) {
				return null != getByGroup(key, group);
			}
		}, CopyOptions.create());
	}
525724
public static BeanMap create(Class srcClass) {
        BeanMappingObject describeConfig = BeanMappingConfigHelper.getInstance().getBeanMapObject(srcClass, Map.class,
                                                                                                  true);

        BeanMappingObject populateConfig = BeanMappingConfigHelper.getInstance().getBeanMapObject(Map.class, srcClass,
                                                                                                  true);
        return new BeanMap(describeConfig, populateConfig);
    }
1132582
public static XContentBuilder marshall(PolicyDefinitionBean bean) throws StorageException {
        try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
            preMarshall(bean);
            builder
                .startObject()
                    .field("id", bean.getId())
                    .field("name", bean.getName())
                    .field("description", bean.getDescription())
                    .field("form", bean.getForm())
                    .field("formType", bean.getFormType())
                    .field("icon", bean.getIcon())
                    .field("pluginId", bean.getPluginId())
                    .field("policyImpl", bean.getPolicyImpl())
                    .field("deleted", bean.isDeleted());

            Set<PolicyDefinitionTemplateBean> templates = bean.getTemplates();
            if (templates != null) {
                builder.field("templates").startArray();
                for (PolicyDefinitionTemplateBean template : templates) {
                    builder.startObject();
                    builder.field("language", template.getLanguage());
                    builder.field("template", template.getTemplate());
                    builder.endObject();
                }
                builder.endArray();
            }

            builder.endObject();
            postMarshall(bean);
            return builder;
        } catch (IOException e) {
            throw new StorageException(e);
        }
    }
542031
public static OrganizationBean unmarshallOrganization(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        OrganizationBean bean = new OrganizationBean();
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setModifiedOn(asDate(source.get("modifiedOn")));
        bean.setModifiedBy(asString(source.get("modifiedBy")));
        postMarshall(bean);
        return bean;
    }
611264
public <T> InternalEjbDescriptor<T> get(String beanName) {
        return cast(ejbByName.get(beanName));
    }
1259794
public static Map<String, Method> getReadMethods(Object bean) {
		Class<? extends Object> beanClass = bean.getClass();
		try {
			Map<String, Method> readMethods = new HashMap<>();
			final BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
			final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
			if (propertyDescriptors != null) {
				for (final PropertyDescriptor propertyDescriptor : propertyDescriptors) {
					if (propertyDescriptor != null) {
						final String name = propertyDescriptor.getName();
						final Method readMethod = propertyDescriptor.getReadMethod();

						if (readMethod != null) {
							readMethods.put(name, readMethod);
						}
					}
				}
			}
			return readMethods;
		} catch (final IntrospectionException e) {
			throw new BeanWrapperException("Failed to initialize bean wrapper on " + beanClass, e);
		}
	}
1316129
public static ClientBean unmarshallClient(Map<String, Object> source) {
        if (source == null) {
            return null;
        }
        ClientBean bean = new ClientBean();
        bean.setId(asString(source.get("id")));
        bean.setName(asString(source.get("name")));
        bean.setDescription(asString(source.get("description")));
        bean.setCreatedBy(asString(source.get("createdBy")));
        bean.setCreatedOn(asDate(source.get("createdOn")));
        postMarshall(bean);
        return bean;
    }
612184
public Map<String, Object> write(Bean bean) {
        JodaBeanUtils.notNull(bean, "bean");
        return writeBean(bean, bean.getClass());
    }