Ray Milkey
Committed by Gerrit Code Review

Eliminate code duplication in initialization

Change-Id: I067f2e0bb22bc24c3e3ac6ba24920c7ceebeee1e
...@@ -37,6 +37,20 @@ public class DefaultGroup extends DefaultGroupDescription ...@@ -37,6 +37,20 @@ public class DefaultGroup extends DefaultGroupDescription
37 private GroupId id; 37 private GroupId id;
38 38
39 /** 39 /**
40 + * Initializes default values.
41 + *
42 + * @param newId group id for new group
43 + */
44 + private void initialize(GroupId newId) {
45 + id = newId;
46 + state = GroupState.PENDING_ADD;
47 + life = 0;
48 + packets = 0;
49 + bytes = 0;
50 + referenceCount = 0;
51 + }
52 +
53 + /**
40 * Default group object constructor with the parameters. 54 * Default group object constructor with the parameters.
41 * 55 *
42 * @param id group identifier 56 * @param id group identifier
...@@ -44,12 +58,7 @@ public class DefaultGroup extends DefaultGroupDescription ...@@ -44,12 +58,7 @@ public class DefaultGroup extends DefaultGroupDescription
44 */ 58 */
45 public DefaultGroup(GroupId id, GroupDescription groupDesc) { 59 public DefaultGroup(GroupId id, GroupDescription groupDesc) {
46 super(groupDesc); 60 super(groupDesc);
47 - this.id = id; 61 + initialize(id);
48 - this.state = GroupState.PENDING_ADD;
49 - this.life = 0;
50 - this.packets = 0;
51 - this.bytes = 0;
52 - this.referenceCount = 0;
53 } 62 }
54 63
55 /** 64 /**
...@@ -66,12 +75,7 @@ public class DefaultGroup extends DefaultGroupDescription ...@@ -66,12 +75,7 @@ public class DefaultGroup extends DefaultGroupDescription
66 GroupDescription.Type type, 75 GroupDescription.Type type,
67 GroupBuckets buckets) { 76 GroupBuckets buckets) {
68 super(deviceId, type, buckets); 77 super(deviceId, type, buckets);
69 - this.id = id; 78 + initialize(id);
70 - this.state = GroupState.PENDING_ADD;
71 - this.life = 0;
72 - this.packets = 0;
73 - this.bytes = 0;
74 - this.referenceCount = 0;
75 } 79 }
76 80
77 /** 81 /**
......