Created
June 18, 2019 17:17
-
-
Save Dimanaux/7cf4d1c4e6e3a3a856b0c2cf4c40eebc to your computer and use it in GitHub Desktop.
May be it is an OOP solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Account { | |
private String email; | |
private String password; | |
// single method | |
public UserDetails asDetails() { | |
return new AccountDetails() { | |
@Override public String getPassword() { | |
return Account.this.password; | |
} | |
@Override public String getUsername() { | |
return Account.this.email; | |
} | |
}; | |
} | |
} | |
abstract class AccountDetails implements UserDetails { | |
public final Account account; | |
public AccountDetails(Account account) { this.account = account; } | |
// template code vvv | |
@Override public Collection<? extends GrantedAuthority> getAuthorities() { return null; } | |
@Override public boolean isAccountNonExpired() { return true; } | |
@Override public boolean isAccountNonLocked() { return true; } | |
@Override public boolean isCredentialsNonExpired() { return true; } | |
@Override public boolean isEnabled() { return true; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment