Unmarshals the property represented by the given property metadata and updates the target
object with the property value.

@param propertyMetadata
the property metadata
@param target
the target object to update
@throws Throwable
propagated
359387
private void unmarshalProperty(PropertyMetadata propertyMetadata, Object target)
      throws Throwable {
    unmarshalProperty(propertyMetadata, target, nativeEntity);
  }
956721
public function addAttributeMapping(PropertyMetadata $mapping)
    {
        if ($this->discriminatorAttribute !== null && $this->discriminatorAttribute === $mapping->attributeName) {
            throw MappingException::discriminatorAttributeConflict($this->name, $this->discriminatorAttribute);
        }

        if ($this->isEmbeddedDocument && $mapping->isCollectionType() && $mapping->strategy === PropertyMetadata::STORAGE_STRATEGY_ATOMIC_SET) {
            throw MappingException::atomicCollectionStrategyNotAllowed($this->name, $mapping->name);
        }

        $this->propertyMetadata[$mapping->name] = $mapping;

        if ($mapping->association !== null) {
            $this->associationMetadata[$mapping->name] = $mapping;
        }

        if ($mapping->generator !== null) {
            $this->generatedProperties[$mapping->name] = $mapping;
        }
    }
141413
public static void incrementVersion(Object target) {
        MetaClass metaClass = GroovySystem.getMetaClassRegistry().getMetaClass(target.getClass());
        if (metaClass.hasProperty(target, GormProperties.VERSION)!=null) {
            Object version = metaClass.getProperty(target, GormProperties.VERSION);
            if (version instanceof Long) {
                Long newVersion = (Long) version + 1;
                metaClass.setProperty(target, GormProperties.VERSION, newVersion);
            }
        }
    }
385560
public void setValueFor(Field target, Object value) {
        if(value == null && target.getType().isPrimitive()) {
            throw new ND4JIllegalStateException("Unable to set primitive field " + target + " of type " + target.getClass()
                    + " using null value!");
        }

        if(value != null) {
            value = ensureProperType(target, value);
        }

        if(isConfigProperties()){
            String propertyName = configFieldName();
            if(propertyName == null)
                propertyName = "config";
            Field f = null;
            Class<?> currClass = getClass();
            try{
                f = currClass.getDeclaredField(propertyName);
            } catch (NoSuchFieldException e){
                //OK, try superclass
            }
            while(f == null && currClass.getSuperclass() != null){
                currClass = currClass.getSuperclass();
                try{
                    f = currClass.getDeclaredField(propertyName);
                } catch (NoSuchFieldException e){
                    //OK, try superclass
                }
            }

            if(f == null){
                throw new IllegalStateException("Could not find field \"" + propertyName + "\" for class " + getClass().getName());
            }

            try {
                f.setAccessible(true);
                Object o = f.get(this);
                if(o == null){
                    //Null config class - try to create one...
                    Class<?> c = f.getType();
                    try {
                        o = c.newInstance();
                    } catch (InstantiationException e){
                        throw new RuntimeException("Error creating new instance of configuration object type " + c.getName(), e);
                    }
                    f.set(this, o);
                }
                target.set(o, value);
            } catch (IllegalAccessException e){
                throw new RuntimeException("Error setting configuration field \"" + propertyName + "\" for config field \"" + propertyName
                    + "\" on class " + getClass().getName());
            }

        } else {
            try {
                target.set(this,value);
            } catch (IllegalAccessException e) {
                throw new RuntimeException("Error setting property for function " + getClass().getName(), e);
            }
        }
    }
622141
public static void populate(Object target, Map properties) throws BeanMappingException {
        BeanMap map = BeanMap.create(target.getClass());
        map.populate(target, properties);
    }
696953
public static void setFieldValue(final Object target, final String name, final Object value) {
		Field field = FieldUtils.getDeclaredField(target.getClass(), name, true);

		if (field == null) {
			throw new IllegalArgumentException("Could not find field [" + name + "] on target [" + target + ']');
		}

		try {
			field.set(target, value);
		} catch (IllegalAccessException e) {
			throw new ImpossibleException(e);
		}
	}
1085468
public static void setProperty(Object messageArgument, Class senderClass, Object receiver, String messageName) throws Throwable {
        try {
            if (receiver==null) receiver= NullObject.getNullObject();
            InvokerHelper.setProperty(receiver, messageName, messageArgument);
        } catch (GroovyRuntimeException gre) {
            throw unwrap(gre);
        }
    }
814019
public function __setSerialisablePropertyMap($propertyMap, $ignoreNoneWritableProperties = false) {
        $propertyAccessors = $this->__findSerialisablePropertyAccessors();

        $noneWritables = array();
        foreach ($propertyMap as $inputPropertyName => $propertyValue) {
            $propertyName = strtolower($inputPropertyName);

            // If we get a match, call the appropriate function
            if (isset ($propertyAccessors [$propertyName]) && isset ($propertyAccessors [$propertyName] ["set"])) {
                $accessor = $propertyAccessors [$propertyName] ["set"];
                if ($accessor instanceof \ReflectionMethod) {
                    if ($accessor->isPublic())
                        $accessor->invoke($this, $propertyValue);
                    else if ($accessor->isProtected()) {
                        $methodName = "set" . $propertyName;
                        $this->$methodName ($propertyValue);
                    } else {
                        if (!$ignoreNoneWritableProperties)
                            throw new PropertyNotWritableException (get_class($this), $propertyName);
                    }
                } else if ($accessor instanceof \ReflectionProperty) {
                    if ($accessor->isPublic())
                        $accessor->setValue($this, $propertyValue);
                    else if ($accessor->isProtected()) {
                        $propertyName = $accessor->getName();
                        $this->$propertyName = $propertyValue;
                    } else {
                        if (!$ignoreNoneWritableProperties)
                            throw new PropertyNotWritableException (get_class($this), $propertyName);
                    }
                }
            } else {
                // If none writable properties ignored, instead add them to an array for return for processing
                // higher if required, else throw exceptions.
                if ($ignoreNoneWritableProperties) {
                    $noneWritables [$inputPropertyName] = $propertyValue;
                } else {
                    throw new PropertyNotWritableException (get_class($this), $propertyName);
                }
            }

        }

        return $noneWritables;
    }
