Create enum property type, trivial code simplification

This commit is contained in:
ljacqu
2016-01-04 20:33:31 +01:00
parent 7d41ccbc9c
commit cb07b3df3d
8 changed files with 66 additions and 25 deletions
@@ -60,15 +60,13 @@ public final class CollectionUtils {
return coll == null || coll.isEmpty();
}
public static <T> List<T> filterCommonStart(List<T> coll1, List<T> coll2) {
public static <T> List<T> filterCommonStart(List<T> list1, List<T> list2) {
List<T> commonStart = new ArrayList<>();
int minSize = Math.min(coll1.size(), coll2.size());
for (int i = 0; i < minSize; ++i) {
if (Objects.equals(coll1.get(i), coll2.get(i))) {
commonStart.add(coll1.get(i));
} else {
break;
}
int minSize = Math.min(list1.size(), list2.size());
int i = 0;
while (i < minSize && Objects.equals(list1.get(i), list2.get(i))) {
commonStart.add(list1.get(i));
++i;
}
return commonStart;
}
@@ -117,12 +117,4 @@ public final class StringUtils {
return "[" + th.getClass().getSimpleName() + "]: " + th.getMessage();
}
public static String repeat(String str, int times) {
StringBuilder sb = new StringBuilder(str.length() * times);
for (int i = 0; i < times; ++i) {
sb.append(str);
}
return sb.toString();
}
}