/* (non-Javadoc)
@see org.jboss.as.controller.AttributeValueCorrector#correct(org.jboss.dmr.ModelNode, org.jboss.dmr.ModelNode)
9103
@Override
    public ModelNode correct(ModelNode newValue, ModelNode currentValue) {
        if(newValue.getType() == ModelType.UNDEFINED) {
            return newValue;
        }
        if(newValue.getType() != ModelType.OBJECT || currentValue.getType() != ModelType.OBJECT) {
            return newValue;
        }
        final Set<String> operationKeys = newValue.keys();
        final Set<String> currentKeys = currentValue.keys();
        for(String currentKey : currentKeys) {
            if(!operationKeys.contains(currentKey)) {
                newValue.get(currentKey).set(currentValue.get(currentKey));
            }
        }
        return newValue;
    }
530806
public static Boolean getAnnotationAttributeAsBoolean(ModelWithAnnotation model, Class<? extends Annotation> annotation, AnnotationAttributeType attribute, Boolean defaultValue) {
		return getAnnotationAttribute(model, annotation, attribute, defaultValue, new OnAnnotationAttributeListener<Boolean>() {

			@Override
			public Boolean onFound(String value) {
				return Boolean.valueOf(value);
			}
		});
	}
1033004
private void setValueFromObject(org.w3c.dom.Node n) {
        DOMProcessing.trimNode(n);
        try {
            setValue(DOMProcessing.writeToString(n));
        } catch (TransformerConfigurationException e) {
            setValue(n.toString());  // TODO: not the most compelling handling
        } catch (TransformerException e) {
            setValue(n.toString()); //TODO: not the most compelling handling
        }
    }
953417
@Override
    public ModelNode resolveValue(ExpressionResolver resolver, ModelNode value) throws OperationFailedException {

        // Pass non-OBJECT values through the superclass so it can reject weird values and, in the odd chance
        // that's how this object is set up, turn undefined into a default list value.
        ModelNode superResult = value.getType() == ModelType.OBJECT ? value : super.resolveValue(resolver, value);

        // If it's not an OBJECT (almost certainly UNDEFINED), then nothing more we can do
        if (superResult.getType() != ModelType.OBJECT) {
            return superResult;
        }

        // Resolve each field.
        // Don't mess with the original value
        ModelNode clone = superResult == value ? value.clone() : superResult;
        ModelNode result = new ModelNode();
        for (AttributeDefinition field : valueTypes) {
            String fieldName = field.getName();
            if (clone.has(fieldName)) {
                result.get(fieldName).set(field.resolveValue(resolver, clone.get(fieldName)));
            } else {
                // Input doesn't have a child for this field.
                // Don't create one in the output unless the AD produces a default value.
                // TBH this doesn't make a ton of sense, since any object should have
                // all of its fields, just some may be undefined. But doing it this
                // way may avoid breaking some code that is incorrectly checking node.has("xxx")
                // instead of node.hasDefined("xxx")
                ModelNode val = field.resolveValue(resolver, new ModelNode());
                if (val.isDefined()) {
                    result.get(fieldName).set(val);
                }
            }
        }
        // Validate the entire object
        getValidator().validateParameter(getName(), result);
        return result;
    }
1228672
boolean applyDomainModel(ModelNode result) {
        if(! result.hasDefined(ModelDescriptionConstants.RESULT)) {
            return false;
        }
        final List<ModelNode> bootOperations= result.get(ModelDescriptionConstants.RESULT).asList();
        return callback.applyDomainModel(bootOperations);
    }
1033
def _assert_correct_model(model_to_check, model_reference, obj_name):
        
        if not issubclass(model_to_check, model_reference):
            raise ConfigurationException('The %s model must be a subclass of %s'
                                         % (obj_name, model_reference.__name__))
801182
@Override
    public boolean isLocalNode(INodeDesc node) {
        final String fwkNodeName = getFrameworkNodeName();
        return fwkNodeName.equals(node.getNodename());
    }
668913
public void setModel (PropertySheetModel pm)
  {
    if (pm instanceof org.apache.ojb.tools.mapping.reversedb.DBFKRelation)
    {
      this.aRelation = (org.apache.ojb.tools.mapping.reversedb.DBFKRelation)pm;
      this.readValuesFromReference();
    }
    else
      throw new IllegalArgumentException();    
  }
602297
private void assignValue(SimpleNode node, RelationQueryNode queryNode) {
        if (node.getId() == JJTSTRINGLITERAL) {
            queryNode.setStringValue(unescapeQuotes(node.getValue()));
        } else if (node.getId() == JJTDECIMALLITERAL) {
            queryNode.setDoubleValue(Double.parseDouble(node.getValue()));
        } else if (node.getId() == JJTDOUBLELITERAL) {
            queryNode.setDoubleValue(Double.parseDouble(node.getValue()));
        } else if (node.getId() == JJTINTEGERLITERAL) {
            // if this is an expression that contains position() do not change
            // the type.
            if (queryNode.getValueType() == QueryConstants.TYPE_POSITION) {
                queryNode.setPositionValue(Integer.parseInt(node.getValue()));
            } else {
                queryNode.setLongValue(Long.parseLong(node.getValue()));
            }
        } else {
            exceptions.add(new InvalidQueryException("Unsupported literal type:" + node.toString()));
        }
    }
286488
protected function isValidScalar(ValueNodeInterface $node): void
    {
        $locationType = $this->context->getInputType();

        if (null === $locationType) {
            return;
        }

        $type = getNamedType($locationType);

        if (!($type instanceof ScalarType)) {
            $didYouMean = $this->getEnumTypeSuggestion($type, $node) ?? null;

            $this->context->reportError(
                new ValidationException(
                    badValueMessage((string)$locationType, printNode($node), $didYouMean),
                    [$node]
                )
            );

            return;
        }

        // Scalars determine if a literal value is valid via parseLiteral() which
        // may throw or return an invalid value to indicate failure.
        try {
            $result = $type->parseLiteral($node, null/* $variables */);

            if (null === $result) {
                $this->context->reportError(
                    new ValidationException(
                        badValueMessage((string)$locationType, printNode($node)),
                        [$node]
                    )
                );
            }
        } catch (\Exception $ex) {
            // Ensure a reference to the original error is maintained.
            $this->context->reportError(
                new ValidationException(
                    badValueMessage((string)$locationType, printNode($node), $ex->getMessage()),
                    [$node],
                    null,
                    null,
                    null,
                    null,
                    $ex
                )
            );
        }
    }
