/*
  * (non-Javadoc)
  *
  * @see org.picketlink.idm.model.IdentityType#removeAttribute(java.lang.String)
  */
 @SuppressWarnings("unchecked")
 @Override
 @Transient
 public void removeAttribute(String name) {
   getUserAttributesMap().remove(name);
   for (AbstractDatabaseAttribute attribute :
       new ArrayList<AbstractDatabaseAttribute>(getOwnerAttributes())) {
     if (attribute.getName().equals(name)) {
       attribute.setIdentityType(null);
       getOwnerAttributes().remove(attribute);
     }
   }
 }
  /**
   * This method converts the {@link List} of the attributes associated with this type into a {@link
   * Map}.
   *
   * @return
   */
  private Map<String, String[]> getUserAttributesMap() {
    if (this.userAttributesMap == null) {
      this.userAttributesMap = new HashMap<String, String[]>();

      for (AbstractDatabaseAttribute attribute : getOwnerAttributes()) {
        String[] values = this.userAttributesMap.get(attribute.getName());

        if (values == null) {
          values = new String[] {attribute.getValue()};
        } else {
          int len = values.length;

          values = Arrays.copyOf(values, len + 1);

          values[len] = attribute.getValue();
        }

        this.userAttributesMap.put(attribute.getName(), values);
      }
    }

    return this.userAttributesMap;
  }