Code improvements for FDS scenarios
[groupbasedpolicy.git] / groupbasedpolicy / src / main / java / org / opendaylight / groupbasedpolicy / util / IidFactory.java
index b9a85bd55394bac5cfc88f24e9f19f145f9d4ecf..531156928daf102460b6a058dccb1ae872ebfc72 100644 (file)
@@ -8,9 +8,9 @@
 
 package org.opendaylight.groupbasedpolicy.util;
 
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.EndpointLocations;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoint.locations.AddressEndpointLocation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.endpoint.locations.AddressEndpointLocationKey;
@@ -115,6 +115,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.statistics
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.statistics.store.rev151215.statistics.store.StatisticRecord;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.statistics.store.rev151215.statistics.store.StatisticRecordKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 
 public class IidFactory {
 
@@ -129,96 +130,69 @@ public class IidFactory {
         return InstanceIdentifier.builder(Tenants.class).child(Tenant.class, new TenantKey(id)).build();
     }
 
-    public static InstanceIdentifier<EndpointGroup> endpointGroupIid(TenantId tenantId, EndpointGroupId epgId) {
+    public static InstanceIdentifierBuilder<Policy> policyIid(TenantId tenantId) {
         return InstanceIdentifier.builder(Tenants.class)
             .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(EndpointGroup.class, new EndpointGroupKey(epgId))
-            .build();
+            .child(Policy.class);
+    }
+
+    public static InstanceIdentifier<EndpointGroup> endpointGroupIid(TenantId tenantId, EndpointGroupId epgId) {
+        return policyIid(tenantId).child(EndpointGroup.class, new EndpointGroupKey(epgId)).build();
     }
 
     public static InstanceIdentifier<Contract> contractIid(TenantId tenantId, ContractId contractId) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(Contract.class, new ContractKey(contractId))
-            .build();
+        return policyIid(tenantId).child(Contract.class, new ContractKey(contractId)).build();
     }
 
     public static InstanceIdentifier<Contract> contractWildcardIid(TenantId tenantId) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(Contract.class)
-            .build();
+        return policyIid(tenantId).child(Contract.class).build();
     }
 
     public static InstanceIdentifier<Subject> subjectIid(TenantId tenantId, ContractId contractId,
             SubjectName subjectName) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(Contract.class, new ContractKey(contractId))
+        return policyIid(tenantId).child(Contract.class, new ContractKey(contractId))
             .child(Subject.class, new SubjectKey(subjectName))
             .build();
     }
 
     public static InstanceIdentifier<ProviderNamedSelector> providerNamedSelectorIid(TenantId tenantId,
             EndpointGroupId epgId, SelectorName providerSelectorName) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(EndpointGroup.class, new EndpointGroupKey(epgId))
+        return policyIid(tenantId).child(EndpointGroup.class, new EndpointGroupKey(epgId))
             .child(ProviderNamedSelector.class, new ProviderNamedSelectorKey(providerSelectorName))
             .build();
     }
 
     public static InstanceIdentifier<ConsumerNamedSelector> consumerNamedSelectorIid(TenantId tenantId,
             EndpointGroupId epgId, SelectorName consumerSelectorName) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(EndpointGroup.class, new EndpointGroupKey(epgId))
+        return policyIid(tenantId).child(EndpointGroup.class, new EndpointGroupKey(epgId))
             .child(ConsumerNamedSelector.class, new ConsumerNamedSelectorKey(consumerSelectorName))
             .build();
     }
 
     public static InstanceIdentifier<Clause> clauseIid(TenantId tenantId, ContractId contractId,
             ClauseName clauseName) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(Contract.class, new ContractKey(contractId))
+        return policyIid(tenantId).child(Contract.class, new ContractKey(contractId))
             .child(Clause.class, new ClauseKey(clauseName))
             .build();
     }
 
     public static InstanceIdentifier<Rule> ruleIid(TenantId tenantId, ContractId contractId, SubjectName subjectName,
             RuleName ruleName) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(Contract.class, new ContractKey(contractId))
+        return policyIid(tenantId).child(Contract.class, new ContractKey(contractId))
             .child(Subject.class, new SubjectKey(subjectName))
             .child(Rule.class, new RuleKey(ruleName))
             .build();
     }
 
     public static InstanceIdentifier<ActionInstance> actionInstanceIid(TenantId tenantId, ActionName actionName) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(SubjectFeatureInstances.class)
+        return policyIid(tenantId).child(SubjectFeatureInstances.class)
             .child(ActionInstance.class, new ActionInstanceKey(actionName))
             .build();
     }
 
     public static InstanceIdentifier<ClassifierInstance> classifierInstanceIid(TenantId tenantId,
             ClassifierName classifierName) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(SubjectFeatureInstances.class)
+        return policyIid(tenantId).child(SubjectFeatureInstances.class)
             .child(ClassifierInstance.class, new ClassifierInstanceKey(classifierName))
             .build();
     }
