chengfan | 392e8f9 | 2015-08-21 13:20:02 -0500 | [diff] [blame] | 1 | package org.onosproject.incubator.net.tunnel; |
| 2 | |
| 3 | |
| 4 | import org.onosproject.ui.table.CellFormatter; |
| 5 | import 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 | */ |
| 11 | public 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 | } |