Add javadoc for UserId.parse()

This commit is contained in:
Paul Schaub 2022-12-20 15:57:11 +01:00
parent 675efe8a37
commit f8f2af7d5e
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
1 changed files with 18 additions and 0 deletions

View File

@ -69,6 +69,24 @@ public final class UserId implements CharSequence {
}
}
/**
* Parse a {@link UserId} from free-form text, <pre>name-addr</pre> or <pre>mailbox</pre> string and split it
* up into its components.
* Example inputs for this method:
* <ul>
* <li><pre>john@pgpainless.org</pre></li>
* <li><pre>&lt;john@pgpainless.org&gt;</pre></li>
* <li><pre>John Doe</pre></li>
* <li><pre>John Doe &lt;john@pgpainless.org&gt;</pre></li>
* <li><pre>John Doe (work email) &lt;john@pgpainless.org&gt;</pre></li>
* </ul>
* In these cases, {@link #parse(String)} will detect email addresses, names and comments and expose those
* via the respective getters.
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc5322#page-16">RFC5322 §3.4. Address Specification</a>
* @param string user-id
* @return parsed {@link UserId} object
*/
public static UserId parse(@Nonnull String string) {
Builder builder = newBuilder();
string = string.trim();