This might be somewhat surprising behavior to users who might naturally assume the following invariant: ident.equals(parseIdent(ident.toExternalString())) This invariant does not hold since whitespace is only trimmed during serialization. We don't want to mess with the strings during initialization, as this is called during the highly-optimized commit parsing codepath. Change-Id: I081a603f0ac0e33167462244779b0ff3ad51e80ctags/v4.4.0.201605041135-m1
PersonIdent personIdent = new PersonIdent(" A U Thor ", | PersonIdent personIdent = new PersonIdent(" A U Thor ", | ||||
" author@example.com "); | " author@example.com "); | ||||
String externalString = personIdent.toExternalString(); | |||||
assertEquals(" A U Thor ", personIdent.getName()); | |||||
assertEquals(" author@example.com ", personIdent.getEmailAddress()); | |||||
String externalString = personIdent.toExternalString(); | |||||
assertTrue(externalString.startsWith("A U Thor <author@example.com>")); | assertTrue(externalString.startsWith("A U Thor <author@example.com>")); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Construct a {@link PersonIdent} | |||||
* Construct a {@link PersonIdent}. | |||||
* <p> | |||||
* Whitespace in the name and email is preserved for the lifetime of this | |||||
* object, but are trimmed by {@link #toExternalString()}. This means that | |||||
* parsing the result of {@link #toExternalString()} may not return an | |||||
* equivalent instance. | |||||
* | * | ||||
* @param aName | * @param aName | ||||
* @param aEmailAddress | * @param aEmailAddress |