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/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
index 6403019..fbdfa9c 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
@@ -16,7 +16,6 @@
package org.onosproject.net.intent.impl.compiler;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -89,14 +88,16 @@
}
}
- Set<ConnectPoint> egress = ImmutableSet.of(intent.egressPoint());
- Intent result = new LinkCollectionIntent(intent.appId(),
- intent.selector(), intent.treatment(),
- Sets.newHashSet(links.values()),
- intent.ingressPoints(),
- ImmutableSet.of(intent.egressPoint()),
- Collections.emptyList(),
- intent.priority());
+ Intent result = LinkCollectionIntent.builder()
+ .appId(intent.appId())
+ .selector(intent.selector())
+ .treatment(intent.treatment())
+ .links(Sets.newHashSet(links.values()))
+ .ingressPoints(intent.ingressPoints())
+ .egressPoints(ImmutableSet.of(intent.egressPoint()))
+ .priority(intent.priority())
+ .build();
+
return Arrays.asList(result);
}