Make boolean convenience based of generic convenience.

This commit is contained in:
Olof Larsson 2016-02-01 21:06:07 +01:00
parent 8f6bcf2be9
commit f133149321

View File

@ -174,6 +174,7 @@ public class Entity<E extends Entity<E>>
// CONVENIENCE: DATABASE // CONVENIENCE: DATABASE
// -------------------------------------------- // // -------------------------------------------- //
// GENERIC
public <T> T convertGet(T value, T defaultValue) public <T> T convertGet(T value, T defaultValue)
{ {
return value != null ? value : defaultValue; return value != null ? value : defaultValue;
@ -185,16 +186,15 @@ public class Entity<E extends Entity<E>>
return Objects.equals(value, defaultValue) ? null : value; return Objects.equals(value, defaultValue) ? null : value;
} }
// Boolean specific // BOOLEAN
public boolean convertGet(Boolean wrapper) public boolean convertGet(Boolean value)
{ {
return wrapper != null ? wrapper.booleanValue() : false; return convertGet(value, false);
} }
public Boolean convertSet(boolean primitive) public Boolean convertSet(Boolean value)
{ {
this.changed(); return convertSet(value, false);
return primitive ? Boolean.TRUE : null;
} }
// -------------------------------------------- // // -------------------------------------------- //