RFR: 24: Allow lazy evaluation of the fullName field in HostUserDetails

Erik Duveblad via github.com duke at openjdk.java.net
Thu Jun 27 13:20:29 UTC 2019


On Thu, 27 Jun 2019 12:01:28 GMT, Robin Westberg via github.com <duke at openjdk.java.net> wrote:

> Hi all,
> 
> Please review the following change that allows lazy evaluation of the fullName field in HostUserDetails. Most GitHub API calls only return the id and username, so to populate the full name we have to do a separate request. However, the full name is rarely used, so we can save a few API calls by only fetching it when needed.
> 
> Best regards,
> Robin
> 
> ----------------
> 
> Commits:
>  - 54d7f40a:	Allow lazy evaluation of the fullName field in HostUserDetails
> 
> Pull request:
> http://git.openjdk.java.net/skara/pull/9
> 
> Webrev:
> https://openjdk.github.io/cr/skara/9/webrev.00
> 
> Patch:
> http://git.openjdk.java.net/skara/pull/9.diff
> 
> Fetch command:
> git fetch https://github.com/openjdk/skara.git 54d7f40a:pr/9

host/src/main/java/org/openjdk/skara/host/HostUserDetails.java line 26:

> 25: import java.util.Objects;
> 26: import java.util.function.Supplier;
> 27: 

Nice improvement, but `fullName` can now be as simple as:
```java
public String fullName() {
    if (name == null) {
        name = nameSupplier.get();
    }
    return name;
}
```


More information about the skara-dev mailing list