Skip to content

Commit

Permalink
cache login in GhUser
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Nov 19, 2013
1 parent f377f91 commit 61988d0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/com/jcabi/github/GhUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ final class GhUser implements User {
*/
private final transient Request request;

/**
* Login of the user.
*/
private final transient String self;

/**
* Public ctor.
* @param github Github
Expand All @@ -86,6 +91,7 @@ final class GhUser implements User {
} else {
this.request = req.uri().path("/users").path(login).back();
}
this.self = login;
}

@Override
Expand All @@ -100,7 +106,13 @@ public Github github() {

@Override
public String login() throws IOException {
return this.json().getString("login");
final String login;
if (this.self.isEmpty()) {
login = this.json().getString("login");
} else {
login = this.self;
}
return login;
}

@Override
Expand Down

0 comments on commit 61988d0

Please sign in to comment.