@@ -238,10 +212,7 @@ public class IidFactory {
 
     public static InstanceIdentifier<ClassifierRef> classifierRefIid(TenantId tenantId, ContractId contractId,
             SubjectName subjectName, RuleName ruleName, ClassifierName classifierRefName) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(Contract.class, new ContractKey(contractId))
+        return policyIid(tenantId).child(Contract.class, new ContractKey(contractId))
             .child(Subject.class, new SubjectKey(subjectName))
             .child(Rule.class, new RuleKey(ruleName))
             .child(ClassifierRef.class, new ClassifierRefKey(classifierRefName))
@@ -249,31 +220,35 @@ public class IidFactory {
     }
 
     @Deprecated
-    public static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2FloodDomain> l2FloodDomainIid(TenantId tenantId,
-            L2FloodDomainId l2FloodDomainId) {
+    public static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2FloodDomain> l2FloodDomainIid(
+            TenantId tenantId, L2FloodDomainId l2FloodDomainId) {
         return InstanceIdentifier.builder(Tenants.class)
             .child(Tenant.class, new TenantKey(tenantId))
             .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.ForwardingContext.class)
-            .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2FloodDomain.class, new L2FloodDomainKey(l2FloodDomainId))
+            .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2FloodDomain.class,
+                    new L2FloodDomainKey(l2FloodDomainId))
             .build();
     }
 
     @Deprecated
-    public static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2BridgeDomain> l2BridgeDomainIid(TenantId tenantId,
-            L2BridgeDomainId l2BridgeDomainId) {
+    public static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2BridgeDomain> l2BridgeDomainIid(
+            TenantId tenantId, L2BridgeDomainId l2BridgeDomainId) {
         return InstanceIdentifier.builder(Tenants.class)
             .child(Tenant.class, new TenantKey(tenantId))
             .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.ForwardingContext.class)
-            .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2BridgeDomain.class, new L2BridgeDomainKey(l2BridgeDomainId))
+            .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2BridgeDomain.class,
+                    new L2BridgeDomainKey(l2BridgeDomainId))
             .build();
     }
 
     @Deprecated
-    public static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L3Context> l3ContextIid(TenantId tenantId, L3ContextId l3ContextId) {
+    public static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L3Context> l3ContextIid(
+            TenantId tenantId, L3ContextId l3ContextId) {
         return InstanceIdentifier.builder(Tenants.class)
             .child(Tenant.class, new TenantKey(tenantId))
             .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.ForwardingContext.class)
-            .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L3Context.class, new L3ContextKey(l3ContextId))
+            .child(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L3Context.class,
+                    new L3ContextKey(l3ContextId))
             .build();
     }
 
