blob: e69964838f29fa138e6ba11b06c5be2a664a781d [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Apache.Ignite.ExamplesDll.Binary
{
using Apache.Ignite.Core.Cache.Affinity;
using Apache.Ignite.Core.Cache.Configuration;
/// <summary>
/// Employee key. Used in query example to co-locate employees with their organizations.
/// </summary>
public class EmployeeKey
{
/// <summary>
/// Constructor.
/// </summary>
/// <param name="id">ID.</param>
/// <param name="orgId">Organization ID.</param>
public EmployeeKey(int id, int orgId)
{
Id = id;
OrganizationId = orgId;
}
/// <summary>
/// ID.
/// </summary>
public int Id { get; private set; }
/// <summary>
/// Organization ID.
/// </summary>
[AffinityKeyMapped]
[QuerySqlField(IsIndexed = true)]
public int OrganizationId { get; private set; }
/// <summary>
/// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
/// </summary>
/// <returns>
/// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
/// </returns>
/// <param name="obj">The object to compare with the current object. </param><filterpriority>2</filterpriority>
public override bool Equals(object obj)
{
EmployeeKey other = obj as EmployeeKey;
return other != null && Id == other.Id && OrganizationId == other.OrganizationId;
}
/// <summary>
/// Serves as a hash function for a particular type.
/// </summary>
/// <returns>
/// A hash code for the current <see cref="T:System.Object"/>.
/// </returns>
/// <filterpriority>2</filterpriority>
public override int GetHashCode()
{
return 31 * Id + OrganizationId;
}
/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>
/// A string that represents the current object.
/// </returns>
public override string ToString()
{
return string.Format("{0} [id={1}, organizationId={2}]", typeof(EmployeeKey).Name, Id, OrganizationId);
}
}
}