blob: acb0e2a71208efe1ab01fb73b46dcb71e25564dd [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2019 CEA LIST, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.gitlight.compare.internal;
import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.ecore.EObject;
/**
* Instance of a feature for an EObject, designed to be used as a key in a Map.
*/
class SidedEObject {
/** The EObject. */
private final EObject eObject;
/** The side. */
private final DifferenceSource side;
/**
* Constructor.
*
* @param eObject
* The EObject
* @param side
* The side
*/
SidedEObject(EObject eObject, DifferenceSource side) {
super();
this.eObject = eObject;
this.side = side;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
// CHECKSTYLE:OFF Code generated by JDT
result = prime * result + ((eObject == null) ? 0 : eObject.hashCode());
result = prime * result + ((side == null) ? 0 : side.hashCode());
// CHECKSTYLE:ON
return result;
}
// CHECKSTYLE:OFF Code generated by JDT
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
SidedEObject other = (SidedEObject)obj;
if (eObject != other.eObject) {
return false;
}
if (side != other.side) {
return false;
}
return true;
// CHECKSTYLE:ON
}
@Override
public String toString() {
if (eObject == null) {
return "<null>-" + side; //$NON-NLS-1$
}
return eObject.eClass().getName() + '-' + side.getName(); //$NON-NLS-1$
}
}