@Test(expected = AssertionError.class) public void testExceptionSelfMemberRef() { a.setMembers(setOfA); }
@Override public void setMembers(Set<IPersonAttributesGroupDefinition> members) { assert (this.name != null); assert (!members.contains(this)); Set<IPersonAttributesGroupDefinition> checkedMembers = new HashSet<IPersonAttributesGroupDefinition>(); for (IPersonAttributesGroupDefinition group : members) { if (group.getDeepMembers().contains(this)) { final String message = "Recursion of group member found for " + name + ", member " + group.getName(); log.error(message); throw new IllegalArgumentException(message); } else { checkedMembers.add(group); } } this.members.clear(); this.members.addAll(checkedMembers); }
PersonAttributesGroupDefinitionImpl implements IPersonAttributesGroupDefinition { @Override public void setMembers(Set<IPersonAttributesGroupDefinition> members) { assert (this.name != null); assert (!members.contains(this)); Set<IPersonAttributesGroupDefinition> checkedMembers = new HashSet<IPersonAttributesGroupDefinition>(); for (IPersonAttributesGroupDefinition group : members) { if (group.getDeepMembers().contains(this)) { final String message = "Recursion of group member found for " + name + ", member " + group.getName(); log.error(message); throw new IllegalArgumentException(message); } else { checkedMembers.add(group); } } this.members.clear(); this.members.addAll(checkedMembers); } }
PersonAttributesGroupDefinitionImpl implements IPersonAttributesGroupDefinition { @Override public void setMembers(Set<IPersonAttributesGroupDefinition> members) { assert (this.name != null); assert (!members.contains(this)); Set<IPersonAttributesGroupDefinition> checkedMembers = new HashSet<IPersonAttributesGroupDefinition>(); for (IPersonAttributesGroupDefinition group : members) { if (group.getDeepMembers().contains(this)) { final String message = "Recursion of group member found for " + name + ", member " + group.getName(); log.error(message); throw new IllegalArgumentException(message); } else { checkedMembers.add(group); } } this.members.clear(); this.members.addAll(checkedMembers); } PersonAttributesGroupDefinitionImpl();  PersonAttributesGroupDefinitionImpl(String name, String description); }
PersonAttributesGroupDefinitionImpl implements IPersonAttributesGroupDefinition { @Override public void setMembers(Set<IPersonAttributesGroupDefinition> members) { assert (this.name != null); assert (!members.contains(this)); Set<IPersonAttributesGroupDefinition> checkedMembers = new HashSet<IPersonAttributesGroupDefinition>(); for (IPersonAttributesGroupDefinition group : members) { if (group.getDeepMembers().contains(this)) { final String message = "Recursion of group member found for " + name + ", member " + group.getName(); log.error(message); throw new IllegalArgumentException(message); } else { checkedMembers.add(group); } } this.members.clear(); this.members.addAll(checkedMembers); } PersonAttributesGroupDefinitionImpl();  PersonAttributesGroupDefinitionImpl(String name, String description); @Override @JsonIgnore long getId(); @Override @JsonIgnore EntityIdentifier getCompositeEntityIdentifierForGroup(); @Override String getName(); @Override void setName(String name); @Override String getDescription(); @Override void setDescription(String description); @Override Set<IPersonAttributesGroupDefinition> getMembers(); @Override Set<IPersonAttributesGroupDefinition> getDeepMembers(); @Override Set<IPersonAttributesGroupDefinition> getDeepMembers(
            Set<IPersonAttributesGroupDefinition> seen); @Override void setMembers(Set<IPersonAttributesGroupDefinition> members); @Override Set<IPersonAttributesGroupTestGroupDefinition> getTestGroups(); @Override void setTestGroups(Set<IPersonAttributesGroupTestGroupDefinition> testGroups); @Override void toElement(org.dom4j.Element parent); }
PersonAttributesGroupDefinitionImpl implements IPersonAttributesGroupDefinition { @Override public void setMembers(Set<IPersonAttributesGroupDefinition> members) { assert (this.name != null); assert (!members.contains(this)); Set<IPersonAttributesGroupDefinition> checkedMembers = new HashSet<IPersonAttributesGroupDefinition>(); for (IPersonAttributesGroupDefinition group : members) { if (group.getDeepMembers().contains(this)) { final String message = "Recursion of group member found for " + name + ", member " + group.getName(); log.error(message); throw new IllegalArgumentException(message); } else { checkedMembers.add(group); } } this.members.clear(); this.members.addAll(checkedMembers); } PersonAttributesGroupDefinitionImpl();  PersonAttributesGroupDefinitionImpl(String name, String description); @Override @JsonIgnore long getId(); @Override @JsonIgnore EntityIdentifier getCompositeEntityIdentifierForGroup(); @Override String getName(); @Override void setName(String name); @Override String getDescription(); @Override void setDescription(String description); @Override Set<IPersonAttributesGroupDefinition> getMembers(); @Override Set<IPersonAttributesGroupDefinition> getDeepMembers(); @Override Set<IPersonAttributesGroupDefinition> getDeepMembers(
            Set<IPersonAttributesGroupDefinition> seen); @Override void setMembers(Set<IPersonAttributesGroupDefinition> members); @Override Set<IPersonAttributesGroupTestGroupDefinition> getTestGroups(); @Override void setTestGroups(Set<IPersonAttributesGroupTestGroupDefinition> testGroups); @Override void toElement(org.dom4j.Element parent);  }