/** * Creates a new form field instance within the given container. * * @param container * @param fieldClass */ private <T> T newInnerInstance(IFormField container, Class<T> fieldClass) { try { // try to create the field using its container T t = BeanUtility.createInstance(fieldClass, m_enclosingContext, container); if (t != null) { return t; } } catch (Exception t) { // NOSONAR } return ConfigurationUtility.newInnerInstance(m_enclosingContext, fieldClass); } }
public AbstractBeanPropertyOutput(Class beanType, String propertyName, ValueOutputToken source) { m_propertyName = propertyName; m_accumulator = new ArrayList<>(); m_source = source; // try { FastPropertyDescriptor desc = BeanUtility.getFastBeanInfo(beanType, null).getPropertyDescriptor(m_propertyName); m_propertyType = desc.getPropertyType(); } catch (Exception e) { throw new ProcessingException("property " + m_propertyName, e); } }
List<Class<?>> serviceInterfaces = BeanUtility.getInterfacesHierarchy(inspector.getService().getClass(), Object.class); Class topInterface = (!serviceInterfaces.isEmpty() ? serviceInterfaces.get(serviceInterfaces.size() - 1) : null); if (topInterface != null && topInterface.getPackage() != null && topInterface.getPackage().getName().contains(".common.")) {
private void exportExtensionProperties(Object o, IPropertyHolder target) { if (!(o instanceof IExtensibleObject)) { return; } for (IExtension<?> ex : ((IExtensibleObject) o).getAllExtensions()) { Class<?> dto = getDataAnnotationValue(ex.getClass()); if (dto != null && !Object.class.equals(dto)) { Object propertyTarget = target.getContribution(dto); Map<String, Object> fieldProperties = BeanUtility.getProperties(ex, AbstractFormField.class, new FormDataPropertyFilter()); BeanUtility.setProperties(propertyTarget, fieldProperties, false, null); } } }
Map<String, Object> props = BeanUtility.getProperties(this, AbstractForm.class, filter); storePropertiesToXml(xProps, props); Map<String, Object> extensionProps = BeanUtility.getProperties(ex, AbstractFormExtension.class, filter); if (extensionProps.isEmpty()) { continue;
private static void addTransformationHook(Class<?> refClass, IDeviceTransformationHook transformationHook) { synchronized (REGISTRY_LOCK) { int index = 0; int insertPos = 0; boolean added = false; for (TransformationHookRef ref : s_transformationHooks) { if (ref.getRefClass().equals(refClass)) { ref.getHooks().add(transformationHook); added = true; break; } if (refClass.isAssignableFrom(ref.getRefClass())) { int typeDistance = BeanUtility.computeTypeDistance(refClass, ref.getRefClass()); if (typeDistance > 0) { insertPos = index + 1; } } index++; } if (!added) { s_transformationHooks.add(insertPos, new TransformationHookRef(refClass, transformationHook)); } } }
IPropertyFilter filter = createPropertyFilter(); List<FastPropertyDescriptor> props = new LinkedList<>(); Collections.addAll(props, BeanUtility.getFastPropertyDescriptors(rowType, AbstractTableRowData.class, filter)); Set<Class<?>> contributions = BEANS.get(IInternalExtensionRegistry.class).getContributionsFor(rowType); for (Class<?> contribution : contributions) { Collections.addAll(props, BeanUtility.getFastPropertyDescriptors(contribution, Object.class, filter));
if (xProps != null) { Map<String, Object> props = loadPropertiesFromXml(xProps); BeanUtility.setProperties(this, props, true, null); BeanUtility.setProperties(extension, extensionProps, true, null);
private void importProperties(IPropertyHolder source, Object target, Class<?> stopClass, IPropertyFilter filter) { // local properties Map<String, Object> properties = BeanUtility.getProperties(source, stopClass, filter); if (!properties.isEmpty()) { removeNotSetProperties(source, properties); BeanUtility.setProperties(target, properties, false, null); } // properties of the extensions List<Object> allContributions = source.getAllContributions(); if (!allContributions.isEmpty()) { for (Object con : allContributions) { if (con instanceof IPropertyHolder) { IPropertyHolder data = (IPropertyHolder) con; Map<String, Object> extensionProperties = BeanUtility.getProperties(data, stopClass, filter); if (!extensionProperties.isEmpty()) { Object clientPart = getClientPartOfExtensionOrContributionRec(data, target); if (clientPart != null) { removeNotSetProperties(data, extensionProperties); BeanUtility.setProperties(clientPart, extensionProperties, false, null); } else { LOG.warn("cannot find extension for property data '{}' in form '{}'.", data.getClass().getName(), this.getClass().getName()); } } } } } }
@Override public void exportFormData(final AbstractFormData target) { Map<String, Object> properties = BeanUtility.getProperties(this, AbstractForm.class, new FormDataPropertyFilter()); BeanUtility.setProperties(target, properties, false, null); if (f != null) { properties = BeanUtility.getProperties(f, AbstractFormField.class, new FormDataPropertyFilter()); BeanUtility.setProperties(data, properties, false, null); exportExtensionProperties(f, data);
try { if (m_propertyDesc == null) { FastPropertyDescriptor test = BeanUtility.getFastBeanInfo(m_beans.getClass().getComponentType(), null).getPropertyDescriptor(m_propertyName); if (test != null && test.getReadMethod() != null) { m_propertyDesc = test; for (Object bean : m_beans) { if (bean != null) { m_propertyDesc = BeanUtility.getFastBeanInfo(bean.getClass(), null).getPropertyDescriptor(m_propertyName); break;
List<Class> interfaceHierarchy = new ArrayList<>(); for (Class c : serviceClass.getInterfaces()) { interfaceHierarchy.addAll(BeanUtility.getInterfacesHierarchy(c, Object.class)); interfaceHierarchy.addAll(BeanUtility.getInterfacesHierarchy(serviceClass, Object.class));
if (bean != null) { if (desc == null) { desc = BeanUtility.getFastBeanInfo(bean.getClass(), null).getPropertyDescriptor(m_propertyName);
FastPropertyDescriptor pd = BeanUtility.getFastBeanInfo(propertyBean.getClass(), null).getPropertyDescriptor(path[0]); Method getter = pd != null ? pd.getReadMethod() : null; if (getter != null) {
FastPropertyDescriptor pd = BeanUtility.getFastBeanInfo(bindBase.getClass(), null).getPropertyDescriptor(path[0]); if (terminal) { Method setter = pd != null ? pd.getWriteMethod() : null;