/*
   * (non-Javadoc)
   * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
   */
  public int compare(Attribute a, Attribute b) {
    int result = a.getId().toString().compareTo(b.getId().toString());

    if (result == 0) {
      result = a.getType().toString().compareTo(b.getType().toString());
    } else {
      return result;
    }

    if (result == 0) {
      result = a.getValue().encode().compareTo(b.getValue().encode());
    } else {
      return result;
    }

    if (result == 0 && (a.getIssueInstant() != null || b.getIssueInstant() != null)) {
      if (a.getIssueInstant() == null && b.getIssueInstant() == null) {
        result = 0;
      } else if (a.getIssueInstant() != null && b.getIssueInstant() == null) {
        result = 1;
      } else if (a.getIssueInstant() == null && b.getIssueInstant() != null) {
        result = -1;
      } else {
        result = a.getIssueInstant().encode().compareTo(b.getIssueInstant().encode());
      }
    }

    return result;
  }
 protected List<Subject> wrapSubjects(String subjectLoginId) {
   logger.debug("wrapSubjectIdAsSubjects(): {}", subjectLoginId);
   StringAttribute stringAttribute = EMPTY_ATTRIBUTE;
   Attribute subjectAttribute = SUBJECT_ATTRIBUTE;
   logger.debug(
       "wrapSubjectIdAsSubjects(): subjectAttribute, id={}, type={}, value={}",
       subjectAttribute.getId(),
       subjectAttribute.getType(),
       subjectAttribute.getValue());
   List<Attribute> subjectAttributes;
   if (subjectLoginId != null && !subjectLoginId.isEmpty()) {
     subjectAttributes = new ArrayList<Attribute>(2);
     subjectAttributes.add(subjectAttribute);
     stringAttribute = new StringAttribute(subjectLoginId);
     subjectAttribute = new SingletonAttribute(SUBJECT_ID_URI, null, null, stringAttribute);
     logger.debug(
         "wrapSubjectIdAsSubjects(): subjectAttribute, id={}, type={}, value={}",
         subjectAttribute.getId(),
         subjectAttribute.getType(),
         subjectAttribute.getValue());
     subjectAttributes.add(subjectAttribute);
   } else {
     subjectAttributes = new ArrayList<Attribute>(1);
     subjectAttributes.add(subjectAttribute);
   }
   Subject singleSubject = new Subject(subjectAttributes);
   return Collections.singletonList(singleSubject);
 }