Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HostUserDetails::email #436

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -196,7 +196,8 @@ private static HostUser asHostUser(JSONObject details) {
if (name == null) {
name = login;
}
return new HostUser(id, login, name);
var email = details.get("email").asString();
return new HostUser(id, login, name, email);
}

@Override
@@ -114,7 +114,8 @@ private HostUser parseUserDetails(JSONObject details) {
var id = details.get("id").asInt();
var username = details.get("username").asString();
var name = details.get("name").asString();
return new HostUser(id, username, name);
var email = details.get("email").asString();
return new HostUser(id, username, name, email);
}

@Override
@@ -23,32 +23,51 @@
package org.openjdk.skara.host;

import java.util.Objects;
import java.util.Optional;
import java.util.function.Supplier;

public class HostUser {
private final String id;
private final String username;
private final Supplier<String> nameSupplier;
private String name;
private String email;

public HostUser(String id, String username, Supplier<String> nameSupplier) {
public HostUser(String id, String username, Supplier<String> nameSupplier, String email) {
this.id = id;
this.username = username;
this.nameSupplier = nameSupplier;
this.email = email;
}

public HostUser(String id, String username, Supplier<String> nameSupplier) {
this(id, username, nameSupplier, null);
}

public HostUser(String id, String username, String name) {
this(id, username, () -> name);
}

public HostUser(String id, String username, String name, String email) {
this(id, username, () -> name, email);
}

public HostUser(int id, String username, String name) {
this(String.valueOf(id), username, name);
}

public HostUser(int id, String username, String name, String email) {
this(String.valueOf(id), username, name, email);
}

public HostUser(int id, String username, Supplier<String> nameSupplier) {
this(String.valueOf(id), username, nameSupplier);
}

public HostUser(int id, String username, Supplier<String> nameSupplier, String email) {
this(String.valueOf(id), username, nameSupplier, email);
}

@Override
public boolean equals(Object o) {
if (this == o) {
@@ -82,6 +101,10 @@ public String fullName() {
return name;
}

public Optional<String> email() {
return Optional.ofNullable(email);
}

@Override
public String toString() {
return "HostUserDetails{" +