-
-
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.
- Loading branch information
Showing
60 changed files
with
444 additions
and
421 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
41 changes: 41 additions & 0 deletions
41
src/main/java/tech/jhipster/lite/module/domain/properties/JHipsterModuleParameters.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,41 @@ | ||
package tech.jhipster.lite.module.domain.properties; | ||
|
||
import java.util.Map; | ||
import tech.jhipster.lite.common.domain.JHipsterCollections; | ||
import tech.jhipster.lite.error.domain.Assert; | ||
|
||
record JHipsterModuleParameters(Map<String, Object> parameters) { | ||
public JHipsterModuleParameters(Map<String, Object> parameters) { | ||
this.parameters = JHipsterCollections.immutable(parameters); | ||
} | ||
|
||
<T> T getOrDefault(String key, T defaultValue, Class<T> clazz) { | ||
Assert.notBlank("key", key); | ||
|
||
if (!parameters.containsKey(key)) { | ||
return defaultValue; | ||
} | ||
|
||
return get(key, clazz); | ||
} | ||
|
||
<T> T get(String key, Class<T> clazz) { | ||
Assert.notBlank("key", key); | ||
|
||
Object property = parameters.get(key); | ||
|
||
if (property == null) { | ||
throw new UnknownPropertyException(key); | ||
} | ||
|
||
if (clazz.isInstance(property)) { | ||
return clazz.cast(property); | ||
} | ||
|
||
throw InvalidPropertyTypeException.builder().key(key).expectedType(clazz).actualType(property.getClass()); | ||
} | ||
|
||
public Map<String, Object> get() { | ||
return parameters(); | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
src/main/java/tech/jhipster/lite/project/domain/history/ModuleParameters.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,28 @@ | ||
package tech.jhipster.lite.project.domain.history; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import tech.jhipster.lite.common.domain.JHipsterCollections; | ||
import tech.jhipster.lite.error.domain.Assert; | ||
|
||
public record ModuleParameters(Map<String, Object> parameters) { | ||
public static final ModuleParameters EMPTY = new ModuleParameters(Map.of()); | ||
|
||
public ModuleParameters(Map<String, Object> parameters) { | ||
this.parameters = JHipsterCollections.immutable(parameters); | ||
} | ||
|
||
public Map<String, Object> get() { | ||
return parameters(); | ||
} | ||
|
||
public ModuleParameters merge(ModuleParameters other) { | ||
Assert.notNull("other", other); | ||
|
||
Map<String, Object> mergedParameters = new HashMap<>(); | ||
mergedParameters.putAll(parameters); | ||
mergedParameters.putAll(other.parameters); | ||
|
||
return new ModuleParameters(mergedParameters); | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
src/main/java/tech/jhipster/lite/project/domain/history/ModuleProperties.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.