Package org.openrewrite.marker
Class Markers
- java.lang.Object
-
- org.openrewrite.marker.Markers
-
- All Implemented Interfaces:
Tree
@Incubating(since="7.0.0") public class Markers extends java.lang.Object implements Tree
-
-
Constructor Summary
Constructors Constructor Description Markers()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Markersadd(Marker marker)Adds a new marker element to the collection.<M extends Marker>
MarkersaddIfAbsent(M m)Add a new marker or update some existing marker.static Markersbuild(java.util.Collection<? extends Marker> markers)<M extends Marker>
Markerscompute(M identity, java.util.function.BinaryOperator<M> remappingFunction)Add a new marker or update some existing marker.<M extends Marker>
MarkerscomputeByType(M identity, java.util.function.BinaryOperator<M> remappingFunction)Add a new marker or update some existing marker.java.util.Collection<? extends Marker>entries()TreeVisitormay respond to a marker to determine whether to act on a source file or not.<M extends Marker>
java.util.List<M>findAll(java.lang.Class<M> markerType)<M extends Marker>
java.util.Optional<M>findFirst(java.lang.Class<M> markerType)<P> booleanisAcceptable(TreeVisitor<?,P> v, P p)Checks the supplied argument to see if the supplied visitor and its context would be valid arguments to accept().MarkerssearchResult()MarkerssearchResult(@Nullable java.lang.String description)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openrewrite.Tree
accept, getId, getJacksonPolymorphicTypeTag, isScope, print, print, print, print, printer, printTrimmed, printTrimmed, printTrimmed
-
-
-
-
Field Detail
-
EMPTY
public static final Markers EMPTY
-
-
Method Detail
-
entries
public java.util.Collection<? extends Marker> entries()
TreeVisitormay 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
Treeelement.
-
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
Markerswith an added marker.
-
computeByType
public <M extends Marker> Markers computeByType(M identity, java.util.function.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
Markerswith an added or updated marker.
-
compute
public <M extends Marker> Markers compute(M identity, java.util.function.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
Markerswith 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> java.util.List<M> findAll(java.lang.Class<M> markerType)
-
findFirst
public <M extends Marker> java.util.Optional<M> findFirst(java.lang.Class<M> markerType)
-
searchResult
public Markers searchResult()
-
isAcceptable
public <P> boolean isAcceptable(TreeVisitor<?,P> v, P p)
Description copied from interface:TreeChecks the supplied argument to see if the supplied visitor and its context would be valid arguments to accept(). Typically this involves checking that the visitor is of a type that operates on this kind of tree. e.g.: A Java Tree implementation would return true for JavaVisitors and false for MavenVisitors- Specified by:
isAcceptablein interfaceTree- Type Parameters:
P- the visitor's context argument- Returns:
- 'true' if the arguments to this function would be valid arguments to accept()
-
-