final JcrPropertyDefinition findBestPropertyDefinition( Name primaryTypeNameOfParent,
                                                            Collection<Name> mixinTypeNamesOfParent,
                                                            org.modeshape.jcr.value.Property property,
                                                            boolean isSingle,
                                                            boolean skipProtected,
                                                            boolean skipConstraints,
                                                            NodeTypes nodeTypes ) {
        JcrPropertyDefinition definition = null;
        int propertyType = PropertyTypeUtil.jcrPropertyTypeFor(property);

        // If single-valued ...
        ValueFactories factories = context().getValueFactories();
        if (isSingle) {
            // Create a value for the ModeShape property value ...
            Object value = property.getFirstValue();
            Value jcrValue = new JcrValue(factories, propertyType, value);
            definition = nodeTypes.findPropertyDefinition(session, primaryTypeNameOfParent, mixinTypeNamesOfParent,
                                                          property.getName(), jcrValue, true, skipProtected);
        } else {
            // Create values for the ModeShape property value ...
            Value[] jcrValues = new Value[property.size()];
            int index = 0;
            for (Object value : property) {
                jcrValues[index++] = new JcrValue(factories, propertyType, value);
            }
            definition = nodeTypes.findPropertyDefinition(session, primaryTypeNameOfParent, mixinTypeNamesOfParent,
                                                          property.getName(), jcrValues, skipProtected);
        }

        if (definition != null) return definition;

        // No definition that allowed the values ...
        return null;
    }
final JcrPropertyDefinition findBestPropertyDefinition ( Name primaryTypeNameOfParent , Collection < Name > mixinTypeNamesOfParent , org . modeshape . jcr . value . Property property , boolean isSingle , boolean skipProtected , boolean skipConstraints , NodeTypes nodeTypes ) { JcrPropertyDefinition definition = null ; int propertyType = PropertyTypeUtil . jcrPropertyTypeFor ( property ) ; ValueFactories factories = context ( ) . getValueFactories ( ) ; if ( isSingle ) { Object value = property . getFirstValue ( ) ; Value jcrValue = new JcrValue ( factories , propertyType , value ) ; definition = nodeTypes . findPropertyDefinition ( session , primaryTypeNameOfParent , mixinTypeNamesOfParent , property . getName ( ) , jcrValue , true , skipProtected ) ; } else { Value [ ] jcrValues = new Value [ property . size ( ) ] ; int index = 0 ; for ( Object value : property ) { jcrValues [ index ++ ] = new JcrValue ( factories , propertyType , value ) ; } definition = nodeTypes . findPropertyDefinition ( session , primaryTypeNameOfParent , mixinTypeNamesOfParent , property . getName ( ) , jcrValues , skipProtected ) ; } if ( definition != null ) return definition ; return null ; }
Find the best property definition in this node's primary type and mixin types.

@param primaryTypeNameOfParent the name of the primary type for the parent node; may not be null
@param mixinTypeNamesOfParent the names of the mixin types for the parent node; may be null or empty if there are no mixins
to include in the search
@param property the property
@param isSingle true if the property definition should be single-valued, or false if the property definition should allow
multiple values
@param skipProtected true if this operation is being done from within the public JCR node and property API, or false if
this operation is being done from within internal implementations
@param skipConstraints true if any constraints on the potential property definitions should be skipped; usually this is
true for the first attempt but then 'false' for a subsequent attempt when figuring out an appropriate error message
@param nodeTypes the node types cache to use; may not be null
@return the property definition that allows setting this property, or null if there is no such definition