boolean isAsOrMoreConstrainedThan ( PropertyDefinition other , ExecutionContext context ) { String [ ] otherConstraints = other . getValueConstraints ( ) ; if ( otherConstraints == null || otherConstraints . length == 0 ) { // The ancestor's definition is less constrained, so it's okay even if this definition has no constraints ... return true ; } String [ ] constraints = this . getValueConstraints ( ) ; if ( constraints == null || constraints . length == 0 ) { // This definition has no constraints, while the ancestor does have them ... return false ; } // There are constraints on both, so make sure they have the same types ... int type = this . getRequiredType ( ) ; int otherType = other . getRequiredType ( ) ; if ( type == otherType && type != PropertyType . UNDEFINED ) { ConstraintChecker thisChecker = createChecker ( context , type , constraints ) ; ConstraintChecker thatChecker = createChecker ( context , otherType , otherConstraints ) ; return thisChecker . isAsOrMoreConstrainedThan ( thatChecker ) ; } // We can only compare constraint literals, and we can only expect that every constraint literal in this // definition can be found in the other defintion (which can have more than this one) ... Set < String > thatLiterals = new HashSet < String > ( ) ; for ( String literal : otherConstraints ) { thatLiterals . add ( literal ) ; } for ( String literal : constraints ) { if ( ! thatLiterals . contains ( literal ) ) return false ; } return true ; }
Determine if the constraints on this definition are as - constrained or more - constrained than those on the supplied definition .