Refactor construction of application objects
- Use a builder and make the constructors private for DefaultApplication
- Make DefaultApplication immutable
- Use a builder and make the constructors private for DefaultApplicationDescription
- Make DefaultApplicationDescription immutable
Change-Id: I9499981bd2c0f48aede40682260d51eeae2cab98
diff --git a/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java b/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java
index 92709cb..55c198e 100644
--- a/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java
+++ b/core/common/src/main/java/org/onosproject/common/app/ApplicationArchive.java
@@ -328,10 +328,22 @@
// put short description to description field
String desc = compactDescription(readme);
- return new DefaultApplicationDescription(name, version, title, desc, origin,
- category, url, readme, icon,
- role, perms, featuresRepo,
- features, requiredApps);
+ return DefaultApplicationDescription.builder()
+ .withName(name)
+ .withVersion(version)
+ .withTitle(title)
+ .withDescription(desc)
+ .withOrigin(origin)
+ .withCategory(category)
+ .withUrl(url)
+ .withReadme(readme)
+ .withIcon(icon)
+ .withRole(role)
+ .withPermissions(perms)
+ .withFeaturesRepo(featuresRepo)
+ .withFeatures(features)
+ .withRequiredApps(requiredApps)
+ .build();
}
// Expands the specified ZIP stream into app-specific directory.