org.eclipse.incquery.patternlanguage.emf.specification.builder

## Class PatternSanitizer

- java.lang.Object
- - org.eclipse.incquery.patternlanguage.emf.specification.builder.PatternSanitizer

-     public class PatternSanitizer
      extends java.lang.Object

  Stateful sanitizer that maintains a set of admitted patterns. Patterns go through sanitization checks (validation + name uniqueness) before they can be admitted.

  INVARIANTS:

  - the set of admitted patterns is closed with respect to references.
  - the set of admitted patterns are free of errors.
  - admitted patterns have unique qualified names.
  Author:
    Gabor Bergmann

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PatternSanitizer(org.apache.log4j.Logger logger)` Creates an instance of the stateful sanitizer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `admit(Pattern pattern)` Admits a new pattern, checking if it passes validation and name uniqueness checks.
    `boolean` | `admit(Pattern pattern, boolean skipPatternValidation)` Admits a new pattern, checking if it passes validation and name uniqueness checks.
    `void` | `forgetPattern(Pattern pattern)` Forgets a pattern from the specification.
    `Pattern` | `getAdmittedPatternByName(java.lang.String fqn)`
    `java.util.Set<Pattern>` | `getAdmittedPatterns()` Returns the set of patterns that have been admitted so far.
    `java.util.Collection<PProblem>` | `getProblemByPattern(Pattern pattern)`
    `java.util.Set<Pattern>` | `getRejectedPatterns()` Returns the set of patterns that have been rejected so far.

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

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

- - ### Constructor Detail

    - #### PatternSanitizer

          public PatternSanitizer(org.apache.log4j.Logger logger)

      Creates an instance of the stateful sanitizer.
      Parameters:
        `logger` - where detected problems will be logged

  - ### Method Detail

    - #### admit

          public boolean admit(Pattern pattern)

      Admits a new pattern, checking if it passes validation and name uniqueness checks. Referenced patterns likewise go through the checks. Transactional semantics: will only admit any patterns if none of them have any errors.
      Parameters:
        `pattern` - a pattern that should be validated.
      Returns:
        false if the pattern was not possible to admit, true if it passed all validation checks (or was already admitted before)

    - #### admit

          public boolean admit(Pattern pattern,
                               boolean skipPatternValidation)

      Admits a new pattern, checking if it passes validation and name uniqueness checks. Referenced patterns likewise go through the checks. Transactional semantics: will only admit any patterns if none of them have any errors.
      Parameters:
        `pattern` - a pattern that should be validated.
        `skipPatternValidation` - if set to true, detailed pattern validation is skipped - true for model inferrer; not recommended for generic API
      Returns:
        false if the pattern was not possible to admit, true if it passed all validation checks (or was already admitted before)

    - #### getAdmittedPatterns

          public java.util.Set<Pattern> getAdmittedPatterns()

      Returns the set of patterns that have been admitted so far.
      Returns:
        the admitted patterns

    - #### getRejectedPatterns

          public java.util.Set<Pattern> getRejectedPatterns()

      Returns the set of patterns that have been rejected so far.
      Returns:
        the rejected patterns

    - #### getProblemByPattern

          public java.util.Collection<PProblem> getProblemByPattern(Pattern pattern)

      Returns:
        a problem recorded for this pattern, if any

    - #### getAdmittedPatternByName

          public Pattern getAdmittedPatternByName(java.lang.String fqn)

      Parameters:
        `fqn` - the fully qualified name of the pattern

    - #### forgetPattern

          public void forgetPattern(Pattern pattern)

      Forgets a pattern from the specification.

      Warning! Removing a pattern that has other patterns referring to it may leave the builder in an inconsistent state!

      Parameters:
        `pattern` -