Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Hibernate OGM, Domain model persistence for NoSQL datastores
   *
   * License: GNU Lesser General Public License (LGPL), version 2.1 or later
   * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
   */
  package org.hibernate.ogm.model.key.spi;
  
  import java.util.Arrays;

A key representing an association row or identifier sequence.

Author(s):
Emmanuel Bernard
 
 public final class RowKey {
 
 	private final String[] columnNames;
 	//column value types do have to be serializable so RowKey can be serializable
 	//should it be a Serializable[] type? It seems to be more pain than anything else
 	private final Object[] columnValues;
 	private final int hashCode;
 
 	public RowKey(String[] columnNamesObject[] columnValues) {
 		this. = columnNames;
 		this. = columnValues;
 	}

This class should be treated as immutable. While we expose this array, you should never make changes to it! This is a design tradeoff vs. raw performance and memory usage.

Returns:
the column names
 
 	public String[] getColumnNames() {
 		return ;
 	}

This class should be treated as immutable. While we expose this array, you should never make changes to it! This is a design tradeoff vs. raw performance and memory usage.

Returns:
the column values corresponding to the column names returned by RowKey#getColumnNames()
 
 	public Object[] getColumnValues() {
 		return ;
 	}

Get the value of the specified column.

Parameters:
columnName the name of the column
Returns:
the corresponding value of the column, null if the column does not exist in the row key
 
 	public Object getColumnValue(String columnName) {
 		for ( int j = 0; j < .j++ ) {
 			if ( [j].equalscolumnName ) ) {
 				return [j];
 			}
 		}
 		return null;
 	}

Check if a column is part of the row key columns.

Parameters:
column the name of the column to check
Returns:
true if the column is one of the row key columns, false otherwise
 
 	public boolean contains(String column) {
 		for ( String columnName :  ) {
 			if ( columnName.equalscolumn ) ) {
 				return true;
 			}
 		}
 		return false;
 	}
 
 	public boolean equals(Object o) {
 		if ( this == o ) {
 			return true;
 		}
 		if ( o == null || RowKey.class != o.getClass() ) {
 			return false;
 		}
 
 		RowKey that = (RowKeyo;
 
 		// Probably incorrect - comparing Object[] arrays with Arrays.equals
 		if ( !Arrays.equalsthat.columnValues ) ) {
 			return false;
 		}
 		if ( !Arrays.equalsthat.columnNames ) ) {
 			return false;
 		}
 
		return true;
	}
	public int hashCode() {
		return ;
	}
	private int generateHashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Arrays.hashCode );
		result = prime * result + Arrays.hashCode );
		return result;
	}
	public String toString() {
		final StringBuilder sb = new StringBuilder();
		sb.append"RowKey[" );
		int i = 0;
		for ( String column :  ) {
			sb.appendcolumn ).append"=" ).append[i] );
			i++;
			if ( i < . ) {
				sb.append", " );
			}
		}
		sb.append"]" );
		return sb.toString();
	}
New to GrepCode? Check out our FAQ X