private UserGroupRestRep update() {
      UserGroupUpdateParam param = new UserGroupUpdateParam();
      UserGroupRestRep userGroupRestRep = UserGroupUtils.getUserGroup(this.id);

      param.setLabel(userGroupRestRep.getName());
      param.setDomain(this.domain);

      Set<UserAttributeParam> oldAttributes = userGroupRestRep.getAttributes();
      Set<UserAttributeParam> newAttributes = new HashSet<UserAttributeParam>();
      for (AttributeMapping mapping : this.attributes) {
        if (mapping != null) {
          newAttributes.add(mapping.createUserAttributeParam());
        }
      }

      param.getAddAttributes().addAll(newAttributes);
      param.getAddAttributes().removeAll(oldAttributes);

      for (UserAttributeParam oldAttribute : oldAttributes) {
        param.getRemoveAttributes().add(oldAttribute.getKey());
      }

      for (UserAttributeParam newAttribute : newAttributes) {
        param.getRemoveAttributes().remove(newAttribute.getKey());
      }

      return UserGroupUtils.update(this.id, param);
    }
    private UserGroupRestRep create() {
      UserGroupCreateParam param = new UserGroupCreateParam();
      param.setLabel(this.name);
      param.setDomain(this.domain);
      for (AttributeMapping mapping : this.attributes) {
        if (mapping != null) {
          param.getAttributes().add(mapping.createUserAttributeParam());
        }
      }

      return UserGroupUtils.create(param);
    }