From 325186b8813d7b4405d588c53cbd256e19d13c6e Mon Sep 17 00:00:00 2001 From: "matus.kubica" Date: Fri, 21 Apr 2017 11:08:12 +0200 Subject: [PATCH] Bug 8153: Enforce check-style rules for netconf - netconf-mapping-api Organize Imports for Checkstyle compliance. Checkstyle compliance: line length. Checkstyle compliance: various types of small changes. Checkstyle compliant Exception handling. Checkstyle final clean up & enforcement. Change-Id: I733c6883a59a27b680c8e35b43f42f649a06906a Signed-off-by: matus.kubica --- .../netconf/mapping/api/HandlingPriority.java | 28 ++++++++++--------- .../netconf/mapping/api/NetconfOperation.java | 13 ++++----- .../api/NetconfOperationChainedExecution.java | 13 +++++---- .../mapping/api/NetconfOperationService.java | 2 +- .../api/NetconfOperationServiceFactory.java | 3 +- 5 files changed, 32 insertions(+), 27 deletions(-) diff --git a/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/HandlingPriority.java b/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/HandlingPriority.java index 98220d19e0..078e9aae9e 100644 --- a/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/HandlingPriority.java +++ b/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/HandlingPriority.java @@ -32,6 +32,8 @@ public final class HandlingPriority implements Comparable { } /** + * Get priority number. + * * @return priority number or Optional.absent otherwise */ public Optional getPriority() { @@ -39,7 +41,7 @@ public final class HandlingPriority implements Comparable { } public HandlingPriority increasePriority(int priorityIncrease) { - Preconditions.checkState(priority!=null, "Unable to increase priority for %s", this); + Preconditions.checkState(priority != null, "Unable to increase priority for %s", this); Preconditions.checkArgument(priorityIncrease > 0, "Negative increase"); Preconditions.checkArgument(Long.valueOf(priority) + priorityIncrease < Integer.MAX_VALUE, "Resulting priority cannot be higher than %s", Integer.MAX_VALUE); @@ -51,42 +53,42 @@ public final class HandlingPriority implements Comparable { } @Override - public int compareTo(HandlingPriority o) { - if (this == o) { + public int compareTo(HandlingPriority priority) { + if (this == priority) { return 0; } if (isCannotHandle()) { return -1; } - if (o.isCannotHandle()) { + if (priority.isCannotHandle()) { return 1; } - if (priority > o.priority){ + if (this.priority > priority.priority) { return 1; } - if (priority.equals(o.priority)){ + if (this.priority.equals(priority.priority)) { return 0; } - if (priority < o.priority){ + if (this.priority < priority.priority) { return -1; } - throw new IllegalStateException("Unexpected state comparing " + this + " with " + o); + throw new IllegalStateException("Unexpected state comparing " + this + " with " + priority); } @Override - public boolean equals(Object o) { - if (this == o){ + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (!(o instanceof HandlingPriority)){ + if (!(obj instanceof HandlingPriority)) { return false; } - HandlingPriority that = (HandlingPriority) o; + HandlingPriority that = (HandlingPriority) obj; - if (priority != null ? !priority.equals(that.priority) : that.priority != null){ + if (priority != null ? !priority.equals(that.priority) : that.priority != null) { return false; } diff --git a/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperation.java b/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperation.java index d1bba40856..445eb6d3d6 100644 --- a/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperation.java +++ b/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperation.java @@ -17,11 +17,11 @@ import org.w3c.dom.Document; * operations are chained (ordered by HandlingPriority returned by canHandle * method) and executed. * + *

* Operation can be declared as singleton or last in chain (see abstract * implementations in netconf-util). If the operation is not singleton or last, * it is responsible for the execution of subsequent operation and for merging * the results. - * */ public interface NetconfOperation { @@ -31,7 +31,7 @@ public interface NetconfOperation { * HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY. * * @param message request message - * @return + * @return {@code handling priority} */ HandlingPriority canHandle(Document message) throws DocumentedException; @@ -42,11 +42,10 @@ public interface NetconfOperation { * last/singleton operation, subsequentOperation must indicate termination * point. * - * @param requestMessage - * @param subsequentOperation - * execution of subsequent netconf operation - * @return - * @throws DocumentedException + * @param requestMessage request message + * @param subsequentOperation execution of subsequent netconf operation + * @return {@code document} + * @throws DocumentedException if operation fails */ Document handle(Document requestMessage, NetconfOperationChainedExecution subsequentOperation) throws DocumentedException; diff --git a/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationChainedExecution.java b/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationChainedExecution.java index 294482b0b5..1e57fc7021 100644 --- a/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationChainedExecution.java +++ b/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationChainedExecution.java @@ -17,18 +17,20 @@ import org.w3c.dom.Document; public interface NetconfOperationChainedExecution { /** + * Check if this is termination point in operation execution. + * * @return true if this is termination point in operation execution, false - * if there is a subsequent operation present that needs to be - * executed + * if there is a subsequent operation present that needs to be + * executed. */ boolean isExecutionTermination(); /** - * Do not execute if this is termination point + * Do not execute if this is termination point. */ Document execute(Document requestMessage) throws DocumentedException; - public static final NetconfOperationChainedExecution EXECUTION_TERMINATION_POINT = new NetconfOperationChainedExecution() { + NetconfOperationChainedExecution EXECUTION_TERMINATION_POINT = new NetconfOperationChainedExecution() { @Override public boolean isExecutionTermination() { return true; @@ -36,7 +38,8 @@ public interface NetconfOperationChainedExecution { @Override public Document execute(Document requestMessage) throws DocumentedException { - throw new IllegalStateException("This execution represents the termination point in operation execution and cannot be executed itself"); + throw new IllegalStateException("This execution represents the termination point in operation execution " + + "and cannot be executed itself"); } }; diff --git a/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationService.java b/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationService.java index 907bc2dca0..f7f633de19 100644 --- a/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationService.java +++ b/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationService.java @@ -11,7 +11,7 @@ package org.opendaylight.netconf.mapping.api; import java.util.Set; /** - * + * Service of netconf operations. */ public interface NetconfOperationService extends AutoCloseable { diff --git a/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationServiceFactory.java b/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationServiceFactory.java index 9e63f038db..57d896e6ea 100644 --- a/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationServiceFactory.java +++ b/netconf/netconf-mapping-api/src/main/java/org/opendaylight/netconf/mapping/api/NetconfOperationServiceFactory.java @@ -25,7 +25,8 @@ public interface NetconfOperationServiceFactory { Set getCapabilities(); /** - * Supported capabilities may change over time, registering a listener allows for push based information retrieval about current notifications + * Supported capabilities may change over time, registering a listener allows for push based information + * retrieval about current notifications. */ AutoCloseable registerCapabilityListener(CapabilityListener listener); -- 2.36.6