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

org.simpleflatmapper.map.mapper.MapperKey Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 9.0.2
Show newest version
package org.simpleflatmapper.map.mapper;

import org.simpleflatmapper.map.FieldKey;

import java.util.Arrays;

import static org.simpleflatmapper.util.Asserts.requireNonNull;

public final class MapperKey> {

	private final K[] columns;

	@SuppressWarnings("unchecked")
	public MapperKey(final K... columns) {
		requireNonNull("columns", columns);
		this.columns = columns;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MapperKey that = (MapperKey) obj;
		return equals(columns, that.columns);
	}

	private boolean equals(K[] c1, FieldKey[] c2) {
		if (c1.length != c2.length)
			return false;
		for(int i = 0; i < c1.length; i++) {
			if (!c1[i].equals(c2[i])) {
				return false;
			}
		}
		return true;
	}

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

	public K[] getColumns() {
		return columns;
	}

    @Override
    public String toString() {
        return "MapperKey{" + Arrays.toString(columns) +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy