blob: c247dc7cd89939b1888323908b02a59526c87e6f [file] [log] [blame]
/*
* Copyright (c) 2011-2013 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.emf.cdo.internal.common.revision;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.net4j.util.CheckUtil;
import java.text.MessageFormat;
/**
* @author Eike Stepper
*/
public class CDOIDAndVersionImpl implements CDOIDAndVersion
{
private CDOID id;
private int version;
public CDOIDAndVersionImpl(CDOID id, int version)
{
CheckUtil.checkArg(id, "id");
this.id = id;
this.version = version;
}
public CDOID getID()
{
return id;
}
public int getVersion()
{
return version;
}
@Override
public boolean equals(Object obj)
{
if (obj == this)
{
return true;
}
if (obj instanceof CDOIDAndVersion)
{
CDOIDAndVersion that = (CDOIDAndVersion)obj;
return id == that.getID() && version == that.getVersion();
}
return false;
}
@Override
public int hashCode()
{
return id.hashCode() ^ version;
}
@Override
public String toString()
{
return MessageFormat.format("{0}v{1}", id, version); //$NON-NLS-1$
}
}