Simon Hunt

Cleaning up Javadocs in core-ui classes.

Added common constants to AbstractCellFormatter.

Change-Id: Ie20ea62f059646e7d6c7f3660dd60a60c40532fe
Showing 20 changed files with 67 additions and 83 deletions
...@@ -35,9 +35,9 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -35,9 +35,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
35 * A simple model of time series chart data. 35 * A simple model of time series chart data.
36 * <p> 36 * <p>
37 * Note that this is not a full MVC type model; the expected usage pattern 37 * Note that this is not a full MVC type model; the expected usage pattern
38 - * is to create an empty chart, add data points (by consulting the business model), 38 + * is to create an empty chart, add data points (by consulting the business
39 - * and produce the list of data points which contain a label and a set of data 39 + * model), and produce the list of data points which contain a label and a set
40 - * values for all serials. 40 + * of data values for all serials.
41 */ 41 */
42 public class ChartModel { 42 public class ChartModel {
43 43
......
...@@ -27,12 +27,12 @@ import java.util.List; ...@@ -27,12 +27,12 @@ import java.util.List;
27 */ 27 */
28 public abstract class ChartRequestHandler extends RequestHandler { 28 public abstract class ChartRequestHandler extends RequestHandler {
29 29
30 - private final String respType;
31 - private final String nodeName;
32 protected static final String LABEL = "label"; 30 protected static final String LABEL = "label";
33 -
34 private static final String ANNOTS = "annots"; 31 private static final String ANNOTS = "annots";
35 32
33 + private final String respType;
34 + private final String nodeName;
35 +
36 /** 36 /**
37 * Constructs a chart model handler for a specific graph view. When chart 37 * Constructs a chart model handler for a specific graph view. When chart
38 * requests come in, the handler will generate the appropriate chart data 38 * requests come in, the handler will generate the appropriate chart data
...@@ -56,7 +56,7 @@ public abstract class ChartRequestHandler extends RequestHandler { ...@@ -56,7 +56,7 @@ public abstract class ChartRequestHandler extends RequestHandler {
56 ObjectNode rootNode = MAPPER.createObjectNode(); 56 ObjectNode rootNode = MAPPER.createObjectNode();
57 rootNode.set(nodeName, ChartUtils.generateDataPointArrayNode(cm)); 57 rootNode.set(nodeName, ChartUtils.generateDataPointArrayNode(cm));
58 rootNode.set(ANNOTS, ChartUtils.generateAnnotObjectNode(cm)); 58 rootNode.set(ANNOTS, ChartUtils.generateAnnotObjectNode(cm));
59 - sendMessage(respType, 0, rootNode); 59 + sendMessage(respType, rootNode);
60 } 60 }
61 61
62 /** 62 /**
...@@ -72,8 +72,8 @@ public abstract class ChartRequestHandler extends RequestHandler { ...@@ -72,8 +72,8 @@ public abstract class ChartRequestHandler extends RequestHandler {
72 List<String> series = new ArrayList<>(); 72 List<String> series = new ArrayList<>();
73 series.addAll(Arrays.asList(getSeries())); 73 series.addAll(Arrays.asList(getSeries()));
74 series.add(LABEL); 74 series.add(LABEL);
75 - String[] seiresArray = new String[series.size()]; 75 + String[] array = new String[series.size()];
76 - return new ChartModel(series.toArray(seiresArray)); 76 + return new ChartModel(series.toArray(array));
77 } 77 }
78 78
79 /** 79 /**
......
...@@ -15,6 +15,6 @@ ...@@ -15,6 +15,6 @@
15 */ 15 */
16 16
17 /** 17 /**
18 - * Facilities for creating chart models of data for the GUI. 18 + * Facilities for creating chart models of data for the Web UI.
19 */ 19 */
20 package org.onosproject.ui.chart; 20 package org.onosproject.ui.chart;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -43,7 +43,7 @@ public class UiClusterMember extends UiElement { ...@@ -43,7 +43,7 @@ public class UiClusterMember extends UiElement {
43 * topology instance and the specified controller node instance. 43 * topology instance and the specified controller node instance.
44 * 44 *
45 * @param topology parent topology containing this cluster member 45 * @param topology parent topology containing this cluster member
46 - * @param cnode underlying controller node. 46 + * @param cnode underlying controller node
47 */ 47 */
48 public UiClusterMember(UiTopology topology, ControllerNode cnode) { 48 public UiClusterMember(UiTopology topology, ControllerNode cnode) {
49 this.topology = topology; 49 this.topology = topology;
......
...@@ -101,7 +101,7 @@ public class UiDevice extends UiNode { ...@@ -101,7 +101,7 @@ public class UiDevice extends UiNode {
101 * Returns the identifier of the region to which this device belongs. 101 * Returns the identifier of the region to which this device belongs.
102 * This will be null if the device does not belong to any region. 102 * This will be null if the device does not belong to any region.
103 * 103 *
104 - * @return region identity 104 + * @return region ID
105 */ 105 */
106 public RegionId regionId() { 106 public RegionId regionId() {
107 return regionId; 107 return regionId;
......
1 -/*
2 - * Copyright 2016-present Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -
17 -package org.onosproject.ui.model.topo;
18 -
19 -/**
20 - * Designates the logical layer of the network that an element belongs to.
21 - */
22 -public enum UiLayer {
23 - PACKET, OPTICAL;
24 -
25 - /**
26 - * Returns the default layer (for those elements that do not explicitly
27 - * define which layer they belong to).
28 - *
29 - * @return default layer
30 - */
31 - public static UiLayer defaultLayer() {
32 - return PACKET;
33 - }
34 -}
...@@ -49,7 +49,7 @@ public final class UiLinkId { ...@@ -49,7 +49,7 @@ public final class UiLinkId {
49 B_TO_A 49 B_TO_A
50 } 50 }
51 51
52 - static final String CP_DELIMITER = "~"; 52 + private static final String CP_DELIMITER = "~";
53 static final String ID_PORT_DELIMITER = "/"; 53 static final String ID_PORT_DELIMITER = "/";
54 54
55 private final RegionId regionA; 55 private final RegionId regionA;
...@@ -236,7 +236,8 @@ public final class UiLinkId { ...@@ -236,7 +236,8 @@ public final class UiLinkId {
236 ConnectPoint src = link.src(); 236 ConnectPoint src = link.src();
237 ConnectPoint dst = link.dst(); 237 ConnectPoint dst = link.dst();
238 if (src == null || dst == null) { 238 if (src == null || dst == null) {
239 - throw new NullPointerException("null src or dst connect point: " + link); 239 + throw new NullPointerException(
240 + "null src or dst connect point: " + link);
240 } 241 }
241 242
242 ElementId srcId = src.elementId(); 243 ElementId srcId = src.elementId();
......
...@@ -36,7 +36,7 @@ public class UiRegionLink extends UiLink { ...@@ -36,7 +36,7 @@ public class UiRegionLink extends UiLink {
36 * link identifier is one that has region IDs as source and destination. 36 * link identifier is one that has region IDs as source and destination.
37 * 37 *
38 * @param topology parent topology 38 * @param topology parent topology
39 - * @param id canonicalized link identifier 39 + * @param id canonicalized link ID
40 * @throws IllegalArgumentException if the link ID is not region-region 40 * @throws IllegalArgumentException if the link ID is not region-region
41 */ 41 */
42 public UiRegionLink(UiTopology topology, UiLinkId id) { 42 public UiRegionLink(UiTopology topology, UiLinkId id) {
......
...@@ -24,21 +24,19 @@ public interface CellComparator { ...@@ -24,21 +24,19 @@ public interface CellComparator {
24 /** 24 /**
25 * Compares its two arguments for order. Returns a negative integer, 25 * Compares its two arguments for order. Returns a negative integer,
26 * zero, or a positive integer as the first argument is less than, equal 26 * zero, or a positive integer as the first argument is less than, equal
27 - * to, or greater than the second.<p> 27 + * to, or greater than the second.
28 - * 28 + * <p>
29 * Note that nulls are permitted, and should be sorted to the beginning 29 * Note that nulls are permitted, and should be sorted to the beginning
30 * of an ascending sort; i.e. null is considered to be "smaller" than 30 * of an ascending sort; i.e. null is considered to be "smaller" than
31 * non-null values. 31 * non-null values.
32 * 32 *
33 * @see java.util.Comparator#compare(Object, Object) 33 * @see java.util.Comparator#compare(Object, Object)
34 * 34 *
35 - * @param o1 the first object to be compared. 35 + * @param o1 the first object to be compared
36 - * @param o2 the second object to be compared. 36 + * @param o2 the second object to be compared
37 - * @return a negative integer, zero, or a positive integer as the 37 + * @return an integer representing relative ordering
38 - * first argument is less than, equal to, or greater than the
39 - * second.
40 * @throws ClassCastException if the arguments' types prevent them from 38 * @throws ClassCastException if the arguments' types prevent them from
41 - * being compared by this comparator. 39 + * being compared by this comparator
42 */ 40 */
43 int compare(Object o1, Object o2); 41 int compare(Object o1, Object o2);
44 42
......
...@@ -50,6 +50,8 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -50,6 +50,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
50 */ 50 */
51 public class TableModel { 51 public class TableModel {
52 52
53 + private static final String DESC = "desc";
54 +
53 private static final CellComparator DEF_CMP = DefaultCellComparator.INSTANCE; 55 private static final CellComparator DEF_CMP = DefaultCellComparator.INSTANCE;
54 private static final CellFormatter DEF_FMT = DefaultCellFormatter.INSTANCE; 56 private static final CellFormatter DEF_FMT = DefaultCellFormatter.INSTANCE;
55 private static final String EMPTY = ""; 57 private static final String EMPTY = "";
...@@ -220,6 +222,9 @@ public class TableModel { ...@@ -220,6 +222,9 @@ public class TableModel {
220 Collections.sort(rows, new RowComparator(id1, dir1, id2, dir2)); 222 Collections.sort(rows, new RowComparator(id1, dir1, id2, dir2));
221 } 223 }
222 224
225 + private boolean nullOrEmpty(String s) {
226 + return s == null || EMPTY.equals(s.trim());
227 + }
223 228
224 /** Designates sorting direction. */ 229 /** Designates sorting direction. */
225 public enum SortDir { 230 public enum SortDir {
...@@ -229,9 +234,6 @@ public class TableModel { ...@@ -229,9 +234,6 @@ public class TableModel {
229 DESC 234 DESC
230 } 235 }
231 236
232 - private boolean nullOrEmpty(String s) {
233 - return s == null || EMPTY.equals(s.trim());
234 - }
235 237
236 /** 238 /**
237 * Row comparator. 239 * Row comparator.
...@@ -381,8 +383,6 @@ public class TableModel { ...@@ -381,8 +383,6 @@ public class TableModel {
381 } 383 }
382 } 384 }
383 385
384 - private static final String DESC = "desc";
385 -
386 /** 386 /**
387 * Returns the appropriate sort direction for the given string. 387 * Returns the appropriate sort direction for the given string.
388 * <p> 388 * <p>
......
...@@ -42,19 +42,17 @@ public abstract class AbstractCellComparator implements CellComparator { ...@@ -42,19 +42,17 @@ public abstract class AbstractCellComparator implements CellComparator {
42 /** 42 /**
43 * Compares its two arguments for order. Returns a negative integer, 43 * Compares its two arguments for order. Returns a negative integer,
44 * zero, or a positive integer as the first argument is less than, equal 44 * zero, or a positive integer as the first argument is less than, equal
45 - * to, or greater than the second.<p> 45 + * to, or greater than the second.
46 - * 46 + * <p>
47 * Note that both objects are guaranteed to be non-null. 47 * Note that both objects are guaranteed to be non-null.
48 * 48 *
49 * @see java.util.Comparator#compare(Object, Object) 49 * @see java.util.Comparator#compare(Object, Object)
50 * 50 *
51 - * @param o1 the first object to be compared. 51 + * @param o1 the first object to be compared
52 - * @param o2 the second object to be compared. 52 + * @param o2 the second object to be compared
53 - * @return a negative integer, zero, or a positive integer as the 53 + * @return an integer representing relative ordering
54 - * first argument is less than, equal to, or greater than the
55 - * second.
56 * @throws ClassCastException if the arguments' types prevent them from 54 * @throws ClassCastException if the arguments' types prevent them from
57 - * being compared by this comparator. 55 + * being compared by this comparator
58 */ 56 */
59 protected abstract int nonNullCompare(Object o1, Object o2); 57 protected abstract int nonNullCompare(Object o1, Object o2);
60 } 58 }
......
...@@ -25,9 +25,17 @@ import org.onosproject.ui.table.CellFormatter; ...@@ -25,9 +25,17 @@ import org.onosproject.ui.table.CellFormatter;
25 */ 25 */
26 public abstract class AbstractCellFormatter implements CellFormatter { 26 public abstract class AbstractCellFormatter implements CellFormatter {
27 27
28 + protected static final String EMPTY = "";
29 + protected static final String SLASH = "/";
30 + protected static final String QUERY = "?";
31 + protected static final String UNDERSCORE = "_";
32 + protected static final String SPACE = " ";
33 + protected static final String OX = "0x";
34 +
35 +
28 @Override 36 @Override
29 public String format(Object value) { 37 public String format(Object value) {
30 - return value == null ? "" : nonNullFormat(value); 38 + return value == null ? EMPTY : nonNullFormat(value);
31 } 39 }
32 40
33 /** 41 /**
......
...@@ -24,6 +24,8 @@ import org.onosproject.ui.table.CellFormatter; ...@@ -24,6 +24,8 @@ import org.onosproject.ui.table.CellFormatter;
24 */ 24 */
25 public final class AppIdFormatter extends AbstractCellFormatter { 25 public final class AppIdFormatter extends AbstractCellFormatter {
26 26
27 + private static final String COLON = " : ";
28 +
27 // non-instantiable 29 // non-instantiable
28 private AppIdFormatter() { } 30 private AppIdFormatter() { }
29 31
...@@ -31,7 +33,7 @@ public final class AppIdFormatter extends AbstractCellFormatter { ...@@ -31,7 +33,7 @@ public final class AppIdFormatter extends AbstractCellFormatter {
31 @Override 33 @Override
32 protected String nonNullFormat(Object value) { 34 protected String nonNullFormat(Object value) {
33 ApplicationId appId = (ApplicationId) value; 35 ApplicationId appId = (ApplicationId) value;
34 - return appId.id() + " : " + appId.name(); 36 + return appId.id() + COLON + appId.name();
35 } 37 }
36 38
37 /** 39 /**
......
...@@ -30,7 +30,7 @@ public final class ConnectPointFormatter extends AbstractCellFormatter { ...@@ -30,7 +30,7 @@ public final class ConnectPointFormatter extends AbstractCellFormatter {
30 @Override 30 @Override
31 protected String nonNullFormat(Object value) { 31 protected String nonNullFormat(Object value) {
32 ConnectPoint cp = (ConnectPoint) value; 32 ConnectPoint cp = (ConnectPoint) value;
33 - return cp.elementId() + "/" + cp.port(); 33 + return cp.elementId() + SLASH + cp.port();
34 } 34 }
35 35
36 /** 36 /**
......
...@@ -30,7 +30,7 @@ public final class EnumFormatter extends AbstractCellFormatter { ...@@ -30,7 +30,7 @@ public final class EnumFormatter extends AbstractCellFormatter {
30 30
31 @Override 31 @Override
32 protected String nonNullFormat(Object value) { 32 protected String nonNullFormat(Object value) {
33 - return capitalizeFully(value.toString().replace("_", " ")); 33 + return capitalizeFully(value.toString().replace(UNDERSCORE, SPACE));
34 } 34 }
35 35
36 /** 36 /**
......
...@@ -28,7 +28,7 @@ public final class HexFormatter extends AbstractCellFormatter { ...@@ -28,7 +28,7 @@ public final class HexFormatter extends AbstractCellFormatter {
28 28
29 @Override 29 @Override
30 protected String nonNullFormat(Object value) { 30 protected String nonNullFormat(Object value) {
31 - return "0x" + Integer.toHexString((Integer) value); 31 + return OX + Integer.toHexString((Integer) value);
32 } 32 }
33 33
34 /** 34 /**
......
...@@ -28,7 +28,7 @@ public final class HexLongFormatter extends AbstractCellFormatter { ...@@ -28,7 +28,7 @@ public final class HexLongFormatter extends AbstractCellFormatter {
28 28
29 @Override 29 @Override
30 protected String nonNullFormat(Object value) { 30 protected String nonNullFormat(Object value) {
31 - return "0x" + Long.toHexString((Long) value); 31 + return OX + Long.toHexString((Long) value);
32 } 32 }
33 33
34 /** 34 /**
......
...@@ -30,7 +30,7 @@ public final class HostLocationFormatter extends AbstractCellFormatter { ...@@ -30,7 +30,7 @@ public final class HostLocationFormatter extends AbstractCellFormatter {
30 @Override 30 @Override
31 protected String nonNullFormat(Object value) { 31 protected String nonNullFormat(Object value) {
32 HostLocation loc = (HostLocation) value; 32 HostLocation loc = (HostLocation) value;
33 - return loc.deviceId() + "/" + loc.port(); 33 + return loc.deviceId() + SLASH + loc.port();
34 } 34 }
35 35
36 /** 36 /**
......
...@@ -22,7 +22,7 @@ import java.text.DecimalFormat; ...@@ -22,7 +22,7 @@ import java.text.DecimalFormat;
22 import java.text.NumberFormat; 22 import java.text.NumberFormat;
23 23
24 /** 24 /**
25 - * Formats number using the specified format string". 25 + * Formats number using the specified format string.
26 */ 26 */
27 public final class NumberFormatter extends AbstractCellFormatter { 27 public final class NumberFormatter extends AbstractCellFormatter {
28 28
......
...@@ -20,9 +20,11 @@ import com.google.common.annotations.Beta; ...@@ -20,9 +20,11 @@ import com.google.common.annotations.Beta;
20 import org.onosproject.ui.table.CellFormatter; 20 import org.onosproject.ui.table.CellFormatter;
21 import org.onosproject.ui.table.cell.AbstractCellFormatter; 21 import org.onosproject.ui.table.cell.AbstractCellFormatter;
22 22
23 +import java.util.Optional;
24 +
23 /** 25 /**
24 - * Formats a optical tunnel endpoint as "(type)/(element-id)/(port)". 26 + * Formats an optical tunnel endpoint as "(type)/(element-id)/(port)".
25 - * Formats a ip tunnel endpoint as "ip". 27 + * Formats an IP tunnel endpoint as "ip".
26 */ 28 */
27 @Beta 29 @Beta
28 public final class TunnelEndPointFormatter extends AbstractCellFormatter { 30 public final class TunnelEndPointFormatter extends AbstractCellFormatter {
...@@ -30,17 +32,26 @@ public final class TunnelEndPointFormatter extends AbstractCellFormatter { ...@@ -30,17 +32,26 @@ public final class TunnelEndPointFormatter extends AbstractCellFormatter {
30 private TunnelEndPointFormatter() { 32 private TunnelEndPointFormatter() {
31 } 33 }
32 34
35 + private String safeOptional(Optional<?> optional) {
36 + return optional.isPresent() ? optional.get().toString() : QUERY;
37 + }
38 +
33 @Override 39 @Override
34 protected String nonNullFormat(Object value) { 40 protected String nonNullFormat(Object value) {
35 41
36 if (value instanceof DefaultOpticalTunnelEndPoint) { 42 if (value instanceof DefaultOpticalTunnelEndPoint) {
37 - DefaultOpticalTunnelEndPoint cp = (DefaultOpticalTunnelEndPoint) value; 43 + DefaultOpticalTunnelEndPoint ep =
38 - return cp.type() + "/" + cp.elementId().get() + "/" + cp.portNumber().get(); 44 + (DefaultOpticalTunnelEndPoint) value;
45 +
46 + String e = safeOptional(ep.elementId());
47 + String p = safeOptional(ep.portNumber());
48 + return ep.type() + SLASH + e + SLASH + p;
49 +
39 } else if (value instanceof IpTunnelEndPoint) { 50 } else if (value instanceof IpTunnelEndPoint) {
40 IpTunnelEndPoint cp = (IpTunnelEndPoint) value; 51 IpTunnelEndPoint cp = (IpTunnelEndPoint) value;
41 return cp.ip().toString(); 52 return cp.ip().toString();
42 } 53 }
43 - return ""; 54 + return EMPTY;
44 } 55 }
45 56
46 /** 57 /**
......