1161042
@SuppressWarnings({ "rawtypes", "unchecked" })
	private void setAttribute(NodeConfig nodeConfig, Object targetObject) throws UnmarshalException {
		Class targetClass = targetObject.getClass();
		List attributes = nodeConfig.getAttribute();
		if (attributes != null && attributes.size() > 0) {
			for (Iterator iterAttr = attributes.iterator(); iterAttr.hasNext();) {
				AttributeConfig attribute = (AttributeConfig) iterAttr.next();
				String methodName = Constant.SET_PREFIX + StringUtils.capitalize(attribute.getName());
				try {
					Method method = targetClass.getMethod(methodName, String.class);
					if (method != null) {
						setMethod(method, targetObject, attribute.getValue());
					}
				} catch (NoSuchMethodException e) {
					if (validation) {
						throw new UnmarshalException(e);
					}
				}
			}
		}
	}
372657
public void setColumnMetadata(java.util.Collection<ColumnMetadata> columnMetadata) {
        if (columnMetadata == null) {
            this.columnMetadata = null;
            return;
        }

        this.columnMetadata = new java.util.ArrayList<ColumnMetadata>(columnMetadata);
    }
385935
private function collectAttributeTypeMetadata(
        PropertyMetadataBuilder $metadata,
        Attribute $attribute
    ) : void {
        $type = $attribute->type;

        // handle the case if the property type is mixed
        if ('mixed' === $type) {
            return;
        }

        if ($attribute->required) {
            $metadata->withBeingRequired();
        }

        // Evaluate type

        // Checks if the property has array<type>
        if (false !== $pos = strpos($type, '<')) {
            $arrayType = substr($type, $pos + 1, -1);

            $metadata->withType(new ArrayType(new MixedType(), $this->createTypeFromName($arrayType)));

            return;
        }

        // Checks if the property has type[]
         if (false !== $pos = strrpos($type, '[')) {
            $arrayType = substr($type, 0, $pos);

            $metadata->withType(new ArrayType(new MixedType(), $this->createTypeFromName($arrayType)));

            return;
        }

        $metadata->withType($this->createTypeFromName($attribute->type));
    }
402907
function isSerializable(target, property) {
    // get the class constructor
    const constr = target.constructor;
    // retrieve the current metadata
    const metadata = Reflect.getMetadata(METADATA_doNotSerialize, constr) || {};
    // if doNotSerialize is defined, don't serialize!
    return !metadata.hasOwnProperty(property);
}
1307630
private void applyPropertyOverride(PropertyMetadata propertyMetadata) {
    String name = propertyMetadata.getName();
    Property override = entityMetadata.getPropertyOverride(name);
    if (override != null) {
      String mappedName = override.name();
      if (mappedName != null && mappedName.trim().length() > 0) {
        propertyMetadata.setMappedName(mappedName);
      }
      propertyMetadata.setIndexed(override.indexed());
      propertyMetadata.setOptional(override.optional());
    }

  }
868500
function(object, propertyMeta, property) {
        var that = this;

        object['_' + property] = undefined;

        // Adjust property 'type' and 'default fields
        if (_.isArray(propertyMeta)) {
            propertyMeta = propertyMeta.length === 3 || !_.isSimpleObject(propertyMeta[1])
                ? { type: [propertyMeta[0], propertyMeta[2] || {}], default: propertyMeta[1] }
                : { type: propertyMeta }
        }
        else if (!_.isSimpleObject(propertyMeta)) {
            propertyMeta = { default: propertyMeta }
        }

        // Sets default property methods
        if (!('methods' in propertyMeta)) {
            propertyMeta.methods = ['get', 'set', 'has', 'is', 'clear', 'remove']
        }

        object.__setPropertyParam(property, {});

        // Process property meta data by options processors
        _.each(propertyMeta, function(data, option) {
            if (!(option in that._options)) {
                return;
            }

            var processor = that._options[option];

            if (_.isString(processor)) {
                processor = meta(processor);
            }

            processor.process(object, data, property);
        });
    }
1019110
private void processVersionField(PropertyMetadata propertyMetadata) {
    Class<?> dataClass = propertyMetadata.getDeclaredType();
    if (!long.class.equals(dataClass)) {
      String messageFormat = "Field %s in class %s must be of type %s";
      throw new EntityManagerException(String.format(messageFormat,
          propertyMetadata.getField().getName(), entityClass, long.class));
    }
    entityMetadata.setVersionMetadata(propertyMetadata);
  }
709844
public void init(Regex annotation, PropertyMetadata propertyMetadata)
    {
        m_propertyMetadata = propertyMetadata;
        m_pattern = java.util.regex.Pattern.compile(annotation.pattern());
        m_message = annotation.message();
    }
215374
private void unmarshalProperties() throws Throwable {
    Collection<PropertyMetadata> propertyMetadataCollection = entityMetadata
        .getPropertyMetadataCollection();
    for (PropertyMetadata propertyMetadata : propertyMetadataCollection) {
      unmarshalProperty(propertyMetadata, entity);
    }
  }