Class Markers

java.lang.Object
org.openrewrite.marker.Markers

public class Markers extends Object
  • Field Details

    • EMPTY

      public static final Markers EMPTY
  • Constructor Details

    • Markers

      public Markers()
  • Method Details

    • build

      public static Markers build(Collection<? extends Marker> markers)
    • entries

      public Collection<? extends Marker> entries()
      TreeVisitor may respond to a marker to determine whether to act on a source file or not.
      Returns:
      A marker collection containing any additional context about the containing Tree element.
    • add

      public Markers add(Marker marker)
      Adds a new marker element to the collection.
      Parameters:
      marker - The data to add or update.
      Returns:
      A new Markers with an added marker.
    • computeByType

      public <M extends Marker> Markers computeByType(M identity, BinaryOperator<M> remappingFunction)
      Add a new marker or update some existing marker.
      Type Parameters:
      M - The type of marker.
      Parameters:
      identity - A new marker to add if it doesn't already exist. Existence is determined by type equality.
      remappingFunction - The function that merges an existing marker.
      Returns:
      A new Markers with an added or updated marker.
    • removeByType

      public Markers removeByType(Class<? extends Marker> type)
    • setByType

      public <M extends Marker> Markers setByType(M m)
    • compute

      public <M extends Marker> Markers compute(M identity, BinaryOperator<M> remappingFunction)
      Add a new marker or update some existing marker.
      Type Parameters:
      M - The type of marker.
      Parameters:
      identity - A new marker to add if it doesn't already exist. Existence is determined by regular equality.
      remappingFunction - The function that merges an existing marker with the new marker.
      Returns:
      A new Markers with an added or updated marker.
    • addIfAbsent

      public <M extends Marker> Markers addIfAbsent(M m)
      Add a new marker or update some existing marker.
      Type Parameters:
      M - The marker type.
      Parameters:
      m - A marker, which may or may not already exist already.
      Returns:
      If a marker already exists that matches by object equality, an unchanged markers reference is returned. Otherwise, the supplied marker is added.
    • findAll

      public <M extends Marker> List<M> findAll(Class<M> markerType)
    • findFirst

      public <M extends Marker> Optional<M> findFirst(Class<M> markerType)