Cleaning up Javadocs in core-ui classes.
Added common constants to AbstractCellFormatter.
Change-Id: Ie20ea62f059646e7d6c7f3660dd60a60c40532fe
diff --git a/core/api/src/main/java/org/onosproject/ui/chart/ChartModel.java b/core/api/src/main/java/org/onosproject/ui/chart/ChartModel.java
index b15705d..1cfb395 100644
--- a/core/api/src/main/java/org/onosproject/ui/chart/ChartModel.java
+++ b/core/api/src/main/java/org/onosproject/ui/chart/ChartModel.java
@@ -35,9 +35,9 @@
* A simple model of time series chart data.
* <p>
* Note that this is not a full MVC type model; the expected usage pattern
- * is to create an empty chart, add data points (by consulting the business model),
- * and produce the list of data points which contain a label and a set of data
- * values for all serials.
+ * is to create an empty chart, add data points (by consulting the business
+ * model), and produce the list of data points which contain a label and a set
+ * of data values for all serials.
*/
public class ChartModel {
diff --git a/core/api/src/main/java/org/onosproject/ui/chart/ChartRequestHandler.java b/core/api/src/main/java/org/onosproject/ui/chart/ChartRequestHandler.java
index 1d00689..5c3e2f7 100644
--- a/core/api/src/main/java/org/onosproject/ui/chart/ChartRequestHandler.java
+++ b/core/api/src/main/java/org/onosproject/ui/chart/ChartRequestHandler.java
@@ -27,11 +27,11 @@
*/
public abstract class ChartRequestHandler extends RequestHandler {
+ protected static final String LABEL = "label";
+ private static final String ANNOTS = "annots";
+
private final String respType;
private final String nodeName;
- protected static final String LABEL = "label";
-
- private static final String ANNOTS = "annots";
/**
* Constructs a chart model handler for a specific graph view. When chart
@@ -56,7 +56,7 @@
ObjectNode rootNode = MAPPER.createObjectNode();
rootNode.set(nodeName, ChartUtils.generateDataPointArrayNode(cm));
rootNode.set(ANNOTS, ChartUtils.generateAnnotObjectNode(cm));
- sendMessage(respType, 0, rootNode);
+ sendMessage(respType, rootNode);
}
/**
@@ -72,8 +72,8 @@
List<String> series = new ArrayList<>();
series.addAll(Arrays.asList(getSeries()));
series.add(LABEL);
- String[] seiresArray = new String[series.size()];
- return new ChartModel(series.toArray(seiresArray));
+ String[] array = new String[series.size()];
+ return new ChartModel(series.toArray(array));
}
/**
diff --git a/core/api/src/main/java/org/onosproject/ui/chart/package-info.java b/core/api/src/main/java/org/onosproject/ui/chart/package-info.java
index 5f85e03..4d1ce8e 100644
--- a/core/api/src/main/java/org/onosproject/ui/chart/package-info.java
+++ b/core/api/src/main/java/org/onosproject/ui/chart/package-info.java
@@ -15,6 +15,6 @@
*/
/**
- * Facilities for creating chart models of data for the GUI.
+ * Facilities for creating chart models of data for the Web UI.
*/
package org.onosproject.ui.chart;
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiClusterMember.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiClusterMember.java
index d8803ab..f0aae01 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiClusterMember.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiClusterMember.java
@@ -43,7 +43,7 @@
* topology instance and the specified controller node instance.
*
* @param topology parent topology containing this cluster member
- * @param cnode underlying controller node.
+ * @param cnode underlying controller node
*/
public UiClusterMember(UiTopology topology, ControllerNode cnode) {
this.topology = topology;
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java
index c05d27b..04eaab0 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiDevice.java
@@ -101,7 +101,7 @@
* Returns the identifier of the region to which this device belongs.
* This will be null if the device does not belong to any region.
*
- * @return region identity
+ * @return region ID
*/
public RegionId regionId() {
return regionId;
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiLayer.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiLayer.java
deleted file mode 100644
index 30d16f6..0000000
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiLayer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ui.model.topo;
-
-/**
- * Designates the logical layer of the network that an element belongs to.
- */
-public enum UiLayer {
- PACKET, OPTICAL;
-
- /**
- * Returns the default layer (for those elements that do not explicitly
- * define which layer they belong to).
- *
- * @return default layer
- */
- public static UiLayer defaultLayer() {
- return PACKET;
- }
-}
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiLinkId.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiLinkId.java
index 3bde82a..ca85fb2 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiLinkId.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiLinkId.java
@@ -49,7 +49,7 @@
B_TO_A
}
- static final String CP_DELIMITER = "~";
+ private static final String CP_DELIMITER = "~";
static final String ID_PORT_DELIMITER = "/";
private final RegionId regionA;
@@ -236,7 +236,8 @@
ConnectPoint src = link.src();
ConnectPoint dst = link.dst();
if (src == null || dst == null) {
- throw new NullPointerException("null src or dst connect point: " + link);
+ throw new NullPointerException(
+ "null src or dst connect point: " + link);
}
ElementId srcId = src.elementId();
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionLink.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionLink.java
index 45a27b9..afc6777 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionLink.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegionLink.java
@@ -36,7 +36,7 @@
* link identifier is one that has region IDs as source and destination.
*
* @param topology parent topology
- * @param id canonicalized link identifier
+ * @param id canonicalized link ID
* @throws IllegalArgumentException if the link ID is not region-region
*/
public UiRegionLink(UiTopology topology, UiLinkId id) {
diff --git a/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java b/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java
index 55c84c8..bb6b185 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/CellComparator.java
@@ -24,21 +24,19 @@
/**
* Compares its two arguments for order. Returns a negative integer,
* zero, or a positive integer as the first argument is less than, equal
- * to, or greater than the second.<p>
- *
+ * to, or greater than the second.
+ * <p>
* Note that nulls are permitted, and should be sorted to the beginning
* of an ascending sort; i.e. null is considered to be "smaller" than
* non-null values.
*
* @see java.util.Comparator#compare(Object, Object)
*
- * @param o1 the first object to be compared.
- * @param o2 the second object to be compared.
- * @return a negative integer, zero, or a positive integer as the
- * first argument is less than, equal to, or greater than the
- * second.
+ * @param o1 the first object to be compared
+ * @param o2 the second object to be compared
+ * @return an integer representing relative ordering
* @throws ClassCastException if the arguments' types prevent them from
- * being compared by this comparator.
+ * being compared by this comparator
*/
int compare(Object o1, Object o2);
diff --git a/core/api/src/main/java/org/onosproject/ui/table/TableModel.java b/core/api/src/main/java/org/onosproject/ui/table/TableModel.java
index ed5db2e..9ec2e3b 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/TableModel.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/TableModel.java
@@ -50,6 +50,8 @@
*/
public class TableModel {
+ private static final String DESC = "desc";
+
private static final CellComparator DEF_CMP = DefaultCellComparator.INSTANCE;
private static final CellFormatter DEF_FMT = DefaultCellFormatter.INSTANCE;
private static final String EMPTY = "";
@@ -220,6 +222,9 @@
Collections.sort(rows, new RowComparator(id1, dir1, id2, dir2));
}
+ private boolean nullOrEmpty(String s) {
+ return s == null || EMPTY.equals(s.trim());
+ }
/** Designates sorting direction. */
public enum SortDir {
@@ -229,9 +234,6 @@
DESC
}
- private boolean nullOrEmpty(String s) {
- return s == null || EMPTY.equals(s.trim());
- }
/**
* Row comparator.
@@ -381,8 +383,6 @@
}
}
- private static final String DESC = "desc";
-
/**
* Returns the appropriate sort direction for the given string.
* <p>
diff --git a/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java b/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java
index b042c85..31f42ea 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellComparator.java
@@ -42,19 +42,17 @@
/**
* Compares its two arguments for order. Returns a negative integer,
* zero, or a positive integer as the first argument is less than, equal
- * to, or greater than the second.<p>
- *
+ * to, or greater than the second.
+ * <p>
* Note that both objects are guaranteed to be non-null.
*
* @see java.util.Comparator#compare(Object, Object)
*
- * @param o1 the first object to be compared.
- * @param o2 the second object to be compared.
- * @return a negative integer, zero, or a positive integer as the
- * first argument is less than, equal to, or greater than the
- * second.
+ * @param o1 the first object to be compared
+ * @param o2 the second object to be compared
+ * @return an integer representing relative ordering
* @throws ClassCastException if the arguments' types prevent them from
- * being compared by this comparator.
+ * being compared by this comparator
*/
protected abstract int nonNullCompare(Object o1, Object o2);
}
diff --git a/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java b/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java
index 4329f14..3f3afc4 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/cell/AbstractCellFormatter.java
@@ -25,9 +25,17 @@
*/
public abstract class AbstractCellFormatter implements CellFormatter {
+ protected static final String EMPTY = "";
+ protected static final String SLASH = "/";
+ protected static final String QUERY = "?";
+ protected static final String UNDERSCORE = "_";
+ protected static final String SPACE = " ";
+ protected static final String OX = "0x";
+
+
@Override
public String format(Object value) {
- return value == null ? "" : nonNullFormat(value);
+ return value == null ? EMPTY : nonNullFormat(value);
}
/**
diff --git a/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java b/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java
index d44836f..9966a88 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/cell/AppIdFormatter.java
@@ -24,6 +24,8 @@
*/
public final class AppIdFormatter extends AbstractCellFormatter {
+ private static final String COLON = " : ";
+
// non-instantiable
private AppIdFormatter() { }
@@ -31,7 +33,7 @@
@Override
protected String nonNullFormat(Object value) {
ApplicationId appId = (ApplicationId) value;
- return appId.id() + " : " + appId.name();
+ return appId.id() + COLON + appId.name();
}
/**
diff --git a/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java b/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java
index f64c296..7d9964f 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/cell/ConnectPointFormatter.java
@@ -30,7 +30,7 @@
@Override
protected String nonNullFormat(Object value) {
ConnectPoint cp = (ConnectPoint) value;
- return cp.elementId() + "/" + cp.port();
+ return cp.elementId() + SLASH + cp.port();
}
/**
diff --git a/core/api/src/main/java/org/onosproject/ui/table/cell/EnumFormatter.java b/core/api/src/main/java/org/onosproject/ui/table/cell/EnumFormatter.java
index e8e41e8..7a8d9aa 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/cell/EnumFormatter.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/cell/EnumFormatter.java
@@ -30,7 +30,7 @@
@Override
protected String nonNullFormat(Object value) {
- return capitalizeFully(value.toString().replace("_", " "));
+ return capitalizeFully(value.toString().replace(UNDERSCORE, SPACE));
}
/**
diff --git a/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java b/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java
index e96a8be..4e3194b 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/cell/HexFormatter.java
@@ -28,7 +28,7 @@
@Override
protected String nonNullFormat(Object value) {
- return "0x" + Integer.toHexString((Integer) value);
+ return OX + Integer.toHexString((Integer) value);
}
/**
diff --git a/core/api/src/main/java/org/onosproject/ui/table/cell/HexLongFormatter.java b/core/api/src/main/java/org/onosproject/ui/table/cell/HexLongFormatter.java
index c5bb69d..67d0fa3 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/cell/HexLongFormatter.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/cell/HexLongFormatter.java
@@ -28,7 +28,7 @@
@Override
protected String nonNullFormat(Object value) {
- return "0x" + Long.toHexString((Long) value);
+ return OX + Long.toHexString((Long) value);
}
/**
diff --git a/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java b/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java
index 306cea1..be652ca 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/cell/HostLocationFormatter.java
@@ -30,7 +30,7 @@
@Override
protected String nonNullFormat(Object value) {
HostLocation loc = (HostLocation) value;
- return loc.deviceId() + "/" + loc.port();
+ return loc.deviceId() + SLASH + loc.port();
}
/**
diff --git a/core/api/src/main/java/org/onosproject/ui/table/cell/NumberFormatter.java b/core/api/src/main/java/org/onosproject/ui/table/cell/NumberFormatter.java
index 597a8a4..93c0754 100644
--- a/core/api/src/main/java/org/onosproject/ui/table/cell/NumberFormatter.java
+++ b/core/api/src/main/java/org/onosproject/ui/table/cell/NumberFormatter.java
@@ -22,7 +22,7 @@
import java.text.NumberFormat;
/**
- * Formats number using the specified format string".
+ * Formats number using the specified format string.
*/
public final class NumberFormatter extends AbstractCellFormatter {
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelEndPointFormatter.java b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelEndPointFormatter.java
index 5414f2c..cc68876 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelEndPointFormatter.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/TunnelEndPointFormatter.java
@@ -20,9 +20,11 @@
import org.onosproject.ui.table.CellFormatter;
import org.onosproject.ui.table.cell.AbstractCellFormatter;
+import java.util.Optional;
+
/**
- * Formats a optical tunnel endpoint as "(type)/(element-id)/(port)".
- * Formats a ip tunnel endpoint as "ip".
+ * Formats an optical tunnel endpoint as "(type)/(element-id)/(port)".
+ * Formats an IP tunnel endpoint as "ip".
*/
@Beta
public final class TunnelEndPointFormatter extends AbstractCellFormatter {
@@ -30,17 +32,26 @@
private TunnelEndPointFormatter() {
}
+ private String safeOptional(Optional<?> optional) {
+ return optional.isPresent() ? optional.get().toString() : QUERY;
+ }
+
@Override
protected String nonNullFormat(Object value) {
if (value instanceof DefaultOpticalTunnelEndPoint) {
- DefaultOpticalTunnelEndPoint cp = (DefaultOpticalTunnelEndPoint) value;
- return cp.type() + "/" + cp.elementId().get() + "/" + cp.portNumber().get();
+ DefaultOpticalTunnelEndPoint ep =
+ (DefaultOpticalTunnelEndPoint) value;
+
+ String e = safeOptional(ep.elementId());
+ String p = safeOptional(ep.portNumber());
+ return ep.type() + SLASH + e + SLASH + p;
+
} else if (value instanceof IpTunnelEndPoint) {
IpTunnelEndPoint cp = (IpTunnelEndPoint) value;
return cp.ip().toString();
}
- return "";
+ return EMPTY;
}
/**