Skip to content
New issue

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

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

Already on GitHub? # to your account

Fixes #52 Improved null-handling when reading many primitives #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
49 changes: 44 additions & 5 deletions src/main/java/redis/clients/johm/JOhmUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,25 +215,64 @@ public static Object convert(final Class<?> type, final String value) {
return '\u0000';
}
}
if (type.equals(Short.class) || type.equals(short.class)) {
if (type.equals(short.class)) {
if ( value == null) {
return 0;
}
return new Short(value);
}
if (type.equals(Short.class)) {
if ( value == null) {
return null;
}
return new Short(value);
}
if (type.equals(Integer.class) || type.equals(int.class)) {
if (type.equals(int.class)) {
if (value == null) {
return 0;
}
return new Integer(value);
}
if (type.equals(Float.class) || type.equals(float.class)) {
if (type.equals(Integer.class)) {
if (value == null) {
return null;
}
return new Integer(value);
}
if (type.equals(float.class)) {
if (value == null) {
return 0f;
}
return new Float(value);
}
if (type.equals(Double.class) || type.equals(double.class)) {
if (type.equals(Float.class)) {
if (value == null) {
return null;
}
return new Float(value);
}
if (type.equals(double.class)) {
if ( value == null) {
return 0.0;
}
return new Double(value);
}
if (type.equals(Double.class)) {
if ( value == null ) {
return null;
}
return new Double(value);
}
if (type.equals(Long.class) || type.equals(long.class)) {
if (type.equals(long.class)) {
if ( value == null) {
return 0L;
}
return new Long(value);
}
if (type.equals(Long.class)) {
if ( value == null) {
return null;
}
return new Long(value);
}
if (type.equals(Boolean.class) || type.equals(boolean.class)) {
Expand Down