/** * {@inheritDoc} * * @param propertyName * the property name * @param propertyValue * the property value */ @Override public void set(String propertyName, Object propertyValue) { try { accessorFactory.createPropertyAccessor(propertyName, getClass()).setValue(this, propertyValue); } catch (NoSuchMethodException | InvocationTargetException | IllegalArgumentException | IllegalAccessException ex) { throw new ComponentException(ex, "Can not write component property " + propertyName + " on " + getClass().getName()); } } }
/** * {@inheritDoc} */ @Override protected void storeProperty(String propertyName, Object propertyValue) { try { getAccessorFactory().createPropertyAccessor(propertyName, getComponentContract()).setValue(delegate, propertyValue); } catch (IllegalAccessException | NoSuchMethodException ex) { throw new ComponentException(ex); } catch (InvocationTargetException ex) { if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } throw new ComponentException(ex.getCause()); } } }
/** * Accesses the underlying model property and sets its value. * <p> * {@inheritDoc} */ @Override protected void setConnecteeValue(Object aValue) { if (!ObjectUtils.equals(aValue, getConnecteeValue())) { try { accessor.setValue(getModelProvider().getModel(), aValue); } catch (IllegalAccessException | NoSuchMethodException ex) { throw new ConnectorBindingException(ex); } catch (InvocationTargetException ex) { if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } throw new ConnectorBindingException(ex.getCause()); } } } }
accessor.setValue(component, initValue); if (LOG.isDebugEnabled()) { LOG.debug("Init value assigned.");
/** * Create random entity * <p> * Uses pairs of field name and field values * - If pair is an array, select of value randomly * - If pair value is anything else, simply use this value * <p> * * @param entityContract * The entity contract * @param initializations * The list of pairs * @return The created entity */ protected <T extends IEntity> T createRandomEntity(Class<T> entityContract, Pair<String, Object>... initializations) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { T entity = createEntityInstance(entityContract); IAccessorFactory accessorFactory = getEntityFactory().getAccessorFactory(); for (Pair<String, Object> init : initializations) { Object value = init.getValue(); if (value instanceof Object[]) { value = randomSelection((Object[]) value); } IAccessor propertyAccessor = accessorFactory.createPropertyAccessor(init.getLeft(), entityContract); propertyAccessor.setValue(entity, value); } return entity; }
collectionConnector.getId(), targetContract).setValue(master, targetList); } catch (IllegalAccessException | NoSuchMethodException ex) {
String rawPropertyName = propertyDescriptor.getName() + IComponentDescriptor.RAW_SUFFIX; getAccessorFactory().createPropertyAccessor(rawPropertyName, getComponentDescriptor().getComponentContract()) .setValue(proxy, translatedValue); } catch (IllegalAccessException | NoSuchMethodException ex) { throw new ComponentException(ex);
accessorFactory.createPropertyAccessor( initializedAttribute.getKey(), queryComponent.getQueryContract()).setValue( queryComponent, accessorFactory
if (reversePropertyDescriptor instanceof IReferencePropertyDescriptor<?>) { accessorFactory.createPropertyAccessor(reversePropertyDescriptor.getName(), propertyDescriptor.getReferencedDescriptor().getElementDescriptor().getComponentContract()).setValue( value, proxy); } else if (reversePropertyDescriptor instanceof ICollectionPropertyDescriptor<?>) {
} else { getAccessorFactory().createPropertyAccessor(reversePropertyDescriptor.getName(), getComponentContract(((IComponent) propertyValue))).setValue(propertyValue, null); } else { getAccessorFactory().createPropertyAccessor(reversePropertyDescriptor.getName(), getComponentContract((IComponent) collectionElement)).setValue(collectionElement, null);
if (reversePropertyDescriptor instanceof IReferencePropertyDescriptor<?>) { accessorFactory.createPropertyAccessor(reversePropertyDescriptor.getName(), propertyDescriptor.getReferencedDescriptor().getElementDescriptor().getComponentContract()).setValue( value, null); } else if (reversePropertyDescriptor instanceof ICollectionPropertyDescriptor<?>) {