Package de.spraener.nxtgen.target
Class CodeTarget
java.lang.Object
de.spraener.nxtgen.target.CodeTarget
Responsibility
A CodeTarget is an ordered collection of CodeSections. It can take each CodeSection with a key. Each CodeSection can be retrieved by this key for later modifications. A CodeTarget can only hold one CodeSection per key. Replacing is not possible and will rise a IllegalArgumentException.
It also delivers a collection of all added section in the order of insertion.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCodeSection(Object key, CodeSection aSection) Add a CodeSection under the given Key to the CodeTarget.getSection(Object key) Retrieve the CodeSection that was added with the specified key or null.Delivers all added CodeSections in the order of Insertion.inContext(Object aspect, ModelElement me, Consumer<CodeTarget>... consumers) Opens a new CodeTargetContext and calls all consumers on this CodeTarget, so they are working in that given CodeTargetContext.withCodeSection(Object key, CodeSection section) A wither for the addCodeSection-method to provide a fluent api.
-
Constructor Details
-
CodeTarget
public CodeTarget()
-
-
Method Details
-
addCodeSection
Add a CodeSection under the given Key to the CodeTarget. A former added CodeSection under that key will be replaced.- Parameters:
key- A key to reference a CodeSection for later modificationaSection- the CodeSection to be inserted.
-
withCodeSection
A wither for the addCodeSection-method to provide a fluent api.- Parameters:
key- A key to reference a CodeSection for later modification.section- The CodeSection to be inserted.- Returns:
- The CodeTarget itself.
-
getSection
Retrieve the CodeSection that was added with the specified key or null.- Parameters:
key- The key for the CodeSection requested- Returns:
- an Optional of the CodeSection. This can be empty if no CodeSection with that key is present.
-
getSectionsOrdered
Delivers all added CodeSections in the order of Insertion.- Returns:
-
inContext
Opens a new CodeTargetContext and calls all consumers on this CodeTarget, so they are working in that given CodeTargetContext.- Parameters:
aspect- An aspect the consumer working on or null.me- A ModelElement the consumers wokring on or null.consumers- a list of consumers to do some work on this CodeTarget.- Returns:
- CodeTarget itself for queuing.
-