-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/vertigo-io/vertigo-core …
…into develop
- Loading branch information
Showing
2 changed files
with
47 additions
and
32 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
vertigo-core/src/main/java/io/vertigo/core/node/definition/SimpleEnumDefinitionProvider.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,39 @@ | ||
package io.vertigo.core.node.definition; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Provides a list of definitions through an enum. | ||
* | ||
* @author skerdudou | ||
*/ | ||
public interface SimpleEnumDefinitionProvider<D extends Definition> extends DefinitionProvider { | ||
|
||
/** | ||
* Return a list of definitions with a set of already known definitions | ||
* | ||
* @param definitionSpace the actual definitionSpace | ||
* @return the list of new definition to register | ||
*/ | ||
@Override | ||
default List<DefinitionSupplier> get(final DefinitionSpace definitionSpace) { | ||
final var enumValues = getEnumClass().getEnumConstants(); | ||
|
||
return Arrays.stream(enumValues) | ||
.map(v -> (DefinitionSupplier) v::buildDefinition) | ||
.toList(); | ||
} | ||
|
||
Class<? extends EnumDefinition<D, ? extends Enum<?>>> getEnumClass(); | ||
|
||
static interface EnumDefinition<D, T extends Enum<T>> { | ||
|
||
String getDefinitionName(); | ||
|
||
D buildDefinition(DefinitionSpace definitionSpace); | ||
|
||
D get(); | ||
|
||
} | ||
} |
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