1259889
void rejectAttributes(RejectedAttributesLogContext rejectedAttributes, ModelNode attributeValue) {
        for (RejectAttributeChecker checker : checks) {
            rejectedAttributes.checkAttribute(checker, name, attributeValue);
        }
    }
1144642
private Set<String> checkModel(final ModelNode model, TransformationContext context) throws OperationFailedException {
        final Set<String> attributes = new HashSet<String>();
        AttributeTransformationRequirementChecker checker;
        for (final String attribute : attributeNames) {
            if (model.hasDefined(attribute)) {
                if (attributeCheckers != null && (checker = attributeCheckers.get(attribute)) != null) {
                    if (checker.isAttributeTransformationRequired(attribute, model.get(attribute), context)) {
                        attributes.add(attribute);
                    }
                } else if (SIMPLE_EXPRESSIONS.isAttributeTransformationRequired(attribute, model.get(attribute), context)) {
                    attributes.add(attribute);
                }
            }
        }
        return attributes;
    }
540094
@SuppressWarnings("unchecked")
    public T fromDMR(String keyValue, ModelNode modelNode) throws Exception {

        if (isBaseTypeAdapter()) return convertToBaseType(modelNode);

        ModelNode actualPayload = null;

        if (ModelType.OBJECT.equals(modelNode.getType())) {
            actualPayload = modelNode;
        }
       /* else if(ModelType.PROPERTY.equals(modelNode.getType()))
        {
            final Property property = modelNode.asProperty();
            actualPayload = property.getValue();
        }*/
        else {
            throw new IllegalArgumentException("Unsupported ModelType " + modelNode.getType() + ": " + modelNode);
        }

        ClassInfo clazz = index.getClassByName(DotName.createSimple(getType().getCanonicalName()));

        T entity = null;
        boolean implicitKey = clazz.annotations().containsKey(IndexFactory.IMPLICIT_META);

        if (implicitKey) {
            // implicit (aka singleton) resource
            Constructor<?> ctor = getType().getConstructor();
            entity = (T) ctor.newInstance();
        } else {
            // explicit (regular) resource
            entity = (T) getType().getConstructor(String.class)
                    .newInstance(keyValue);
        }


        for (MethodInfo method : clazz.methods()) {
            if (method.hasAnnotation(IndexFactory.BINDING_META)) {

                Method getter = entity.getClass().getMethod(method.name());
                Class<?> propertyType = getter.getReturnType();

                ModelNodeBinding binding = getter.getDeclaredAnnotation(ModelNodeBinding.class);
                String detypedName = binding.detypedName();

                ModelNode dmrPayload = actualPayload.get(detypedName);


                // EXPRESSIONS
                if(ModelType.EXPRESSION == dmrPayload.getType()) {

                    ValueExpression expression = dmrPayload.asExpression();

                    ((Map)entity).put(method.name(), expression.getExpressionString());

                    continue; // expression have precedence over real values

                }


                // VALUES
                ModelType dmrType = Types.resolveModelType(propertyType);
                if (dmrType == ModelType.LIST) {
                    new ListTypeAdapter().fromDmr(entity, method.name(), dmrType, propertyType, dmrPayload);
                } else if (dmrType == ModelType.OBJECT) {
                    new MapTypeAdapter().fromDmr(entity, method.name(), dmrType, propertyType, dmrPayload);
                } else {
                    new SimpleTypeAdapter().fromDmr(entity, method.name(), dmrType, propertyType, dmrPayload);
                }


            }
        }
        return entity;
    }
