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