org.freshvanilla.lang.misc.UnsafeBooleanFieldAccessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.paremus.dosgi.net Show documentation
Show all versions of com.paremus.dosgi.net Show documentation
An implementation of OSGi Remote Service Admin, enhanced to
provide support for OSGi Promises and streaming using OSGi
PushStreams.
The newest version!
package org.freshvanilla.lang.misc;
@SuppressWarnings("restriction")
class UnsafeBooleanFieldAccessor implements FieldAccessor {
private final long offset;
UnsafeBooleanFieldAccessor(long offset) {
this.offset = offset;
}
public Boolean getField(Pojo pojo) {
return Unsafe.unsafe.getBoolean(pojo, offset);
}
public boolean getBoolean(Pojo pojo) {
return Unsafe.unsafe.getBoolean(pojo, offset);
}
public long getNum(Pojo pojo) {
return Unsafe.unsafe.getBoolean(pojo, offset) ? 1 : 0;
}
public double getDouble(Pojo pojo) {
return Unsafe.unsafe.getBoolean(pojo, offset) ? 1 : 0;
}
public void setField(Pojo pojo, Boolean object) {
Unsafe.unsafe.putBoolean(pojo, offset, object);
}
public void setBoolean(Pojo pojo, boolean flag) {
Unsafe.unsafe.putBoolean(pojo, offset, flag);
}
public void setNum(Pojo pojo, long value) {
Unsafe.unsafe.putBoolean(pojo, offset, value != 0);
}
public void setDouble(Pojo pojo, double value) {
Unsafe.unsafe.putBoolean(pojo, offset, value != 0);
}
}