mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-10 18:59:39 +02:00
Add more documentation
This commit is contained in:
parent
50d31eb463
commit
df7505eadb
7 changed files with 213 additions and 22 deletions
33
docs/source/pgpainless-core/userids.md
Normal file
33
docs/source/pgpainless-core/userids.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
# User-IDs
|
||||
|
||||
User-IDs are identities that users go by. A User-ID might be a name, an email address or both.
|
||||
User-IDs can also contain both and even have a comment.
|
||||
|
||||
In general, the format of a User-ID is not fixed, so it can contain arbitrary strings.
|
||||
However, it is agreed upon to use the
|
||||
Below is a selection of possible User-IDs:
|
||||
|
||||
```
|
||||
Firstname Lastname <email@address.tld> [Comment]
|
||||
Firstname Lastname
|
||||
Firstname Lastname [Comment]
|
||||
<email@address.tld>
|
||||
<email@address.tld> [Comment]
|
||||
```
|
||||
|
||||
PGPainless comes with a builder class `UserId`, which can be used to safely construct User-IDs:
|
||||
|
||||
```java
|
||||
UserId nameAndEMail = UserId.nameAndEmail("Jane Doe", "jane@pgpainless.org");
|
||||
assertEquals("Jane Doe <jane@pgpainless.org>", nameAndEmail.toString()):
|
||||
|
||||
UserId onlyEmail = UserId.onlyEmail("john@pgpainless.org");
|
||||
assertEquals("<john@pgpainless.org>", onlyEmail.toString());
|
||||
|
||||
UserId full = UserId.newBuilder()
|
||||
.withName("Peter Pattern")
|
||||
.withEmail("peter@pgpainless.org")
|
||||
.withComment("Work Address")
|
||||
.build();
|
||||
assertEquals("Peter Pattern <peter@pgpainless.org> [Work Address]", full.toString());
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue