/******************************************************************************* | |
* Copyright (c) 2004-2008 Akos Horvath, Gergely Varro and Daniel Varro | |
* 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: | |
* Akos Horvath, Gergely Varro - initial API and implementation | |
*******************************************************************************/ | |
package org.eclipse.viatra2.gtasm.patternmatcher; | |
import org.eclipse.viatra2.core.IModelElement; | |
/** | |
* The enumeration of scopes. | |
*/ | |
public class Scope { | |
//TODO: have to change it to EdgeType!! (in this case the ChuiEdmonds needed to be overviewed | |
public static Integer BELOW = 1; | |
public static Integer IN = 0; | |
public static Integer DEFAULT_MODE = BELOW; | |
public static IModelElement DEFAULT_PARENT; // = root; | |
private int containmentMode; | |
protected IModelElement parent; | |
public Scope() { | |
this(DEFAULT_MODE, DEFAULT_PARENT); | |
} | |
public Scope(Integer mode, IModelElement parent) { | |
this.containmentMode = (mode == null ? DEFAULT_MODE : mode); | |
this.parent = (parent == null ? DEFAULT_PARENT : parent); | |
} | |
public Integer getContainmentMode() { | |
return containmentMode; | |
} | |
public IModelElement getParent() { | |
return parent; | |
} | |
/* (non-Javadoc) | |
* @see java.lang.Object#hashCode() | |
*/ | |
@Override | |
public int hashCode() { | |
final int prime = 31; | |
int result = 1; | |
result = prime * result + containmentMode; | |
result = prime * result + ((parent == null) ? 0 : parent.hashCode()); | |
return result; | |
} | |
/* (non-Javadoc) | |
* @see java.lang.Object#equals(java.lang.Object) | |
*/ | |
@Override | |
public boolean equals(Object obj) { | |
if (this == obj) | |
return true; | |
if (obj == null) | |
return false; | |
if (getClass() != obj.getClass()) | |
return false; | |
Scope other = (Scope) obj; | |
if (containmentMode != other.containmentMode) | |
return false; | |
if (parent == null) { | |
if (other.parent != null) | |
return false; | |
} else if (!parent.equals(other.parent)) | |
return false; | |
return true; | |
} | |
} |