Class BasePQuery
- java.lang.Object
-
- org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery
-
- All Implemented Interfaces:
PTraceable,PQuery,PQueryHeader
- Direct Known Subclasses:
BaseGeneratedEMFPQuery,GenericEMFPatternPQuery,GenericSingleConstraintPQuery
public abstract class BasePQuery extends java.lang.Object implements PQuery
Default implementation of PQuery.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery
PQuery.PQueryStatus
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<PProblem>pProblemsprotected PQuery.PQueryStatusstatusprotected PVisibilityvisibility
-
Constructor Summary
Constructors Constructor Description BasePQuery(PVisibility visibility)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddAnnotation(PAnnotation annotation)protected voidaddError(PProblem problem)voidcheckMutability()Before a modification operation is executed, a mutability check is performed (via thePQuery.getStatus()implementation, and in case of problems anIllegalStateExceptionis thrown.protected abstract java.util.Set<PBody>doGetContainedBodies()Creates and returns the bodies of the query.voidensureInitialized()If the query definition is uninitialized, initializes it.java.util.List<PAnnotation>getAllAnnotations()Returns the list of annotations specified for this queryjava.util.Set<PQuery>getAllReferredQueries()Returns all queries required to evaluate this query (transitively).java.util.List<PAnnotation>getAnnotationsByName(java.lang.String annotationName)Returns the list of annotations with a specified namejava.util.Set<PQuery>getDirectReferredQueries()Returns all queries directly referred in the constraints.PDisjunctiongetDisjunctBodies()Returns all bodies associated with the query in their canonical form.QueryEvaluationHintgetEvaluationHints()Optional hints regarding the query evaluation strategy, to be interpreted by the query engine.java.util.Optional<PAnnotation>getFirstAnnotationByName(java.lang.String annotationName)Returns the first annotation with a specified namejava.util.List<java.lang.String>getParameterNames()Return the list of parameter namesjava.lang.IntegergetPositionOfParameter(java.lang.String parameterName)Returns the index of a named parameterjava.util.List<PProblem>getPProblems()Returns a list describing the problems that were found in this query.PQuery.PQueryStatusgetStatus()Returns the initialization status of the definitionjava.util.Set<TypeJudgement>getTypeGuarantees()Type information, expressed on query parameters, that all matches of the query are guaranteed to respect.PVisibilitygetVisibility()Returns the visibility information about the query.booleanisMutable()An option to check mutability of the query.java.util.List<java.lang.Object>publishedAs()Returns the end-user query specification API objects that wrap this query.protected voidsetBodies(java.util.Set<PBody> bodies)voidsetEvaluationHints(QueryEvaluationHint hints)protected voidsetStatus(PQuery.PQueryStatus newStatus)java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQueryHeader
getFullyQualifiedName, getParameter, getParameters, getSimpleName
-
-
-
-
Field Detail
-
status
protected PQuery.PQueryStatus status
-
visibility
protected final PVisibility visibility
- Since:
- 2.0
-
pProblems
protected java.util.List<PProblem> pProblems
-
-
Constructor Detail
-
BasePQuery
public BasePQuery(PVisibility visibility)
- Since:
- 2.0
-
-
Method Detail
-
getPositionOfParameter
public java.lang.Integer getPositionOfParameter(java.lang.String parameterName)
Description copied from interface:PQueryHeaderReturns the index of a named parameter- Specified by:
getPositionOfParameterin interfacePQueryHeader- Returns:
- the index, or null of no such parameter is available
-
setStatus
protected void setStatus(PQuery.PQueryStatus newStatus)
-
addError
protected void addError(PProblem problem)
-
getStatus
public PQuery.PQueryStatus getStatus()
Description copied from interface:PQueryReturns the initialization status of the definition
-
getPProblems
public java.util.List<PProblem> getPProblems()
Description copied from interface:PQueryReturns a list describing the problems that were found in this query.TODO: formulate invariant connecting
PQuery.getPProblems()andPQuery.getStatus().- Specified by:
getPProblemsin interfacePQuery- Returns:
- a non-null, but possibly empty list of problems
-
isMutable
public boolean isMutable()
Description copied from interface:PQueryAn option to check mutability of the query. It can be used to avoid getting anIllegalStateExceptionby the execution ofPQuery.checkMutability().
-
checkMutability
public void checkMutability()
Description copied from interface:PQueryBefore a modification operation is executed, a mutability check is performed (via thePQuery.getStatus()implementation, and in case of problems anIllegalStateExceptionis thrown.- Specified by:
checkMutabilityin interfacePQuery
-
setEvaluationHints
public void setEvaluationHints(QueryEvaluationHint hints)
- Since:
- 1.5
-
getEvaluationHints
public QueryEvaluationHint getEvaluationHints()
Description copied from interface:PQueryOptional hints regarding the query evaluation strategy, to be interpreted by the query engine.To ensure the possibility of external overrides, the evaluation engine should not directly consult this field, but use an
IQueryBackendHintProviderinstead.- Specified by:
getEvaluationHintsin interfacePQuery
-
addAnnotation
protected void addAnnotation(PAnnotation annotation)
-
getAllAnnotations
public java.util.List<PAnnotation> getAllAnnotations()
Description copied from interface:PQueryHeaderReturns the list of annotations specified for this query- Specified by:
getAllAnnotationsin interfacePQueryHeader- Returns:
- a non-null, but possibly empty list of annotations
-
getAnnotationsByName
public java.util.List<PAnnotation> getAnnotationsByName(java.lang.String annotationName)
Description copied from interface:PQueryHeaderReturns the list of annotations with a specified name- Specified by:
getAnnotationsByNamein interfacePQueryHeader- Returns:
- a non-null, but possibly empty list of annotations
-
getFirstAnnotationByName
public java.util.Optional<PAnnotation> getFirstAnnotationByName(java.lang.String annotationName)
Description copied from interface:PQueryHeaderReturns the first annotation with a specified name- Specified by:
getFirstAnnotationByNamein interfacePQueryHeader
-
getParameterNames
public java.util.List<java.lang.String> getParameterNames()
Description copied from interface:PQueryHeaderReturn the list of parameter names- Specified by:
getParameterNamesin interfacePQueryHeader- Returns:
- a non-null, but possibly empty list of parameter names
-
getDirectReferredQueries
public java.util.Set<PQuery> getDirectReferredQueries()
Description copied from interface:PQueryReturns all queries directly referred in the constraints. They are all required to evaluate this query- Specified by:
getDirectReferredQueriesin interfacePQuery- Returns:
- a non-null, but possibly empty list of query definitions
-
getAllReferredQueries
public java.util.Set<PQuery> getAllReferredQueries()
Description copied from interface:PQueryReturns all queries required to evaluate this query (transitively).- Specified by:
getAllReferredQueriesin interfacePQuery- Returns:
- a non-null, but possibly empty list of query definitions
-
publishedAs
public java.util.List<java.lang.Object> publishedAs()
Description copied from interface:PQueryReturns the end-user query specification API objects that wrap this query.Intended for traceability and debug purposes, not part of normal operation. Returned list is intended to be appended during query specification construction time.
- Specified by:
publishedAsin interfacePQuery- Returns:
- a non-null, but possibly empty list of query specification objects;
-
getTypeGuarantees
public java.util.Set<TypeJudgement> getTypeGuarantees()
Description copied from interface:PQueryType information, expressed on query parameters, that all matches of the query are guaranteed to respect.At the very minimum, this should include the declared types of the parameters.
The type judgement tuples shall contain the parameter index, NOT the
PParameterobject.- Specified by:
getTypeGuaranteesin interfacePQuery- Returns:
- a non-null set of type judgements that the query guarantees for its matches
-
getDisjunctBodies
public PDisjunction getDisjunctBodies()
Description copied from interface:PQueryReturns all bodies associated with the query in their canonical form. If called multiple times, the same set with the same contents will be returned.- Specified by:
getDisjunctBodiesin interfacePQuery
-
ensureInitialized
public final void ensureInitialized()
Description copied from interface:PQueryIf the query definition is uninitialized, initializes it.- Specified by:
ensureInitializedin interfacePQuery
-
setBodies
protected final void setBodies(java.util.Set<PBody> bodies)
-
doGetContainedBodies
protected abstract java.util.Set<PBody> doGetContainedBodies()
Creates and returns the bodies of the query. If recalled again, a new instance is created.- Returns:
- Throws:
ViatraQueryRuntimeException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getVisibility
public PVisibility getVisibility()
Description copied from interface:PQueryHeaderReturns the visibility information about the query.- Specified by:
getVisibilityin interfacePQueryHeader- Since:
- 2.0
-
-