Eliminate code duplication in initialization
Change-Id: I067f2e0bb22bc24c3e3ac6ba24920c7ceebeee1e
diff --git a/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java b/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java
index c52f771..546a451 100644
--- a/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java
+++ b/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java
@@ -37,6 +37,20 @@
private GroupId id;
/**
+ * Initializes default values.
+ *
+ * @param newId group id for new group
+ */
+ private void initialize(GroupId newId) {
+ id = newId;
+ state = GroupState.PENDING_ADD;
+ life = 0;
+ packets = 0;
+ bytes = 0;
+ referenceCount = 0;
+ }
+
+ /**
* Default group object constructor with the parameters.
*
* @param id group identifier
@@ -44,12 +58,7 @@
*/
public DefaultGroup(GroupId id, GroupDescription groupDesc) {
super(groupDesc);
- this.id = id;
- this.state = GroupState.PENDING_ADD;
- this.life = 0;
- this.packets = 0;
- this.bytes = 0;
- this.referenceCount = 0;
+ initialize(id);
}
/**
@@ -66,12 +75,7 @@
GroupDescription.Type type,
GroupBuckets buckets) {
super(deviceId, type, buckets);
- this.id = id;
- this.state = GroupState.PENDING_ADD;
- this.life = 0;
- this.packets = 0;
- this.bytes = 0;
- this.referenceCount = 0;
+ initialize(id);
}
/**