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

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

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

    public  Character getField(Pojo pojo) {
        return Unsafe.unsafe.getChar(pojo, offset);
    }

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

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

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

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

    public  void setBoolean(Pojo pojo, boolean value) {
        Unsafe.unsafe.putChar(pojo, offset, (char)(value ? 1 : 0));
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy