Class IndentLevel
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.indentation.IndentLevel
Encapsulates representation of notion of expected indentation levels.
Provide a way to have multiple acceptable levels.
This class is immutable.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Creates new instance with no acceptable indentation level.IndentLevel
(int indent) Creates new instance with one acceptable indentation level.IndentLevel
(IndentLevel base, int... offsets) Creates new instance for nested structure. -
Method Summary
Modifier and TypeMethodDescriptionstatic IndentLevel
addAcceptable
(IndentLevel base, int... additions) Adds one or more acceptable indentation level.static IndentLevel
addAcceptable
(IndentLevel base, IndentLevel addition) Combines 2 acceptable indentation level classes.int
Returns first indentation level.int
Returns last indentation level.boolean
isAcceptable
(int indent) Checks if given indentation is acceptable.boolean
isGreaterThan
(int indent) Returns true if indent less than minimal of acceptable indentation levels, false otherwise.final boolean
Checks whether we have more than one level.toString()
-
Field Details
-
levels
Set of acceptable indentation levels.
-
-
Constructor Details
-
IndentLevel
public IndentLevel(int indent) Creates new instance with one acceptable indentation level.- Parameters:
indent
- acceptable indentation level.
-
IndentLevel
Creates new instance for nested structure.- Parameters:
base
- parent's leveloffsets
- offsets from parent's level.
-
IndentLevel
private IndentLevel()Creates new instance with no acceptable indentation level. This is only used internally to combine multiple levels.
-
-
Method Details
-
isMultiLevel
public final boolean isMultiLevel()Checks whether we have more than one level.- Returns:
- whether we have more than one level.
-
isAcceptable
public boolean isAcceptable(int indent) Checks if given indentation is acceptable.- Parameters:
indent
- indentation to check.- Returns:
- true if given indentation is acceptable, false otherwise.
-
isGreaterThan
public boolean isGreaterThan(int indent) Returns true if indent less than minimal of acceptable indentation levels, false otherwise.- Parameters:
indent
- indentation to check.- Returns:
- true if
indent
less than minimal of acceptable indentation levels, false otherwise.
-
addAcceptable
Adds one or more acceptable indentation level.- Parameters:
base
- class to add new indentations to.additions
- new acceptable indentation.- Returns:
- New acceptable indentation level instance.
-
addAcceptable
Combines 2 acceptable indentation level classes.- Parameters:
base
- class to add new indentations to.addition
- new acceptable indentation.- Returns:
- New acceptable indentation level instance.
-
getFirstIndentLevel
public int getFirstIndentLevel()Returns first indentation level.- Returns:
- indentation level.
-
getLastIndentLevel
public int getLastIndentLevel()Returns last indentation level.- Returns:
- indentation level.
-
toString
-