#566 - Refactor internals - Initial tidy on OrmQueryDetail and OrmQueryDetailProperties

This commit is contained in:
Robin Bygrave
2016-02-17 10:52:55 +13:00
parent 69bf1758bc
commit 2fcaab44c6
21 changed files with 833 additions and 313 deletions
@@ -1,5 +1,8 @@
package com.avaje.ebeaninternal.server.expression;
import java.util.Collection;
import java.util.Iterator;
/**
* Utility to help isSame methods.
*/
@@ -19,6 +22,26 @@ public class Same {
return v1 == null ? v2 == null : v1.equals(v2);
}
/**
* Return true if both collections are the same by value and order is taken into account.
*/
public static boolean sameByValue(Collection<?> v1, Collection<?> v2) {
if (v1 == null) {
return v2 == null;
}
if (v2 == null || v1.size() != v2.size()) {
return false;
}
Iterator<?> thisIt = v1.iterator();
Iterator<?> thatIt = v2.iterator();
while (thisIt.hasNext() && thatIt.hasNext()) {
if (!thisIt.next().equals(thatIt.next())) {
return false;
}
}
return true;
}
/**
* Null safe check by sameByValue or sameByNull based on byValue.
*/