blob: 964d451ad386337cf838d75f41e0a4d5e601822e [file] [log] [blame]
chengfan392e8f92015-08-21 13:20:02 -05001package org.onosproject.incubator.net.tunnel;
2
3
4import org.onosproject.ui.table.CellFormatter;
5import org.onosproject.ui.table.cell.AbstractCellFormatter;
6
7/**
8 * Formats a optical tunnel endpoint as "(type)/(element-id)/(port)".
9 * Formats a ip tunnel endpoint as "ip".
10 */
11public final class TunnelEndPointFormatter extends AbstractCellFormatter {
12 //non-instantiable
13 private TunnelEndPointFormatter() {
14 }
15
16 @Override
17 protected String nonNullFormat(Object value) {
18
19 if (value instanceof DefaultOpticalTunnelEndPoint) {
20 DefaultOpticalTunnelEndPoint cp = (DefaultOpticalTunnelEndPoint) value;
21 return cp.type() + "/" + cp.elementId().get() + "/" + cp.portNumber().get();
22 } else if (value instanceof IpTunnelEndPoint) {
23 IpTunnelEndPoint cp = (IpTunnelEndPoint) value;
24 return cp.ip().toString();
25 }
26 return "";
27 }
28
29 /**
30 * An instance of this class.
31 */
32 public static final CellFormatter INSTANCE = new TunnelEndPointFormatter();
33}