org.freshvanilla.lang.misc.UnsafeByteFieldAccessor 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 UnsafeByteFieldAccessor implements FieldAccessor {
private final long offset;
UnsafeByteFieldAccessor(long offset) {
this.offset = offset;
}
public Byte getField(Pojo pojo) {
return Unsafe.unsafe.getByte(pojo, offset);
}
public boolean getBoolean(Pojo pojo) {
return Unsafe.unsafe.getByte(pojo, offset) != 0;
}
public long getNum(Pojo pojo) {
return Unsafe.unsafe.getByte(pojo, offset);
}
public double getDouble(Pojo pojo) {
return Unsafe.unsafe.getByte(pojo, offset);
}
public void setField(Pojo pojo, Byte object) {
Unsafe.unsafe.putByte(pojo, offset, object);
}
public void setBoolean(Pojo pojo, boolean flag) {
Unsafe.unsafe.putByte(pojo, offset, (byte)(flag ? 1 : 0));
}
public void setNum(Pojo pojo, long value) {
Unsafe.unsafe.putByte(pojo, offset, (byte)value);
}
public void setDouble(Pojo pojo, double value) {
Unsafe.unsafe.putByte(pojo, offset, (byte)value);
}
}