From eb00690b3034b970d4e7a1778d61eb0c305c82aa Mon Sep 17 00:00:00 2001 From: rbygrave Date: Thu, 20 May 2021 14:09:22 +1200 Subject: [PATCH] #2231 - Change OrderBy to not be final to support mocking via Mockito --- ebean-api/src/main/java/io/ebean/OrderBy.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/OrderBy.java b/ebean-api/src/main/java/io/ebean/OrderBy.java index 820a76314..8b39fc19e 100644 --- a/ebean-api/src/main/java/io/ebean/OrderBy.java +++ b/ebean-api/src/main/java/io/ebean/OrderBy.java @@ -16,7 +16,7 @@ import java.util.Objects; * on the Query object. *

*/ -public final class OrderBy implements Serializable { +public class OrderBy implements Serializable { private static final long serialVersionUID = 9157089257745730539L; @@ -69,7 +69,6 @@ public final class OrderBy implements Serializable { * Add a property with ascending order to this OrderBy. */ public Query asc(String propertyName) { - list.add(new Property(propertyName, true)); return query; } @@ -98,7 +97,6 @@ public final class OrderBy implements Serializable { return query; } - /** * Return true if the property is known to be contained in the order by clause. */ @@ -207,7 +205,6 @@ public final class OrderBy implements Serializable { if (!(obj instanceof OrderBy)) { return false; } - OrderBy e = (OrderBy) obj; return e.list.equals(list); } @@ -249,7 +246,7 @@ public final class OrderBy implements Serializable { /** * A property and its ascending descending order. */ - public static final class Property implements Serializable { + public static class Property implements Serializable { private static final long serialVersionUID = 1546009780322478077L; @@ -415,13 +412,10 @@ public final class OrderBy implements Serializable { } private void parse(String orderByClause) { - if (orderByClause == null) { return; } - - String[] chunks = orderByClause.split(","); - for (String chunk : chunks) { + for (String chunk : orderByClause.split(",")) { Property p = parseProperty(chunk); if (p != null) { list.add(p); @@ -467,8 +461,7 @@ public final class OrderBy implements Serializable { if (s.startsWith("desc")) { return false; } - String m = "Expecting [" + s + "] to be asc or desc?"; - throw new RuntimeException(m); + throw new RuntimeException("Expecting [" + s + "] to be asc or desc?"); } private boolean isEmptyString(String s) {