Boolean database conversion methods

This commit is contained in:
BuildTools 2016-01-28 15:45:36 +01:00 committed by Olof Larsson
parent a9f159cc70
commit 337031fc11
2 changed files with 28 additions and 0 deletions

View File

@ -168,6 +168,21 @@ public class Entity<E extends Entity<E>>
return false; return false;
} }
// -------------------------------------------- //
// CONVENIENCE: DATABASE
// -------------------------------------------- //
public boolean convertGet(Boolean wrapper)
{
return wrapper != null ? wrapper.booleanValue() : false;
}
public Boolean convertSet(boolean primitive)
{
this.changed();
return primitive ? Boolean.TRUE : null;
}
// -------------------------------------------- // // -------------------------------------------- //
// STANDARDS // STANDARDS
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -12,6 +12,7 @@ import com.massivecraft.massivecore.Named;
import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.mson.Mson;
import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.PermUtil;
public abstract class SenderEntity<E extends SenderEntity<E>> extends Entity<E> implements Named public abstract class SenderEntity<E extends SenderEntity<E>> extends Entity<E> implements Named
{ {
@ -59,6 +60,18 @@ public abstract class SenderEntity<E extends SenderEntity<E>> extends Entity<E>
return (SenderColl<E>) super.getColl(); return (SenderColl<E>) super.getColl();
} }
// -------------------------------------------- //
// CONVENIENCE: DATABASE
// -------------------------------------------- //
public boolean convertGet(Boolean wrapper, String permission)
{
// Permission requirement
if ( ! PermUtil.has(this.getSender(), permission)) return false;
return super.convertGet(wrapper);
}
// -------------------------------------------- // // -------------------------------------------- //
// TYPE // TYPE
// -------------------------------------------- // // -------------------------------------------- //