class ImmutableAccessControlList implements AccessControlList {

    @Override
    public AccessControlList setEntry(final AclEntry aclEntry) {
        checkNotNull(aclEntry, "entry to be set to this ACL");

        final AccessControlList result;

        final AclEntry existingAclEntry = entries.get(aclEntry.getAuthorizationSubject());
        if (null != existingAclEntry) {
            if (existingAclEntry.equals(aclEntry)) {
                result = this;
            } else {
                final Map<AuthorizationSubject, AclEntry> entriesCopy = copyEntries();
                entriesCopy.put(aclEntry.getAuthorizationSubject(), aclEntry);
                result = new ImmutableAccessControlList(entriesCopy);
            }
        } else {
            final Map<AuthorizationSubject, AclEntry> entriesCopy = copyEntries();
            entriesCopy.put(aclEntry.getAuthorizationSubject(), aclEntry);
            result = new ImmutableAccessControlList(entriesCopy);
        }

        return result;
    }

    private  ImmutableAccessControlList(final Map<AuthorizationSubject, AclEntry> theEntries);
    private  ImmutableAccessControlList(final Collection<AclEntry> theEntries);

}