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

org.freshvanilla.lang.misc.UnsafeBooleanFieldAccessor 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 UnsafeBooleanFieldAccessor implements FieldAccessor {
    private final long offset;

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

	public  Boolean getField(Pojo pojo) {
        return Unsafe.unsafe.getBoolean(pojo, offset);
    }

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

    public  long getNum(Pojo pojo) {
        return Unsafe.unsafe.getBoolean(pojo, offset) ? 1 : 0;
    }

    public  double getDouble(Pojo pojo) {
        return Unsafe.unsafe.getBoolean(pojo, offset) ? 1 : 0;
    }

    public  void setField(Pojo pojo, Boolean object) {
        Unsafe.unsafe.putBoolean(pojo, offset, object);
    }

    public  void setBoolean(Pojo pojo, boolean flag) {
        Unsafe.unsafe.putBoolean(pojo, offset, flag);
    }

    public  void setNum(Pojo pojo, long value) {
        Unsafe.unsafe.putBoolean(pojo, offset, value != 0);
    }

    public  void setDouble(Pojo pojo, double value) {
        Unsafe.unsafe.putBoolean(pojo, offset, value != 0);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy