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

com.kenshoo.pl.data.DatabaseId Maven / Gradle / Ivy

Go to download

A Java persistence layer based on JOOQ for high performance and business flow support.

There is a newer version: 0.1.121-jooq-3.16.3
Show newest version
package com.kenshoo.pl.data;

import org.apache.commons.lang3.ArrayUtils;
import org.jooq.TableField;
import java.util.Arrays;


public class DatabaseId {

    private final TableField[] tableFields;
    private final Object[] values;
    private int hashCode;

    public DatabaseId(TableField[] tableFields, Object[] values) {
        this.values = values;
        this.tableFields = tableFields;
    }

    public DatabaseId append(DatabaseId other) {
        return new DatabaseId(
                ArrayUtils.addAll(this.tableFields, other.tableFields),
                ArrayUtils.addAll(this.values, other.values)
        );
    }

    public Object[] getValues() {
        return values;
    }

    public static  DatabaseId create(TableField tableField, T val) {
        return new SingleDBId<>(tableField, val);
    }

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

        DatabaseId that = (DatabaseId) o;

        // Probably incorrect - comparing Object[] arrays with Arrays.equals
        return Arrays.deepEquals(values, that.values);

    }

    @Override
    public int hashCode() {
        if (hashCode == 0) {
            hashCode = Arrays.deepHashCode(values);
        }
        return hashCode;
    }

    public TableField[] getTableFields() {
        return tableFields;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy