blob: 8b74dd2062c5d03e65740b5c25387b7a9e00ed04 [file] [log] [blame]
Adnaan Sachidanandancf386b12017-08-09 15:12:45 -07001/*
2 * Copyright 2017-present Open Networking Foundation
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 */
16package org.onosproject.linkprops;
17
18import org.onosproject.net.Link;
19import org.onosproject.net.LinkKey;
20import org.onosproject.ui.topo.BiLink;
21import org.onosproject.ui.topo.LinkHighlight;
22import org.onosproject.ui.topo.LinkHighlight.Flavor;
23
24/**
25 * Our demo concrete class of a bi-link. We give it state so we can decide
26 * how to create link highlights.
27 */
28public class LpLink extends BiLink {
29
30 private boolean important = false;
31 private String label = null;
32
33 public LpLink(LinkKey key, Link link) {
34 super(key, link);
35 }
36
37 public LpLink makeImportant() {
38 important = true;
39 return this;
40 }
41
42 public LpLink setLabel(String label) {
43 this.label = label;
44 return this;
45 }
46
47 @Override
48 public LinkHighlight highlight(Enum<?> anEnum) {
49 Flavor flavor = important ? Flavor.PRIMARY_HIGHLIGHT
50 : Flavor.SECONDARY_HIGHLIGHT;
51 return new LinkHighlight(this.linkId(), flavor)
52 .setLabel(label);
53 }
54}