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

net.intelie.pipes.UnsafeRow Maven / Gradle / Ivy

There is a newer version: 0.25.5
Show newest version
package net.intelie.pipes;

import java.util.Arrays;

public final class UnsafeRow implements UnsafeObject {
    private final Object[] buffer;

    public UnsafeRow(int size) {
        this(new Object[size]);
    }

    private UnsafeRow(Object[] buffer) {
        this.buffer = buffer;
    }

    public Object get(int id) {
        return this.buffer[id];
    }

    public void set(int id, Object obj) {
        this.buffer[id] = obj;
    }

    @Override
    public UnsafeRow copy() {
        return new UnsafeRow(Arrays.copyOf(buffer, buffer.length));
    }

    public ArrayRow toRow() {
        return new ArrayRow(Arrays.copyOf(buffer, buffer.length));
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof UnsafeRow)) return false;

        UnsafeRow row = (UnsafeRow) o;

        return Arrays.equals(buffer, row.buffer);
    }

    @Override
    public int hashCode() {
        return Arrays.hashCode(buffer);
    }

    @Override
    public String toString() {
        return "" + Arrays.asList(buffer);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy