GroupPrincipals { public static boolean isGroup(@NotNull Principal principal) { return principal instanceof GroupPrincipal; } private  GroupPrincipals(); static boolean isGroup(@NotNull Principal principal); @NotNull static Enumeration<? extends Principal> members(@NotNull Principal principal); static boolean isMember(@NotNull Principal principal, @NotNull Principal member);  }
@Test public void testIsGroup() { Principal p0 = new PrincipalImpl("test"); assertFalse(GroupPrincipals.isGroup(p0)); GroupPrincipal g = new GroupPrincipal() { @Override public String getName() { return "testG"; } @Override public Enumeration<? extends Principal> members() { throw new UnsupportedOperationException(); } @Override public boolean isMember(Principal member) { return false; } }; assertTrue(GroupPrincipals.isGroup(g)); }