Class PBody
- java.lang.Object
-
- org.eclipse.viatra.query.runtime.matchers.psystem.PBody
-
- All Implemented Interfaces:
PTraceable
public class PBody extends java.lang.Object implements PTraceable
A set of constraints representing a pattern body
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringVIRTUAL_VARIABLE_PREFIX
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<PVariable,java.util.Set<TypeJudgement>>getAllUnaryTypeRestrictions(IQueryMetaContext context)All unary input keys directly prescribed by constraints, grouped by variable.java.util.Set<PVariable>getAllVariables()java.util.Set<PConstraint>getConstraints()<ConstraintType>
java.util.Set<ConstraintType>getConstraintsOfType(java.lang.Class<ConstraintType> constraintClass)PDisjunctiongetContainerDisjunction()Returns the disjunction the body is contained with.PVariablegetOrCreateVariableByName(java.lang.String name)Finds and returns a PVariable by name.PQuerygetPattern()java.util.List<ExportedParameter>getSymbolicParameters()Returns the exported parameter constraints of the body.java.util.List<PVariable>getSymbolicParameterVariables()Returns the symbolic parameters of the body.java.util.Set<PVariable>getUniqueVariables()PVariablegetVariableByNameChecked(java.lang.Object name)Find a PVariable by namebooleanisMutable()PVariablenewConstantVariable(java.lang.Object value)PVariablenewVirtualVariable()PVariablenewVirtualVariable(java.lang.String name)voidsetContainerDisjunction(PDisjunction containerDisjunction)voidsetStatus(PQuery.PQueryStatus status)Sets a specific status for the body.voidsetSymbolicParameters(java.util.List<ExportedParameter> symbolicParameters)Sets the exported parameter constraints of the body, if this instance is mutable.
-
-
-
Field Detail
-
VIRTUAL_VARIABLE_PREFIX
public static final java.lang.String VIRTUAL_VARIABLE_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PBody
public PBody(PQuery query)
-
-
Method Detail
-
getConstraintsOfType
public <ConstraintType> java.util.Set<ConstraintType> getConstraintsOfType(java.lang.Class<ConstraintType> constraintClass)
-
newVirtualVariable
public PVariable newVirtualVariable()
-
newVirtualVariable
public PVariable newVirtualVariable(java.lang.String name)
-
newConstantVariable
public PVariable newConstantVariable(java.lang.Object value)
-
getAllVariables
public java.util.Set<PVariable> getAllVariables()
-
getUniqueVariables
public java.util.Set<PVariable> getUniqueVariables()
-
getVariableByNameChecked
public PVariable getVariableByNameChecked(java.lang.Object name)
Find a PVariable by name- Parameters:
name-- Returns:
- the found variable
- Throws:
java.lang.IllegalArgumentException- if no PVariable is found with the selected name
-
getOrCreateVariableByName
public PVariable getOrCreateVariableByName(java.lang.String name)
Finds and returns a PVariable by name. If no PVariable exists with the name in the body, a new one is created. If the name of the variable starts with ".virtual", the created variable will be considered virtual.- Parameters:
name-- Returns:
- a PVariable with the selected name; never null
-
getConstraints
public java.util.Set<PConstraint> getConstraints()
-
getPattern
public PQuery getPattern()
-
getSymbolicParameterVariables
public java.util.List<PVariable> getSymbolicParameterVariables()
Returns the symbolic parameters of the body.Warning: if two PVariables are unified, the returned list changes. If you want to have a stable version, consider using
getSymbolicParameters().- Returns:
- a non-null, but possibly empty list
-
getSymbolicParameters
public java.util.List<ExportedParameter> getSymbolicParameters()
Returns the exported parameter constraints of the body.- Returns:
- a non-null, but possibly empty list
-
setSymbolicParameters
public void setSymbolicParameters(java.util.List<ExportedParameter> symbolicParameters)
Sets the exported parameter constraints of the body, if this instance is mutable.- Parameters:
symbolicParameters- the new value
-
setStatus
public void setStatus(PQuery.PQueryStatus status)
Sets a specific status for the body. If set, the parent PQuery status will not be checked; if set to null, its corresponding PQuery status is checked for mutability.- Parameters:
status- the status to set
-
isMutable
public boolean isMutable()
-
getContainerDisjunction
public PDisjunction getContainerDisjunction()
Returns the disjunction the body is contained with. This disjunction may either be thecanonical disjunction of the corresponding queryor something equivalent.- Returns:
- the container disjunction of the body. Can be null if body is not in a disjunction yet.
-
setContainerDisjunction
public void setContainerDisjunction(PDisjunction containerDisjunction)
- Parameters:
containerDisjunction- the containerDisjunction to set
-
getAllUnaryTypeRestrictions
public java.util.Map<PVariable,java.util.Set<TypeJudgement>> getAllUnaryTypeRestrictions(IQueryMetaContext context)
All unary input keys directly prescribed by constraints, grouped by variable.to supertype inference or subsumption applied at this point.
-
-