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

This replaces the redundant if statements with OOP best practices #128

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions src/main/java/com/bunq/sdk/context/SessionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,7 @@ public class SessionContext implements java.io.Serializable {
}

private int getUserId(BunqModel user) {
if (user instanceof UserPerson) {
return ((UserPerson) user).getId();
} else if (user instanceof UserCompany) {
return ((UserCompany) user).getId();
} else if (user instanceof UserApiKey) {
return ((UserApiKey) user).getId();
} else if (user instanceof UserPaymentServiceProvider) {
return ((UserPaymentServiceProvider) user).getId();
} else {
throw new BunqException(
String.format(
ERROR_UNEXPECTED_USER_TYPE, user.getClass().toString()
)
);
}
return user.getId();
}

private static Date calculateExpiryTime(SessionServer sessionServer) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/bunq/sdk/model/core/BunqModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,7 @@ protected static byte[] determineAllRequestByte(HashMap<String, Object> requestM

return requestString.replaceAll(REGEX_FIELD_FOR_REQUEST, STRING_EMPTY).getBytes();
}

abstract public Integer getId();

}