org.eclipse.viatra.query.runtime.matchers.psystem.rewriters

## Class PBodyCopier

- java.lang.Object
- - org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.AbstractRewriterTraceSource
  - - org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.PBodyCopier

-     public class PBodyCopier
      extends AbstractRewriterTraceSource

  This class can create a new PBody for a PQuery. The result body contains a copy of given variables and constraints.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected PBody` | `body` The created body
    `protected java.util.Map<PVariable,PVariable>` | `variableMapping` Mapping between the original and the copied variables

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PBodyCopier(PBody body)` Deprecated. use `PBodyCopier(PBody, IRewriterTraceCollector)` instead
    `PBodyCopier(PBody body, IRewriterTraceCollector traceCollector)`
    `PBodyCopier(PQuery query)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `copyAggregatorConstraint(AggregatorConstraint constraint)`
    `protected void` | `copyBinaryTransitiveClosureConstraint(BinaryTransitiveClosure binaryTransitiveClosure)`
    `protected void` | `copyConstantValueConstraint(ConstantValue constantValue)`
    `protected void` | `copyConstraint(PConstraint constraint)`
    `protected void` | `copyEqualityConstraint(Equality equality)`
    `protected ExportedParameter` | `copyExportedParameterConstraint(ExportedParameter exportedParameter)`
    `protected void` | `copyExpressionEvaluationConstraint(ExpressionEvaluation expressionEvaluation)`
    `protected void` | `copyInequalityConstraint(Inequality inequality)`
    `protected void` | `copyNegativePatternCallConstraint(NegativePatternCall negativePatternCall)`
    `protected void` | `copyPatternMatchCounterConstraint(PatternMatchCounter patternMatchCounter)`
    `protected void` | `copyPositivePatternCallConstraint(PositivePatternCall positivePatternCall)`
    `protected void` | `copyTypeConstraint(TypeConstraint typeConstraint)`
    `protected void` | `copyTypeFilterConstraint(TypeFilterConstraint typeConstraint)`
    `protected void` | `copyVariable(PVariable variable, java.lang.String newName)`
    `protected PVariable[]` | `extractMappedVariables(EnumerablePConstraint enumerablePConstraint)` For positive pattern calls
    `PBody` | `getCopiedBody()` Returns the body with the copied variables and constraints.
    `java.util.Map<PVariable,PVariable>` | `getVariableMapping()`
    `void` | `mergeBody(PBody sourceBody)`
    `void` | `mergeBody(PBody sourceBody, IVariableRenamer namingTool, IConstraintFilter filter)` Merge all variables and constraints from a source body to a target body.

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.matchers.psystem.rewriters.AbstractRewriterTraceSource

      `addTrace, derivativeRemoved, getTraceCollector, getTraces, setTraceCollector`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### body

          protected PBody body

      The created body

    - #### variableMapping

          protected java.util.Map<PVariable,PVariable> variableMapping

      Mapping between the original and the copied variables

  - ### Constructor Detail

    - #### PBodyCopier

          @Deprecated
          public PBodyCopier(PBody body)

      Deprecated. use `PBodyCopier(PBody, IRewriterTraceCollector)` instead
      This constructor is deprecated as it performs a copy without allowing callers to set the trace collector before.

    - #### PBodyCopier

          public PBodyCopier(PBody body,
                             IRewriterTraceCollector traceCollector)

      Since:
        1.6

    - #### PBodyCopier

          public PBodyCopier(PQuery query)

      Since:
        1.6

  - ### Method Detail

    - #### getVariableMapping

          public java.util.Map<PVariable,PVariable> getVariableMapping()

    - #### mergeBody

          public void mergeBody(PBody sourceBody)

    - #### mergeBody

          public void mergeBody(PBody sourceBody,
                                IVariableRenamer namingTool,
                                IConstraintFilter filter)

      Merge all variables and constraints from a source body to a target body. If multiple bodies are merged into a single one, use the renamer and filter options to avoid collisions.
      Parameters:
        `sourceBody` -
        `namingTool` -
        `filter` -

    - #### copyVariable

          protected void copyVariable(PVariable variable,
                                      java.lang.String newName)

    - #### getCopiedBody

          public PBody getCopiedBody()

      Returns the body with the copied variables and constraints. The returned body is still uninitialized.

    - #### copyConstraint

          protected void copyConstraint(PConstraint constraint)

    - #### copyExportedParameterConstraint

          protected ExportedParameter copyExportedParameterConstraint(ExportedParameter exportedParameter)

    - #### copyEqualityConstraint

          protected void copyEqualityConstraint(Equality equality)

    - #### copyInequalityConstraint

          protected void copyInequalityConstraint(Inequality inequality)

    - #### copyTypeConstraint

          protected void copyTypeConstraint(TypeConstraint typeConstraint)

    - #### copyTypeFilterConstraint

          protected void copyTypeFilterConstraint(TypeFilterConstraint typeConstraint)

    - #### copyConstantValueConstraint

          protected void copyConstantValueConstraint(ConstantValue constantValue)

    - #### copyPositivePatternCallConstraint

          protected void copyPositivePatternCallConstraint(PositivePatternCall positivePatternCall)

    - #### copyNegativePatternCallConstraint

          protected void copyNegativePatternCallConstraint(NegativePatternCall negativePatternCall)

    - #### copyBinaryTransitiveClosureConstraint

          protected void copyBinaryTransitiveClosureConstraint(BinaryTransitiveClosure binaryTransitiveClosure)

    - #### copyPatternMatchCounterConstraint

          protected void copyPatternMatchCounterConstraint(PatternMatchCounter patternMatchCounter)

    - #### copyAggregatorConstraint

          protected void copyAggregatorConstraint(AggregatorConstraint constraint)

      Since:
        1.4

    - #### copyExpressionEvaluationConstraint

          protected void copyExpressionEvaluationConstraint(ExpressionEvaluation expressionEvaluation)

    - #### extractMappedVariables

          protected PVariable[] extractMappedVariables(EnumerablePConstraint enumerablePConstraint)

      For positive pattern calls
      Parameters:
        `positivePatternCall` -
      Returns:
        the mapped variables to the pattern's parameters