Refactor: extract interfaces for a set of simple fabric classes
Change-Id: I4a23fb2277498f466ce20f82e38d5e9cb25dab6e
diff --git a/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricSubnet.java b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricSubnet.java
new file mode 100644
index 0000000..2e7ba3c
--- /dev/null
+++ b/apps/simplefabric/api/src/main/java/org/onosproject/simplefabric/api/FabricSubnet.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.simplefabric.api;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.EncapsulationType;
+
+/**
+ * Interface of FabricSubnet.
+ */
+public interface FabricSubnet {
+
+ /**
+ * Gets the IP subnet of the IP subnet entry.
+ *
+ * @return the IP subnet
+ */
+ IpPrefix prefix();
+
+ /**
+ * Gets the virtual gateway IP address of the IP subnet entry.
+ *
+ * @return the virtual gateway IP address
+ */
+ IpAddress gatewayIp();
+
+ /**
+ * Gets the virtual gateway Mac address of the IP subnet entry.
+ *
+ * @return the virtuai gateway Mac address
+ */
+ MacAddress gatewayMac();
+
+ /**
+ * Gets the encapsulation type of IP subnet entry.
+ *
+ * @return the encapsulation type
+ */
+ EncapsulationType encapsulation();
+
+ /**
+ * Gets the subnet name.
+ *
+ * @return the subnet name
+ */
+ String name();
+
+ /**
+ * Tests whether the IP version of this entry is IPv4.
+ *
+ * @return true if the IP version of this entry is IPv4, otherwise false.
+ */
+ boolean isIp4();
+
+ /**
+ * Tests whether the IP version of this entry is IPv6.
+ *
+ * @return true if the IP version of this entry is IPv6, otherwise false.
+ */
+ boolean isIp6();
+
+ /**
+ * Builder of Ip Subnet.
+ */
+ interface Builder {
+
+ /**
+ * Returns FabricSubnet builder with supplied IpPrefix.
+ *
+ * @param ipPrefix IP prefix
+ * @return FabricSubnet instance builder
+ */
+ Builder ipPrefix(IpPrefix ipPrefix);
+
+ /**
+ * Returns FabricSubnet builder with supplied gatewayIp.
+ *
+ * @param gatewayIp gateway IP
+ * @return FabricSubnet instance builder
+ */
+ Builder gatewayIp(IpAddress gatewayIp);
+
+ /**
+ * Returns FabricSubnet builder with supplied gatewayMac.
+ *
+ * @param gatewayMac gateway MAC
+ * @return FabricSubnet instance builder
+ */
+ Builder gatewayMac(MacAddress gatewayMac);
+
+ /**
+ * Returns FabricSubnet builder with supplied encapsulation type.
+ *
+ * @param encapsulation encapsulation type
+ * @return FabricSubnet instance builder
+ */
+ Builder encapsulation(EncapsulationType encapsulation);
+
+ /**
+ * Returns FabricSubnet builder with supplied subnet name.
+ *
+ * @param name subnet name
+ * @return FabricSubnet instance builder
+ */
+ Builder name(String name);
+
+ /**
+ * Builds an immutable FabricSubnet instance.
+ *
+ * @return FabricSubnet instance
+ */
+ FabricSubnet build();
+ }
+}