From 5b2b6ba02115b27660f2becf2781be37f23920cd Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Thu, 27 Jul 2017 09:04:16 +0200 Subject: Api docs: api list sorted in natural order Change-Id: Ide2316c50ee144055eab2499fd241ca1ea354066 Signed-off-by: Marek Gradzki --- vpp-integration/api-docs/api/pom.xml | 7 +++++++ .../java/io/fd/hc2vpp/docs/api/CoverageUnit.java | 24 ++++++++++++++-------- .../java/io/fd/hc2vpp/docs/api/VppApiMessage.java | 9 +++++--- .../docs/scripts/ApiDocsIndexGenerator.groovy | 2 +- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/vpp-integration/api-docs/api/pom.xml b/vpp-integration/api-docs/api/pom.xml index dac57ee7a..1e9a62657 100644 --- a/vpp-integration/api-docs/api/pom.xml +++ b/vpp-integration/api-docs/api/pom.xml @@ -25,6 +25,13 @@ ../../../common/hc2vpp-parent 4.0.0 + + + com.google.code.findbugs + jsr305 + 3.0.0 + + true diff --git a/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/CoverageUnit.java b/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/CoverageUnit.java index e04d28304..5c8247177 100644 --- a/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/CoverageUnit.java +++ b/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/CoverageUnit.java @@ -16,15 +16,18 @@ package io.fd.hc2vpp.docs.api; +import static java.util.Objects.requireNonNull; + import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.Set; +import javax.annotation.Nonnull; /** * Represents mapping between single supported VPP binary api and its binding */ -public class CoverageUnit { +public class CoverageUnit implements Comparable { /** * VPP binary api reference @@ -46,13 +49,13 @@ public class CoverageUnit { */ private final Collection supportedOperations; - private CoverageUnit(final VppApiMessage vppApi, final JavaApiMessage javaApi, - final List yangTypes, - final Collection supportedOperations) { - this.vppApi = vppApi; - this.javaApi = javaApi; - this.yangTypes = yangTypes; - this.supportedOperations = supportedOperations; + private CoverageUnit(@Nonnull final VppApiMessage vppApi, @Nonnull final JavaApiMessage javaApi, + @Nonnull final List yangTypes, + @Nonnull final Collection supportedOperations) { + this.vppApi = requireNonNull(vppApi, "vppApi should not be null"); + this.javaApi = requireNonNull(javaApi, "javaApi should not be null"); + this.yangTypes = requireNonNull(yangTypes, "yangTypes should not be null"); + this.supportedOperations = requireNonNull(supportedOperations, "supportedOperations should not be null"); } public VppApiMessage getVppApi() { @@ -93,6 +96,11 @@ public class CoverageUnit { return Objects.hash(vppApi, javaApi, yangTypes, supportedOperations); } + @Override + public int compareTo(final CoverageUnit o) { + return vppApi.getName().compareTo(o.getVppApi().getName()); + } + public static class CoverageUnitBuilder { private VppApiMessage vppApi; private JavaApiMessage javaApi; diff --git a/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/VppApiMessage.java b/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/VppApiMessage.java index 78010471a..5be743241 100644 --- a/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/VppApiMessage.java +++ b/vpp-integration/api-docs/api/src/main/java/io/fd/hc2vpp/docs/api/VppApiMessage.java @@ -16,7 +16,10 @@ package io.fd.hc2vpp.docs.api; +import static java.util.Objects.requireNonNull; + import java.util.Objects; +import javax.annotation.Nonnull; /** * Represents reference to VPP binary api @@ -34,9 +37,9 @@ public class VppApiMessage { // TODO - check if possible to add direct link for specific api private final String link; - public VppApiMessage(final String name, final String link) { - this.name = name; - this.link = link; + public VppApiMessage(@Nonnull final String name, @Nonnull final String link) { + this.name = requireNonNull(name, "name should not be null"); + this.link = requireNonNull(link, "link should not be null"); } public String getName() { diff --git a/vpp-integration/api-docs/scripts/src/main/groovy/io/fd/hc2vpp/docs/scripts/ApiDocsIndexGenerator.groovy b/vpp-integration/api-docs/scripts/src/main/groovy/io/fd/hc2vpp/docs/scripts/ApiDocsIndexGenerator.groovy index ae6ebc606..de15d7b9b 100644 --- a/vpp-integration/api-docs/scripts/src/main/groovy/io/fd/hc2vpp/docs/scripts/ApiDocsIndexGenerator.groovy +++ b/vpp-integration/api-docs/scripts/src/main/groovy/io/fd/hc2vpp/docs/scripts/ApiDocsIndexGenerator.groovy @@ -123,7 +123,7 @@ class ApiDocsIndexGenerator { } private static String generateConfigTableContent(final Set coverage) { - coverage.stream() + coverage.stream().sorted() .map { unit -> "$NL" + "${vppApiWithLink(unit.vppApi)}" + -- cgit 1.2.3-korg