Class Finder

java.lang.Object
com.karuslabs.elementary.Finder
All Implemented Interfaces:
Iterable<Diagnostic<? extends JavaFileObject>>

public class Finder extends Object implements Iterable<Diagnostic<? extends JavaFileObject>>
Filter and maps the results of a compilation.
  • Constructor Details

    • Finder

      public Finder(Results results)
      Creates a Finder for the given results.
      Parameters:
      results - the results of a compilation
  • Method Details

    • iterator

      public Iterator<Diagnostic<? extends JavaFileObject>> iterator()
      Returns an iterator over Diagnostic<? extends JavaFileObject>s.
      Specified by:
      iterator in interface Iterable<Diagnostic<? extends JavaFileObject>>
      Returns:
      an iterator
    • kind

      public Finder kind(Diagnostic.Kind... kinds)
      Removes all diagnostic messages which kind does not match the given kinds.
      Parameters:
      kinds - the kinds which all diagnostic messages should match
      Returns:
      this
    • kind

      public Finder kind(Collection<Diagnostic.Kind> kinds)
      Removes all diagnostic messages which kind does not match the given kinds.
      Parameters:
      kinds - the kinds which all diagnostic messages should match
      Returns:
      this
    • errors

      public Finder errors()
      Retains only errors.
      Returns:
      this
    • warnings

      public Finder warnings()
      Retains only warnings.
      Returns:
      this
    • notes

      public Finder notes()
      Retains only notes.
      Returns:
      this
    • in

      public Finder in(JavaFileObject file)
      Retains only diagnostic messages in the given Java source file.
      Parameters:
      file - the Java source file
      Returns:
      this
    • on

      public Finder on(long line)
      Retains only diagnostic messages that appear on the given line.
      Parameters:
      line - the line
      Returns:
      this
    • at

      public Finder at(long column)
      Retains only diagnostic messages that appear at the given column.
      Parameters:
      column - the column
      Returns:
      this
    • where

      public Finder where(Predicate<Diagnostic<? extends JavaFileObject>> condition)
      Retains only diagnostic messages that satisfy the given predicate.
      Parameters:
      condition - the condition
      Returns:
      this
    • matches

      public Finder matches(String message)
      Retains only diagnostic messages that exactly match the given message.
      Parameters:
      message - the message
      Returns:
      this
    • matches

      public Finder matches(Pattern pattern)
      Retain only diagnostic messages that match the given pattern.
      Parameters:
      pattern - the pattern
      Returns:
      this
    • contains

      public Finder contains(String substring)
      Retain only diagnostic messages that contain the given substring.
      Parameters:
      substring - the substring
      Returns:
      this
    • diagnostics

      public List<String> diagnostics()
      Returns the full descriptions of the diagnostic messages.
      Returns:
      the full descriptions
    • messages

      public List<String> messages()
      Returns only the message portions of the diagnostic messages.
      Returns:
      the message portions
    • lines

      public List<Long> lines()
      Returns the line numbers of the diagnostic messages.
      Returns:
      the line numbers
    • columns

      public List<Long> columns()
      Returns the column numbers of the diagnostic messages.
      Returns:
      the column numbers
    • positions

      public List<Long> positions()
      Return the positions of the diagnostic messages from the start of a source file.
      Returns:
      the positions
    • codes

      public List<String> codes()
      Return the codes of the diagnostic messages.
      Returns:
      the codes
    • one

      public @Nullable Diagnostic<? extends JavaFileObject> one()
      Returns the diagnostic message if this Finder contains exactly one diagnostic message. Otherwise returns null.
      Returns:
      the diagnostic message if this Finder matches exactly one diagnostic message
    • list

      public List<Diagnostic<? extends JavaFileObject>> list()
      Returns the diagnostic messages.
      Returns:
      the diagnostic messages
    • map

      public Map<Diagnostic.Kind,List<Diagnostic<? extends JavaFileObject>>> map()
      Returns a map of diagnostic messages and associated Kinds.
      Returns:
      the map
    • count

      public int count()
      Returns the current count of diagnostic messages.
      Returns:
      the current count of diagnostic messages