Yuta HIGUCHI

minor changes to RoleValue

Change-Id: Id870843c53549439e88ada40e8b2ef5513b8e4b7
package org.onlab.onos.store.mastership.impl;
import java.util.Collections;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
......@@ -17,9 +17,9 @@ import com.google.common.base.MoreObjects.ToStringHelper;
* A structure that holds node mastership roles associated with a
* {@link DeviceId}. This structure needs to be locked through IMap.
*/
public class RoleValue {
final class RoleValue {
protected Map<MastershipRole, List<NodeId>> value = new HashMap<>();
protected final Map<MastershipRole, List<NodeId>> value = new EnumMap<>(MastershipRole.class);
public RoleValue() {
value.put(MastershipRole.MASTER, new LinkedList<NodeId>());
......@@ -27,7 +27,8 @@ public class RoleValue {
value.put(MastershipRole.NONE, new LinkedList<NodeId>());
}
public Map<MastershipRole, List<NodeId>> value() {
// exposing internals for serialization purpose only
Map<MastershipRole, List<NodeId>> value() {
return Collections.unmodifiableMap(value);
}
......
......@@ -35,10 +35,10 @@ public class RoleValueSerializer extends Serializer<RoleValue> {
@Override
public void write(Kryo kryo, Output output, RoleValue type) {
output.writeInt(type.value().size());
final Map<MastershipRole, List<NodeId>> map = type.value();
output.writeInt(map.size());
for (Map.Entry<MastershipRole, List<NodeId>> el :
type.value().entrySet()) {
for (Map.Entry<MastershipRole, List<NodeId>> el : map.entrySet()) {
output.writeInt(el.getKey().ordinal());
List<NodeId> nodes = el.getValue();
......