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

org.freshvanilla.lang.misc.UnsafeShortFieldAccessor 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 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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy