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