Refactor connectivity intent creation to use builders
- Each connectivity intent now has only one constructor
- Intent constructors are now private for leaf classes and
protected for classes that can be derived from
- Each intent class has a Builder class that accumulates
parameters for intent creation
- Each intent class has a public static builder() method
to create a builder
- Each Builder class has a build() method to create the
intent from the accumulated parameters
- Added keys to a few intent types that were missing them
- Tightened up usage of checkNotNull(), taking advantage of
the return value to save some lines of code
- Modified callers to use the builders instead of directly
calling the constructors
Change-Id: I713185d5ecbadbf51f87ef7f68fec41102106c78
diff --git a/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java b/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
index 9f29c1b..7625af6 100644
--- a/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
+++ b/apps/sdnip/src/test/java/org/onosproject/sdnip/IntentSyncTest.java
@@ -233,9 +233,13 @@
ingressPoints.add(SW4_ETH1);
MultiPointToSinglePointIntent intent =
- new MultiPointToSinglePointIntent(APPID,
- selectorBuilder.build(), treatmentBuilder.build(),
- ingressPoints, SW1_ETH1);
+ MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(selectorBuilder.build())
+ .treatment(treatmentBuilder.build())
+ .ingressPoints(ingressPoints)
+ .egressPoint(SW1_ETH1)
+ .build();
// Setup the expected intents
intentService.submit(eqExceptId(intent));
@@ -291,9 +295,13 @@
ingressPoints.add(SW3_ETH1);
MultiPointToSinglePointIntent intent =
- new MultiPointToSinglePointIntent(APPID,
- selectorBuilder.build(), treatmentBuilder.build(),
- ingressPoints, SW4_ETH1);
+ MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(selectorBuilder.build())
+ .treatment(treatmentBuilder.build())
+ .ingressPoints(ingressPoints)
+ .egressPoint(SW4_ETH1)
+ .build();
// Setup the expected intents
intentService.submit(eqExceptId(intent));
@@ -357,10 +365,13 @@
ingressPointsNew.add(SW4_ETH1);
MultiPointToSinglePointIntent intentNew =
- new MultiPointToSinglePointIntent(APPID,
- selectorBuilderNew.build(),
- treatmentBuilderNew.build(),
- ingressPointsNew, SW2_ETH1);
+ MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(selectorBuilderNew.build())
+ .treatment(treatmentBuilderNew.build())
+ .ingressPoints(ingressPointsNew)
+ .egressPoint(SW2_ETH1)
+ .build();
// Set up test expectation
reset(intentService);
@@ -592,9 +603,13 @@
}
}
MultiPointToSinglePointIntent intent =
- new MultiPointToSinglePointIntent(APPID,
- selectorBuilder.build(), treatmentBuilder.build(),
- ingressPoints, egressPoint);
+ MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(selectorBuilder.build())
+ .treatment(treatmentBuilder.build())
+ .ingressPoints(ingressPoints)
+ .egressPoint(egressPoint)
+ .build();
return intent;
}