org.thewonderlemming.c4plantuml.grammars

## Enum SourceType

- java.lang.Object
- - java.lang.Enum<SourceType>
  - - org.thewonderlemming.c4plantuml.grammars.SourceType

- All Implemented Interfaces:
    Serializable, Comparable<SourceType>

      public enum SourceType
      extends Enum<SourceType>

  An enumeration that binds C4 grammars to their specific `Lexer` and `Parser`, and provides convenience methods such as parsing source files and identifying a source C4 level.
  Author:
    thewonderlemming

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `C4_L1` A C4 System Context grammar.
    `C4_L2` A C4 Container grammar.
    `C4_L3` A C4 Component grammar.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Optional<? extends org.antlr.v4.runtime.Parser>` | `createParser(Path sourcePath, Charset charset, org.antlr.v4.runtime.BaseErrorListener errorListener)` Parses the given C4 source file and returns an `Optional` of the created `Parser` or empty if any exception occurs.
    `String` | `getC4Level()` Returns the associated C4 level of the current enumeration value.
    `Class<org.antlr.v4.runtime.Parser>` | `getParserType()` Returns the associated `Parser` type of the current enumeration value.
    `static Optional<SourceType>` | `getSourceTypeFromFilename(Path fullyQualifiedName)` Guesses the given source file C4 level and returns an `Optional` of the matching enumeration value if any, or empty.
    `static SourceType` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static SourceType[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

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

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### C4_L1

          public static final SourceType C4_L1

      A C4 System Context grammar.

    - #### C4_L2

          public static final SourceType C4_L2

      A C4 Container grammar.

    - #### C4_L3

          public static final SourceType C4_L3

      A C4 Component grammar.

  - ### Method Detail

    - #### values

          public static SourceType[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (SourceType c : SourceType.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static SourceType valueOf(String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null

    - #### getSourceTypeFromFilename

          public static Optional<SourceType> getSourceTypeFromFilename(Path fullyQualifiedName)

      Guesses the given source file C4 level and returns an `Optional` of the matching enumeration value if any, or empty.
      Parameters:
        `fullyQualifiedName` - the C4 source file to guess the level from.
      Returns:
        an `Optional` of the matching enumeration if any or empty.

    - #### createParser

          public Optional<? extends org.antlr.v4.runtime.Parser> createParser(Path sourcePath,
                                                                              Charset charset,
                                                                              org.antlr.v4.runtime.BaseErrorListener errorListener)

      Parses the given C4 source file and returns an `Optional` of the created `Parser` or empty if any exception occurs. Parsing errors are reported to the given `BaseErrorListener` instance.
      Parameters:
        `sourcePath` - the C4 source file to parse.
        `charset` - the `Charset` of the source file.
        `errorListener` - the error listener to report syntax error to.
      Returns:
        n `Optional` of the new `Parser` instance or empty on error.

    - #### getC4Level

          public String getC4Level()

      Returns the associated C4 level of the current enumeration value.
      Returns:
        the current enumeration C4 level.

    - #### getParserType

          public Class<org.antlr.v4.runtime.Parser> getParserType()

      Returns the associated `Parser` type of the current enumeration value.
      Returns:
        the current enumeration `Parser` type.

Copyright © 2020. All rights reserved.