From 025081ca392f63639e340cb41ca8272feb5be194 Mon Sep 17 00:00:00 2001 From: Tomas Bjerre Date: Sat, 30 Jan 2016 08:06:54 +0100 Subject: [PATCH] Sorting buttons #91 --- src/main/java/se/bjurr/prnfb/ManualResource.java | 2 ++ src/main/java/se/bjurr/prnfb/settings/PrnfbButton.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/se/bjurr/prnfb/ManualResource.java b/src/main/java/se/bjurr/prnfb/ManualResource.java index 5e1920f4..3990329d 100644 --- a/src/main/java/se/bjurr/prnfb/ManualResource.java +++ b/src/main/java/se/bjurr/prnfb/ManualResource.java @@ -3,6 +3,7 @@ import static com.atlassian.bitbucket.permission.Permission.ADMIN; import static com.google.common.collect.Iterables.find; import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Ordering.usingToString; import static java.lang.Boolean.FALSE; import static java.lang.Boolean.TRUE; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; @@ -106,6 +107,7 @@ && triggeredByAction(clientKeyStore, settings, pullRequestAction, pullRequest, v buttons.add(candidate); } } + buttons = usingToString().sortedCopy(buttons); return ok(gson.toJson(buttons), APPLICATION_JSON).build(); } diff --git a/src/main/java/se/bjurr/prnfb/settings/PrnfbButton.java b/src/main/java/se/bjurr/prnfb/settings/PrnfbButton.java index afa80afa..9f4f0074 100644 --- a/src/main/java/se/bjurr/prnfb/settings/PrnfbButton.java +++ b/src/main/java/se/bjurr/prnfb/settings/PrnfbButton.java @@ -25,4 +25,9 @@ public BUTTON_VISIBILITY getVisibility() { public String getFormIdentifier() { return formIdentifier; } + + @Override + public String toString() { + return "Title: " + title; + } }