summaryrefslogtreecommitdiffstats
path: root/core/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/slitopologyutils/topology/OtnLink.java
blob: 553a9bd264a7d42955adcc5920615c7863d201d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.onap.ccsdk.sli.core.slipluginutils.slitopologyutils.topology;

import java.util.Objects;

public class OtnLink implements Link{

    private final Type type = Type.OTN;
    private final PInterface src;
    private final PInterface dst;


    private final String linkName;

    public OtnLink(String linkName, PInterface src, PInterface dst){
        this.linkName = linkName;
        this.src = src;
        this.dst = dst;
    }

    public PInterface src() {
        return src;
    }

    public PInterface dst() {
        return dst;
    }

    public String linkName() {
        return linkName;
    }

    public boolean isInnerDomain(){
        if (src != null && dst != null){
            if (src.pInterfaceName() != null && dst.pInterfaceName() != null){
                if (src.pInterfaceName().getNetworkId() != null
                    && dst.pInterfaceName().getNetworkId() != null) {
                    return src.pInterfaceName().getNetworkId().equals(dst.pInterfaceName().getNetworkId());
                }
            }
        }
        return false;
    }

    @Override
    public boolean equals(Object o){
        if (this == o) {
            return true;
        }
        if (o instanceof OtnLink){
            final OtnLink other = (OtnLink) o;
            return  Objects.equals(this.linkName, other.linkName);
        }
        return false;
    }

    @Override
    public int hashCode(){
        return Objects.hash(linkName, type, src, dst);
    }
}