package org.hibernate.ogm.grid;

import java.io.Serializable;
import java.util.Arrays;

/**
 * Represents the key used to link a property value and the id of it's owning entity
 *
 * @author Emmanuel Bernard
 */
public class PropertyKey {
	private final String table;
	//TODO replace property with columns
	private final String property;
	private final Object[] columnValues;

	public PropertyKey(String table, String property, Object[] columnValues) {
		this.table = table;
		this.property = property;
		this.columnValues = columnValues;
	}

	@Override
	public boolean equals(Object o) {
		if ( this == o ) {
			return true;
		}
		if ( o == null || getClass() != o.getClass() ) {
			return false;
		}

		PropertyKey that = ( PropertyKey ) o;

		if ( !Arrays.equals( columnValues, that.columnValues ) ) {
			return false;
		}
		if ( property != null ? !property.equals( that.property ) : that.property != null ) {
			return false;
		}
		if ( table != null ? !table.equals( that.table ) : that.table != null ) {
			return false;
		}

		return true;
	}

	@Override
	public int hashCode() {
		int result = table != null ? table.hashCode() : 0;
		result = 31 * result + ( property != null ? property.hashCode() : 0 );
		result = 31 * result + ( columnValues != null ? Arrays.hashCode( columnValues ) : 0 );
		return result;
	}
}

@@ -1315,11 +1315,421 @@
 sult;%0A%09%7D
+%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09final StringBuilder sb = new StringBuilder();%0A%09%09sb.append( %22PropertyKey%22 );%0A%09%09sb.append( %22%7Btable='%22 ).append( table ).append( '%5C'' );%0A%09%09sb.append( %22, property='%22 ).append( property ).append( '%5C'' );%0A%09%09sb.append( %22, columnValues=%22 )%0A%09%09%09%09.append( columnValues == null ? %22null%22 : Arrays.asList( columnValues ).toString() );%0A%09%09sb.append( '%7D' );%0A%09%09return sb.toString();%0A%09%7D
 %0A%7D%0A

Implement a toString method to PropertyKey