/**
  * Helper method for subclasses to implement getFooAttribute(String attributeName), as such:
  *
  * <pre>
  * public class User
  * {
  *     private final Set<UserAttribute> userAttributes = new HashSet<UserAttribute>();
  *
  *     public String getUserAttribute(String attributeName)
  *     {
  *         return PersistentAttribute.getAttribute(userAttributes, attributeName);
  *     }
  * }
  * </pre>
  *
  * @param attributeSet the set of objects derived from PersistentAttribute to turn into a
  *     Map<String,String>
  * @param attributeName the name of the desired attribute
  * @return the attribute value or null if the attribute does not exist
  */
 public static <OwnerClass, AttributeClass extends PersistentAttribute<OwnerClass>>
     String getAttribute(Set<AttributeClass> attributeSet, String attributeName) {
   for (AttributeClass attribute : attributeSet) {
     if (attribute.getName().equals(attributeName)) return attribute.getValue();
   }
   return null;
 }
 /**
  * Helper method for subclasses to implement getFooAttributes(), as such:
  *
  * <pre>
  * public class User
  * {
  *     private final Set<UserAttribute> userAttributes = new HashSet<UserAttribute>();
  *
  *     public Map<String,String> getUserAttributes()
  *     {
  *         return PersistentAttribute.buildMap(userAttributes);
  *     }
  * }
  * </pre>
  *
  * @param attributeSet the set of objects derived from PersistentAttribute to turn into a
  *     Map<String,String>
  * @return an unmodifiable Map representing the attributes attached to the object
  */
 public static <OwnerClass, AttributeClass extends PersistentAttribute<OwnerClass>>
     Map<String, String> buildMap(Set<AttributeClass> attributeSet) {
   Map<String, String> map = new HashMap<String, String>(attributeSet.size());
   for (AttributeClass attribute : attributeSet) {
     map.put(attribute.getName(), attribute.getValue());
   }
   return Collections.unmodifiableMap(map);
 }