Sho SHIMIZU

Use filter() to skip undesired instances

Change-Id: Ifc7cc5affe494c8573065cdcf7a018584e553a01
...@@ -86,8 +86,7 @@ public class PolicyHandler { ...@@ -86,8 +86,7 @@ public class PolicyHandler {
86 public List<Policy> getPolicies() { 86 public List<Policy> getPolicies() {
87 return policyStore.values() 87 return policyStore.values()
88 .stream() 88 .stream()
89 - // keep the original behavior, but it may cause a cast error 89 + .filter(policy -> policy instanceof TunnelPolicy)
90 - // it is better to use filter() to omit instances not being TunnelPolicy
91 .map(policy -> new TunnelPolicy((TunnelPolicy) policy)) 90 .map(policy -> new TunnelPolicy((TunnelPolicy) policy))
92 .collect(Collectors.toList()); 91 .collect(Collectors.toList());
93 } 92 }
......