@@ -384,11 +359,7 @@ public class IidFactory {
 
     public static InstanceIdentifier<ExternalImplicitGroup> externalImplicitGroupIid(TenantId tenantId,
             EndpointGroupId epgId) {
-        return InstanceIdentifier.builder(Tenants.class)
-            .child(Tenant.class, new TenantKey(tenantId))
-            .child(Policy.class)
-            .child(ExternalImplicitGroup.class, new ExternalImplicitGroupKey(epgId))
-            .build();
+        return policyIid(tenantId).child(ExternalImplicitGroup.class, new ExternalImplicitGroupKey(epgId)).build();
     }
 
     public static InstanceIdentifier<ContainmentEndpoint> containmentEndpointIid(ContainmentEndpointKey key) {
@@ -409,70 +380,73 @@ public class IidFactory {
             .build();
     }
 
-    public static InstanceIdentifier<AddressEndpointLocation> addressEndpointLocationIid(AddressEndpointLocationKey addrEndpointLocationKey) {
+    public static InstanceIdentifier<AddressEndpointLocation> addressEndpointLocationIid(
+            AddressEndpointLocationKey addrEndpointLocationKey) {
         return InstanceIdentifier.builder(EndpointLocations.class)
-                .child(AddressEndpointLocation.class, addrEndpointLocationKey)
-                .build();
+            .child(AddressEndpointLocation.class, addrEndpointLocationKey)
+            .build();
     }
 
-    public static InstanceIdentifier<ContainmentEndpointLocation> containmentEndpointLocationIid(ContainmentEndpointLocationKey addrEndpointLocationKey) {
+    public static InstanceIdentifier<ContainmentEndpointLocation> containmentEndpointLocationIid(
+            ContainmentEndpointLocationKey addrEndpointLocationKey) {
         return InstanceIdentifier.builder(EndpointLocations.class)
-                .child(ContainmentEndpointLocation.class, addrEndpointLocationKey)
-                .build();
+            .child(ContainmentEndpointLocation.class, addrEndpointLocationKey)
+            .build();
     }
 
-    public static InstanceIdentifier<InternalLocation> internalLocationIid(AddressEndpointLocationKey addrEndpointLocationKey,
-            InternalLocationKey internalLocationKey) {
+    public static InstanceIdentifier<InternalLocation> internalLocationIid(
+            AddressEndpointLocationKey addrEndpointLocationKey, InternalLocationKey internalLocationKey) {
         return InstanceIdentifier.builder(EndpointLocations.class)
-                .child(AddressEndpointLocation.class, addrEndpointLocationKey)
-                .child(RelativeLocations.class)
-                .child(InternalLocation.class, internalLocationKey)
-                .build();
+            .child(AddressEndpointLocation.class, addrEndpointLocationKey)
+            .child(RelativeLocations.class)
+            .child(InternalLocation.class, internalLocationKey)
+            .build();
     }
 
-    public static InstanceIdentifier<InternalLocation> internalLocationIid(ContainmentEndpointLocationKey contEndpointLocationKey,
-            InternalLocationKey internalLocationKey) {
+    public static InstanceIdentifier<InternalLocation> internalLocationIid(
+            ContainmentEndpointLocationKey contEndpointLocationKey, InternalLocationKey internalLocationKey) {
         return InstanceIdentifier.builder(EndpointLocations.class)
-                .child(ContainmentEndpointLocation.class, contEndpointLocationKey)
-                .child(RelativeLocations.class)
-                .child(InternalLocation.class, internalLocationKey)
-                .build();
+            .child(ContainmentEndpointLocation.class, contEndpointLocationKey)
+            .child(RelativeLocations.class)
+            .child(InternalLocation.class, internalLocationKey)
+            .build();
     }
 
-    public static InstanceIdentifier<ExternalLocation> externalLocationIid(AddressEndpointLocationKey addrEndpointLocationKey,
-            ExternalLocationKey externalLocationKey) {
+    public static InstanceIdentifier<ExternalLocation> externalLocationIid(
+            AddressEndpointLocationKey addrEndpointLocationKey, ExternalLocationKey externalLocationKey) {
         return InstanceIdentifier.builder(EndpointLocations.class)
-                .child(AddressEndpointLocation.class, addrEndpointLocationKey)
-                .child(RelativeLocations.class)
-                .child(ExternalLocation.class, externalLocationKey)
-                .build();
+            .child(AddressEndpointLocation.class, addrEndpointLocationKey)
+            .child(RelativeLocations.class)
+            .child(ExternalLocation.class, externalLocationKey)
+            .build();
     }
 
-    public static InstanceIdentifier<ExternalLocation> externalLocationIid(ContainmentEndpointLocationKey contEndpointLocationKey,
-            ExternalLocationKey externalLocationKey) {
+    public static InstanceIdentifier<ExternalLocation> externalLocationIid(
+            ContainmentEndpointLocationKey contEndpointLocationKey, ExternalLocationKey externalLocationKey) {
         return InstanceIdentifier.builder(EndpointLocations.class)
-                .child(ContainmentEndpointLocation.class, contEndpointLocationKey)
-                .child(RelativeLocations.class)
-                .child(ExternalLocation.class, externalLocationKey)
-                .build();
+            .child(ContainmentEndpointLocation.class, contEndpointLocationKey)
+            .child(RelativeLocations.class)
+            .child(ExternalLocation.class, externalLocationKey)
+            .build();
     }
 
-    public static InstanceIdentifier<AbsoluteLocation> absoluteLocationIid(AddressEndpointLocationKey addrEndpointLocationKey) {
+    public static InstanceIdentifier<AbsoluteLocation> absoluteLocationIid(
+            AddressEndpointLocationKey addrEndpointLocationKey) {
         return InstanceIdentifier.builder(EndpointLocations.class)
-                .child(AddressEndpointLocation.class, addrEndpointLocationKey)
-                .child(AbsoluteLocation.class)
-                .build();
+            .child(AddressEndpointLocation.class, addrEndpointLocationKey)
+            .child(AbsoluteLocation.class)
+            .build();
     }
 
     public static InstanceIdentifier<ProviderAddressEndpointLocation> providerAddressEndpointLocationIid(
             String provider, Class<? extends AddressType> addrType, String addr, Class<? extends ContextType> cType,
             ContextId containment) {
-        return providerAddressEndpointLocationIid(new ProviderName(provider),
+        return locationProviderIid(new ProviderName(provider),
                 new ProviderAddressEndpointLocationKey(addr, addrType, containment, cType));
     }
 
-    public static InstanceIdentifier<ProviderAddressEndpointLocation> providerAddressEndpointLocationIid(
-            ProviderName provider, ProviderAddressEndpointLocationKey providerAddressEndpointLocationKey) {
+    public static InstanceIdentifier<ProviderAddressEndpointLocation> locationProviderIid(ProviderName provider,
+            ProviderAddressEndpointLocationKey providerAddressEndpointLocationKey) {
         return locationProviderIid(provider).child(ProviderAddressEndpointLocation.class,
                 providerAddressEndpointLocationKey);
     }