protected Object undoCollection(Object potentialCollection, Object otherObject) {
    """
	Sometimes an attribute in one object is a single-entity collection and on the other it is just the object.
	Check the passed potentialCollection and if it is a single-entry collection of the same type as the otherObject, return just the collection element.
	Otherwise, return the original collection.
    """
        if ((potentialCollection != null) && (otherObject != null) && (potentialCollection instanceof Collection) &&
            !(otherObject instanceof Collection)) {
            if ((((Collection) potentialCollection).size() == 1) && ((Collection) potentialCollection).iterator()
                .next().getClass().equals(otherObject.getClass())) {
                potentialCollection = ((Collection) potentialCollection).iterator().next();
            }
        }
        return potentialCollection;
    }
protected Object undoCollection(Object potentialCollection, Object otherObject) {
        if ((potentialCollection != null) && (otherObject != null) && (potentialCollection instanceof Collection) &&
            !(otherObject instanceof Collection)) {
            if ((((Collection) potentialCollection).size() == 1) && ((Collection) potentialCollection).iterator()
                .next().getClass().equals(otherObject.getClass())) {
                potentialCollection = ((Collection) potentialCollection).iterator().next();
            }
        }
        return potentialCollection;
    }
protected Object undoCollection ( Object potentialCollection , Object otherObject ) { if ( ( potentialCollection != null ) && ( otherObject != null ) && ( potentialCollection instanceof Collection ) && ! ( otherObject instanceof Collection ) ) { if ( ( ( ( Collection ) potentialCollection ) . size ( ) == 1 ) && ( ( Collection ) potentialCollection ) . iterator ( ) . next ( ) . getClass ( ) . equals ( otherObject . getClass ( ) ) ) { potentialCollection = ( ( Collection ) potentialCollection ) . iterator ( ) . next ( ) ; } } return potentialCollection ; }
Sometimes an attribute in one object is a single-entity collection and on the other it is just the object.
Check the passed potentialCollection and if it is a single-entry collection of the same type as the otherObject, return just the collection element.
Otherwise, return the original collection.
Sometimes an attribute in one object is a single - entity collection and on the other it is just the object . Check the passed potentialCollection and if it is a single - entry collection of the same type as the otherObject return just the collection element . Otherwise return the original collection .