aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java')
-rw-r--r--framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java39
1 files changed, 34 insertions, 5 deletions
diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
index b9d3eadf..e2109689 100644
--- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
+++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/intf/Interface.java
@@ -30,11 +30,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* An Interface maps network configuration information (such as addresses and
- * vlans) to a port in the network. This is considered a L2/L3 network
- * interface.
+ * vlans) to a port in the network.
*/
@Beta
public class Interface {
+ public static final String NO_INTERFACE_NAME = "";
+
+ private final String name;
private final ConnectPoint connectPoint;
private final Set<InterfaceIpAddress> ipAddresses;
private final MacAddress macAddress;
@@ -43,14 +45,16 @@ public class Interface {
/**
* Creates new Interface with the provided configuration.
*
+ * @param name name of the interface
* @param connectPoint the connect point this interface maps to
* @param ipAddresses Set of IP addresses
* @param macAddress MAC address
* @param vlan VLAN ID
*/
- public Interface(ConnectPoint connectPoint,
+ public Interface(String name, ConnectPoint connectPoint,
Set<InterfaceIpAddress> ipAddresses,
MacAddress macAddress, VlanId vlan) {
+ this.name = name == null ? NO_INTERFACE_NAME : name;
this.connectPoint = checkNotNull(connectPoint);
this.ipAddresses = ipAddresses == null ? Sets.newHashSet() : ipAddresses;
this.macAddress = macAddress == null ? MacAddress.NONE : macAddress;
@@ -58,6 +62,29 @@ public class Interface {
}
/**
+ * Creates new Interface with the provided configuration.
+ *
+ * @param connectPoint the connect point this interface maps to
+ * @param ipAddresses Set of IP addresses
+ * @param macAddress MAC address
+ * @param vlan VLAN ID
+ */
+ public Interface(ConnectPoint connectPoint,
+ Set<InterfaceIpAddress> ipAddresses,
+ MacAddress macAddress, VlanId vlan) {
+ this(NO_INTERFACE_NAME, connectPoint, ipAddresses, macAddress, vlan);
+ }
+
+ /**
+ * Retrieves the name of the interface.
+ *
+ * @return name
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
* Retrieves the connection point that this interface maps to.
*
* @return the connection point
@@ -101,7 +128,8 @@ public class Interface {
Interface otherInterface = (Interface) other;
- return Objects.equals(connectPoint, otherInterface.connectPoint) &&
+ return Objects.equals(name, otherInterface.name) &&
+ Objects.equals(connectPoint, otherInterface.connectPoint) &&
Objects.equals(ipAddresses, otherInterface.ipAddresses) &&
Objects.equals(macAddress, otherInterface.macAddress) &&
Objects.equals(vlan, otherInterface.vlan);
@@ -109,12 +137,13 @@ public class Interface {
@Override
public int hashCode() {
- return Objects.hash(connectPoint, ipAddresses, macAddress, vlan);
+ return Objects.hash(connectPoint, name, ipAddresses, macAddress, vlan);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
+ .add("name", name)
.add("connectPoint", connectPoint)
.add("ipAddresses", ipAddresses)
.add("macAddress", macAddress)