Class PipelineDeclaration
- All Implemented Interfaces:
PipelineExpression
AST for a pipeline declaration - the root of the AST.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSimple value holder for the results of finding a step via thefind(BiPredicate)method. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPipelineDeclaration(List<StepChain> chains) Construct a newPipelineDeclarationwithout any metadata.PipelineDeclaration(List<StepChain> chains, PipelineMetadata metadata) -
Method Summary
Modifier and TypeMethodDescriptionReturn a newPipelineDeclarationwith the given step chain added to the end of thisPipelineDeclaration's list of chainsadd(PipelineDeclaration toAdd) Return a newPipelineDeclarationthat is the combination of this pipeline and the other - no merge or squishing or anything clever is going onprotected voidappendSource(StringBuilder appendTo) protected voidappendString(StringBuilder appendTo) protected booleancheckValid(Function<StepDeclaration, String> nameFunction) Check that thisPipelineDeclarationis valid.booleanfind(BiPredicate<StepChain, StepDeclaration> predicate) General purpose step-finding method.find(Predicate<StepDeclaration> predicate) Convenience version offind(BiPredicate)that drops the chain from the predicatefindAll(BiPredicate<StepChain, StepDeclaration> predicate) General purpose step-finding method.findDefinition(@NonNull String stepName) Search through for the definition of a step with the given name, using either the step id or aliasgetFirst()getLast()getStepNameFunction(StepNamingPolicy policy) inthashCode()booleanisEmpty()Return a newPipelineDeclaration, with a replacement step chainreplaceParameters(Map<String, Expression> replacements) Builds a new PipelineDeclaration by replacing tokens with those specified, while trying to preserve whitespaceintsize()final StringtoSource()final StringtoString()Returns a simplified view of the ast in a source-like fashion, but with a lot of details left out for concisenesswithMetadata(PipelineMetadata newMetadata) Clones this PipelineDeclaration but with different metadata.
-
Field Details
-
EMPTY
An empty
PipelineDeclaration. Useful in various situations where a null might otherwise be used, or might require a different API method to handle a base case.
-
-
Constructor Details
-
PipelineDeclaration
Construct a new
PipelineDeclarationwithout any metadata. -
PipelineDeclaration
-
-
Method Details
-
getBoundary
-
findDefinition
Search through for the definition of a step with the given name, using either the step id or alias
- Parameters:
stepName- name (id or alias) of a step to look for- Returns:
- the first found declaration of the found step, along with the step chain that it was found in, or empty if nothing was found
-
find
Convenience version of
find(BiPredicate)that drops the chain from the predicate -
find
General purpose step-finding method. Find a step using a predicate, returning the first step that matches (in ast order).
- Parameters:
predicate- test each step against this predicate- Returns:
- the first step (and chain) that matched, or empty if nothing found.
-
findAll
General purpose step-finding method. Find a list of steps using a predicate, returning all steps that match (in ast order).
- Parameters:
predicate- test each step against this predicate- Returns:
- a list of
PipelineDeclaration.Foundobjects for the steps that matched the predicate
-
replace
public PipelineDeclaration replace(@NonNull @NonNull StepChain found, @NonNull @NonNull StepChain newChain) throws IllegalStateException Return a new
PipelineDeclaration, with a replacement step chain- Parameters:
found- the step chain to replacenewChain- the replacement chain- Returns:
- a new
PipelineDeclarationwith the replacement made - Throws:
IllegalStateException- if found is not part of this pipeline declaration
-
findParameters
-
replaceParameters
Builds a new PipelineDeclaration by replacing tokens with those specified, while trying to preserve whitespace
- Parameters:
replacements- parameter names mapped to replacement expressions.- Returns:
- a new
PipelineDeclaration, or problems if any of the parameter tokens found in the pipeline declaration that were not replaced.
-
add
Return a new
PipelineDeclarationwith the given step chain added to the end of thisPipelineDeclaration's list of chains- Parameters:
toAdd- the chain to add- Returns:
- a new
PipelineDeclarationcontaining the given chain
-
add
Return a new
PipelineDeclarationthat is the combination of this pipeline and the other - no merge or squishing or anything clever is going on -
getFirst
- Returns:
- the 0th chain in this declaration
- Throws:
IndexOutOfBoundsException- if this declaration is empty
-
getLast
- Returns:
- the last chain in this declaration
- Throws:
IndexOutOfBoundsException- if this declaration is empty
-
isEmpty
public boolean isEmpty()- Returns:
- true if this declaration has no chains
-
appendString
-
appendSource
-
stepDefinitionIterator
- Returns:
- an
Iteratorthat yields all of theStepDefinitions in this pipeline declaration in the order they appear in the source. Skips all theStepReferences.
-
size
public int size()- Returns:
- the number of chains (not steps) in this pipeline declaration
-
getStepNameFunction
- Parameters:
policy- the step naming policy that will be applied- Returns:
- a function that gives the name for a step definition, returning either a unique generated name, if none was assigned, or the explicitly assigned name
-
checkValid
public ResultOrProblems<PipelineDeclaration> checkValid(Function<StepDeclaration, String> nameFunction) Check that this
PipelineDeclarationis valid. This check includes checking for step redefinition and pipeline cycles.- Parameters:
nameFunction- maps a StepDefinition to a name, seegetStepNameFunction(StepNamingPolicy)- Returns:
- function that provides step names for this pipeline or errors found
-
withMetadata
Clones this PipelineDeclaration but with different metadata.
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getChains
-
getMetadata
-
toString
Returns a simplified view of the ast in a source-like fashion, but with a lot of details left out for conciseness
-
toSource
- Specified by:
toSourcein interfacePipelineExpression- Returns:
- a string that can be parsed back in to the same ast as this one. It might not be whitespace-faithful...
-