-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1870 from DamnClin/modules-post-actions
Module post actions
- Loading branch information
Showing
12 changed files
with
141 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...tech/jhipster/lite/generator/module/domain/postaction/JHipsterModuleExecutionContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package tech.jhipster.lite.generator.module.domain.postaction; | ||
|
||
import tech.jhipster.lite.error.domain.Assert; | ||
import tech.jhipster.lite.generator.module.domain.JHipsterProjectFolder; | ||
|
||
public record JHipsterModuleExecutionContext(JHipsterProjectFolder projectFolder) { | ||
public JHipsterModuleExecutionContext { | ||
Assert.notNull("projectFolder", projectFolder); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...java/tech/jhipster/lite/generator/module/domain/postaction/JHipsterModulePostActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package tech.jhipster.lite.generator.module.domain.postaction; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import tech.jhipster.lite.error.domain.Assert; | ||
import tech.jhipster.lite.generator.module.domain.JHipsterModule.JHipsterModuleBuilder; | ||
|
||
public class JHipsterModulePostActions { | ||
|
||
private final Collection<RunnableInContext> actions; | ||
|
||
private JHipsterModulePostActions(JHipsterModulePostActionsBuilder builder) { | ||
actions = builder.actions; | ||
} | ||
|
||
public static JHipsterModulePostActionsBuilder builder(JHipsterModuleBuilder module) { | ||
return new JHipsterModulePostActionsBuilder(module); | ||
} | ||
|
||
public void run(JHipsterModuleExecutionContext context) { | ||
Assert.notNull("context", context); | ||
|
||
actions.forEach(action -> action.run(context)); | ||
} | ||
|
||
public static class JHipsterModulePostActionsBuilder { | ||
|
||
private final JHipsterModuleBuilder module; | ||
private final Collection<RunnableInContext> actions = new ArrayList<>(); | ||
|
||
private JHipsterModulePostActionsBuilder(JHipsterModuleBuilder module) { | ||
Assert.notNull("module", module); | ||
|
||
this.module = module; | ||
} | ||
|
||
public JHipsterModulePostActionsBuilder add(Runnable action) { | ||
Assert.notNull("action", action); | ||
|
||
return add(context -> action.run()); | ||
} | ||
|
||
public JHipsterModulePostActionsBuilder add(RunnableInContext action) { | ||
Assert.notNull("action", action); | ||
|
||
actions.add(action); | ||
|
||
return this; | ||
} | ||
|
||
public JHipsterModuleBuilder and() { | ||
return module; | ||
} | ||
|
||
public JHipsterModulePostActions build() { | ||
return new JHipsterModulePostActions(this); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/tech/jhipster/lite/generator/module/domain/postaction/RunnableInContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package tech.jhipster.lite.generator.module.domain.postaction; | ||
|
||
@FunctionalInterface | ||
public interface RunnableInContext { | ||
void run(JHipsterModuleExecutionContext context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters