Top Description Fields Constructors Methods
com.github.javaparser.printer.lexicalpreservation

pack-priv final Class RemovedGroup

extends Object
implements Iterable<Removed>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Imports
com.github.javaparser.JavaToken, .TokenRange, .TokenTypes, com.github.javaparser.ast.Node, com.github.javaparser.printer.concretesyntaxmodel.CsmToken, java.util.Iterator, .List, .Optional, java.util.function.Function, java.util.stream.Collectors, .IntStream

This class represents a group of Removed elements. The Removed elements are ideally consecutive for the methods in this class to work correctly. This class consists of methods that calculate information to better handle the difference application for the containing Removed elements.
Author
ThLeu
See Also
Iterable

Field Summary

Modifier and TypeField and Description
private final Integer
private final Function<TokenRange, Boolean>
private final Function<TokenRange, Boolean>
private final Function<JavaToken, Boolean>
private final Function<JavaToken, Boolean>
private boolean
private final List<Removed>

Constructor Summary

AccessConstructor and Description
private
RemovedGroup(Integer firstElementIndex, List<Removed> removedList)

Method Summary

Modifier and TypeMethod and Description
pack-priv final Removed

Returns:

the first element of this RemovedGroup
getFirstElement
()

Returns the first element of this RemovedGroup

pack-priv final Optional<Integer>

Returns:

the indentation in front of this RemovedGroup or Optional.empty()
getIndentation
()

Returns the indentation in front of this RemovedGroup if possible.

private List<Integer>
pack-priv final Removed

Returns:

the last element of this RemovedGroup
getLastElement
()

Returns the last element of this RemovedGroup

pack-priv final Integer

Returns:

the last difference incex of this RemovedGroup
getLastElementIndex
()

Returns the difference index of the last element being removed with this RemovedGroup

private boolean
hasOnlyWhitespace(Removed startElement, Function<TokenRange, Boolean> hasOnlyWhitespaceFunction)

private boolean
pack-priv final boolean

Returns:

true if the RemovedGroup equates to a complete line
isACompleteLine
()

Returns true if the RemovedGroup equates to a complete line This is the case if there are only spaces and tabs left on the line besides the Removed elements.

pack-priv final boolean

Returns:

wheter the RemovedGroup was already processed
isProcessed
()

Returns whether the RemovedGroup was already processed and should not be processed again

public final Iterator<Removed>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
public static RemovedGroup

Returns:

a RemovedGroup object
of
(Integer
the difference index at which the RemovedGroup starts
firstElementIndex
,
List<Removed>
list of the consecutive Removed elements
removedList
)

Factory method to create a RemovedGroup which consists of consecutive Removed elements

pack-priv final void
processed()

Marks the RemovedGroup as processed which indicates that it should not be processed again

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

firstElementIndexback to summary
private final Integer firstElementIndex
hasOnlyWhitespaceBehindFunctionback to summary
private final Function<TokenRange, Boolean> hasOnlyWhitespaceBehindFunction
hasOnlyWhitespaceInFrontFunctionback to summary
private final Function<TokenRange, Boolean> hasOnlyWhitespaceInFrontFunction
hasOnlyWhitespaceJavaTokenBehindFunctionback to summary
private final Function<JavaToken, Boolean> hasOnlyWhitespaceJavaTokenBehindFunction
hasOnlyWhitespaceJavaTokenInFrontFunctionback to summary
private final Function<JavaToken, Boolean> hasOnlyWhitespaceJavaTokenInFrontFunction
isProcessedback to summary
private boolean isProcessed
removedListback to summary
private final List<Removed> removedList

Constructor Detail

RemovedGroupback to summary
private RemovedGroup(Integer firstElementIndex, List<Removed> removedList)

Method Detail

getFirstElementback to summary
pack-priv final Removed getFirstElement()

Returns the first element of this RemovedGroup

Returns:Removed

the first element of this RemovedGroup

getIndentationback to summary
pack-priv final Optional<Integer> getIndentation()

Returns the indentation in front of this RemovedGroup if possible. If there is something else than whitespace in front, Optional.empty() is returned.

Returns:Optional<Integer>

the indentation in front of this RemovedGroup or Optional.empty()

getIndicesBeingRemovedback to summary
private List<Integer> getIndicesBeingRemoved()
getLastElementback to summary
pack-priv final Removed getLastElement()

Returns the last element of this RemovedGroup

Returns:Removed

the last element of this RemovedGroup

getLastElementIndexback to summary
pack-priv final Integer getLastElementIndex()

Returns the difference index of the last element being removed with this RemovedGroup

Returns:Integer

the last difference incex of this RemovedGroup

hasOnlyWhitespaceback to summary
private boolean hasOnlyWhitespace(Removed startElement, Function<TokenRange, Boolean> hasOnlyWhitespaceFunction)
hasOnlyWhiteSpaceForTokenFunctionback to summary
private boolean hasOnlyWhiteSpaceForTokenFunction(JavaToken token, Function<JavaToken, Optional<JavaToken>> tokenFunction)
isACompleteLineback to summary
pack-priv final boolean isACompleteLine()

Returns true if the RemovedGroup equates to a complete line This is the case if there are only spaces and tabs left on the line besides the Removed elements.
Example:

"  [Removed] [EOL]" -> this would be a complete line, regardless of spaces or tabs before or after the [Removed] element
"  [Removed] void [EOL]" -> this would not be a complete line because of the "void"
"  public [Removed] [EOL]" -> this would not be a complete line because of the "public"
Returns:boolean

true if the RemovedGroup equates to a complete line

isProcessedback to summary
pack-priv final boolean isProcessed()

Returns whether the RemovedGroup was already processed and should not be processed again

Returns:boolean

wheter the RemovedGroup was already processed

iteratorback to summary
public final Iterator<Removed> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<Removed>

an Iterator.

Annotations
@Override
ofback to summary
public static RemovedGroup of(Integer firstElementIndex, List<Removed> removedList)

Factory method to create a RemovedGroup which consists of consecutive Removed elements

Parameters
firstElementIndex:Integer

the difference index at which the RemovedGroup starts

removedList:List<Removed>

list of the consecutive Removed elements

Returns:RemovedGroup

a RemovedGroup object

Exceptions
IllegalArgumentException:
if the firstElementIndex is null or the removedList is empty or null
processedback to summary
pack-priv final void processed()

Marks the RemovedGroup as processed which indicates that it should not be processed again