/******************************************************************************* | |
* Copyright (c) 2004-2010 Gabor Bergmann 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: | |
* Gabor Bergmann - initial API and implementation | |
*******************************************************************************/ | |
package org.eclipse.viatra2.gtasm.patternmatcher.incremental.simple.legacy; | |
import java.util.HashSet; | |
import java.util.LinkedList; | |
/** | |
* @author Bergmann Gábor | |
* | |
*/ | |
public class PatternNodeBase { | |
/** | |
* The name of the pattern variable. This is the unique key of the pattern node. | |
*/ | |
public String name; | |
/** | |
* if a node is not a symbolic parameter nor is it touched (quantified) by any | |
* nonnegative constraints, it should be inversely quantified | |
*/ | |
public boolean isTouched; | |
/** | |
* virtual pNodes are nodes that do not correspond to actual pattern | |
* variables; they represent constants or Term substitutes | |
*/ | |
public boolean isVirtual; | |
/** | |
* true if node is explicitly made exempt from injectivity | |
*/ | |
public boolean isExemptFromInjectivity = false; | |
/** | |
* Counts the number of hitherto unmatched constraints that can restrict the type of the node | |
*/ | |
public int lingeringTypeInfoCounter; | |
/** | |
* types explicitly asserted of this node | |
*/ | |
public LinkedList<Object> assertedTypes; | |
/** | |
* types automatically implied by other constraints | |
*/ | |
public HashSet<Object> impliedTypes; | |
/** | |
* @param name | |
* @param isTouched | |
* @param isVirtual | |
*/ | |
public PatternNodeBase(String name, boolean isTouched, boolean isVirtual) { | |
super(); | |
this.name = name; | |
this.isTouched = isTouched; | |
this.isVirtual = isVirtual; | |
this.assertedTypes = new LinkedList<Object>(); | |
this.impliedTypes = new HashSet<Object>(); | |
this.lingeringTypeInfoCounter = 0; | |
} | |
public PatternNodeBase(String name) { | |
this(name, false, false); | |
} | |
public boolean isVirtual() { | |
return isVirtual; | |
} | |
public boolean isExemptFromInjectivity() { | |
return isVirtual || isExemptFromInjectivity; | |
} | |
public void makeExemptFromInjectivity() { | |
isExemptFromInjectivity = true; | |
} | |
@Override | |
public int hashCode() { | |
final int PRIME = 31; | |
int result = 1; | |
result = PRIME * result + ((name == null) ? 0 : name.hashCode()); | |
return result; | |
} | |
@Override | |
public boolean equals(Object obj) { | |
if (this == obj) | |
return true; | |
if (obj == null) | |
return false; | |
if (getClass() != obj.getClass()) | |
return false; | |
final PatternNode other = (PatternNode) obj; | |
if (name == null) { | |
if (other.name != null) | |
return false; | |
} else if (!name.equals(other.name)) | |
return false; | |
return true; | |
} | |
public int compareTo(PatternNode arg0) { | |
return name.compareTo(arg0.name); | |
} | |
@Override | |
public String toString() { | |
return name;// + ":PatternNode"; | |
} | |
} |