455736
private void visitComponentModel(final ObjectGraphNode node) {
		ComponentModel model = (ComponentModel) node.getValue();
		ComponentModel sharedModel = null;

		List<Field> fieldList = ReflectionUtil.getAllFields(node.getValue(), true, false);
		Field[] fields = fieldList.toArray(new Field[fieldList.size()]);

		for (int i = 0; i < fields.length; i++) {
			if (ComponentModel.class.equals(fields[i].getDeclaringClass())
					&& "sharedModel".equals(fields[i].getName())) {
				sharedModel = (ComponentModel) readField(fields[i], model);
			}
		}

		visitComplexTypeWithDiff(node, sharedModel);
	}
1099736
protected void validateAnnotationValue(T originatingElement, String annotationName, T member, String memberName, Object resolvedValue) {
        final AnnotatedElementValidator elementValidator = getElementValidator();
        if (elementValidator != null && !erroneousElements.contains(member)) {
            final boolean shouldValidate = !(annotationName.equals(AliasFor.class.getName())) &&
                                           (!(resolvedValue instanceof String) || !resolvedValue.toString().contains("${"));
            if (shouldValidate) {
                final Set<String> errors = elementValidator.validatedAnnotatedElement(new AnnotatedElement() {

                    AnnotationMetadata metadata = buildDeclared(member);

                    @Nonnull
                    @Override
                    public String getName() {
                        return memberName;
                    }

                    @Override
                    public AnnotationMetadata getAnnotationMetadata() {
                        return metadata;
                    }
                }, resolvedValue);

                if (CollectionUtils.isNotEmpty(errors)) {
                    erroneousElements.add(member);
                    for (String error : errors) {
                        error = "@" + NameUtils.getSimpleName(annotationName) + "." + memberName + ": " + error;
                        addError(originatingElement, error);
                    }
                }
            }
        }
    }
841969
@SuppressWarnings("unchecked")
    private void setValue(List<Element> elements, String attrName, Object pojo,
                          CustomPropertyDescriptor field) {
        XmlNode attrXmlNode = field.getAnnotation(XmlNode.class);
        log.debug("要赋值的fieldName为{}", field.getName());
        final XmlTypeConvert convert = XmlTypeConverterUtil.resolve(attrXmlNode, field);

        Class<? extends Collection> collectionClass;
        Class<? extends Collection> real = (Class<? extends Collection>) field.getRealType();

        if (attrXmlNode != null) {
            collectionClass = attrXmlNode.arrayType();
            if (!collectionClass.equals(real) && !real.isAssignableFrom(collectionClass)) {
                log.warn("用户指定的集合类型[{}]不是字段的实际集合类型[{}]的子类，使用字段的实际集合类型", collectionClass, real);
                collectionClass = real;
            }
        } else {
            collectionClass = real;
        }

        if (!StringUtils.isEmpty(attrXmlNode.arrayRoot()) && !elements.isEmpty()) {
            elements = elements.get(0).elements(attrXmlNode.arrayRoot());
        }

        //将数据转换为用户指定数据
        List<?> list = elements.stream().map(d -> convert.read(d, attrName))
            .collect(Collectors.toList());

        if (!trySetValue(list, pojo, field, collectionClass)) {
            //使用注解标记的类型赋值失败并且注解的集合类型与实际字段类型不符时尝试使用字段实际类型赋值
            if (!trySetValue(list, pojo, field, real)) {
                log.warn("无法为字段[{}]赋值", field.getName());
            }
        }
    }
1096436
@Override
    public boolean handleAttribute(DDParser parser, String nsURI, String localName, int index) throws ParseException {
        boolean result = false;

        if (nsURI != null) {
            return result;
        }

        if (CONTEXT_ROOT_ATTRIBUTE_NAME.equals(localName)) {
            this.contextRoot = parser.parseStringAttributeValue(index);
            result = true;
        }

        return result;

    }