1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-23 19:38:00 +01:00

Make UserId constructor private in favor of factory methods

This commit is contained in:
Paul Schaub 2021-01-18 18:12:53 +01:00
parent 2ad944977d
commit 1ce28a09af
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -15,13 +15,13 @@
*/ */
package org.pgpainless.key.util; package org.pgpainless.key.util;
public class UserId implements CharSequence { public final class UserId implements CharSequence {
private final String name; private final String name;
private final String comment; private final String comment;
private final String email; private final String email;
public UserId(String name, String comment, String email) { private UserId(String name, String comment, String email) {
this.name = name; this.name = name;
this.comment = comment; this.comment = comment;
this.email = email; this.email = email;
@ -49,6 +49,10 @@ public class UserId implements CharSequence {
return new UserId(null, null, email); return new UserId(null, null, email);
} }
public static UserId nameAndEmail(String name, String email) {
return withName(name).noComment().withEmail(email);
}
public static WithComment withName(String name) { public static WithComment withName(String name) {
if (name == null) { if (name == null) {
throw new IllegalArgumentException("Name must not be null."); throw new IllegalArgumentException("Name must not be null.");