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