/*@ public normal_behavior @ requires othMap != null && errval != null; @ requires int_size() @ <= Integer.MAX_VALUE - othMap.difference(this).int_size(); @ ensures (\forall JMLObjectValuePair pair; ; @ \result.theRelation.has(pair) @ == @ (!othMap.isDefinedAt(pair.key) @ && this.elementImage(pair.key).has(pair.value)) @ || (!this.isDefinedAt(pair.key) @ && othMap.elementImage(pair.key) @ .has(pair.value)) @ || (this.isDefinedAt(pair.key) @ && othMap.isDefinedAt(pair.key) @ && pair.value .equals(errval)) @ ); @ implies_that @ requires othMap != null && errval != null; @*/ public /*@ non_null @*/ JMLObjectToValueMap clashReplaceUnion( JMLObjectToValueMap othMap, JMLType errval) throws IllegalStateException { JMLObjectSet overlap = this.domain_.intersection(othMap.domain_); Enumeration overlapEnum = overlap.elements(); othMap = othMap.restrictedTo(othMap.domain_.difference(overlap)); JMLObjectToValueMap newMap = this.restrictedTo(this.domain_.difference(overlap)); JMLObjectToValueRelation newRel; if (newMap.size_ <= Integer.MAX_VALUE - othMap.size_) { newRel = new JMLObjectToValueRelation( newMap.imagePairSet_.union(othMap.imagePairSet_), newMap.domain_.union(othMap.domain_), newMap.size_ + othMap.size_); } else { throw new IllegalStateException(TOO_BIG_TO_UNION); } Object dv; while (overlapEnum.hasMoreElements()) { // @ assume overlapEnum.moreElements; Object oo = overlapEnum.nextElement(); // @ assume oo != null && oo instanceof Object; dv = (Object) oo; newRel = newRel.add(dv, errval); } return newRel.toFunction(); } // @ nowarn Exception;