@Test public void whenHierarchyHasPermission() { Rank a = createRank("a"); Rank b = createRank("b"); Rank c = createRank("c"); Rank d = createRank("d"); d.setChild(c); c.setChild(b); b.setChild(a); assertTrue(d.hasPermission("perm.a.a")); assertTrue(c.hasPermission("perm.a.b")); assertTrue(d.hasPermission("perm.d.a")); assertTrue(b.hasPermission("perm.a.a")); assertTrue(b.hasPermission("perm.a.b")); assertFalse(b.hasPermission("perm.c.a.a")); assertFalse(b.hasPermission("perm.c.a.b")); }
public boolean hasPermission(String permission) { return operator || permissions.contains(permission) || child != null && child.hasPermission(permission); }
Rank { public boolean hasPermission(String permission) { return operator || permissions.contains(permission) || child != null && child.hasPermission(permission); } }
Rank { public boolean hasPermission(String permission) { return operator || permissions.contains(permission) || child != null && child.hasPermission(permission); }  }
Rank { public boolean hasPermission(String permission) { return operator || permissions.contains(permission) || child != null && child.hasPermission(permission); }  boolean hasPermission(String permission); }
Rank { public boolean hasPermission(String permission) { return operator || permissions.contains(permission) || child != null && child.hasPermission(permission); }  boolean hasPermission(String permission);  }