All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.freshvanilla.lang.misc.UnsafeFloatFieldAccessor Maven / Gradle / Ivy

Go to download

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 UnsafeFloatFieldAccessor implements FieldAccessor {
    private final long offset;

    UnsafeFloatFieldAccessor(long offset) {
        this.offset = offset;
    }

    public  Float getField(Pojo pojo) {
        return Unsafe.unsafe.getFloat(pojo, offset);
    }

    public  boolean getBoolean(Pojo pojo) {
        return Unsafe.unsafe.getFloat(pojo, offset) != 0;
    }

    public  long getNum(Pojo pojo) {
        return (long)Unsafe.unsafe.getFloat(pojo, offset);
    }

    public  double getDouble(Pojo pojo) {
        return Unsafe.unsafe.getFloat(pojo, offset);
    }

    public  void setField(Pojo pojo, Float value) {
        Unsafe.unsafe.putFloat(pojo, offset, value);
    }

    public  void setBoolean(Pojo pojo, boolean value) {
        Unsafe.unsafe.putFloat(pojo, offset, value ? 1.0f : 0.0f);
    }

    public  void setNum(Pojo pojo, long value) {
        Unsafe.unsafe.putFloat(pojo, offset, value);
    }

    public  void setDouble(Pojo pojo, double value) {
        Unsafe.unsafe.putFloat(pojo, offset, (float)value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy