-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devonfw:main' into feature/131-support-for-tool-depende…
…cies
- Loading branch information
Showing
23 changed files
with
410 additions
and
197 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,5 @@ jobs: | |
java-version: '17' | ||
- name: Build project with Maven | ||
run: mvn -B -ntp -Dstyle.color=always install | ||
- name: Deploy to OSSRH nexus | ||
env: | ||
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | ||
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | ||
run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dmaven.install.skip=true -Dstyle.color=always -B -ntp deploy | ||
- name: Coveralls GitHub Action | ||
uses: coverallsapp/[email protected] | ||
uses: coverallsapp/[email protected] |
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
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
59 changes: 59 additions & 0 deletions
59
cli/src/main/java/com/devonfw/tools/ide/property/EnumProperty.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 com.devonfw.tools.ide.property; | ||
|
||
import java.util.Locale; | ||
|
||
import com.devonfw.tools.ide.commandlet.Commandlet; | ||
import com.devonfw.tools.ide.completion.CompletionCandidateCollector; | ||
import com.devonfw.tools.ide.context.IdeContext; | ||
|
||
/** | ||
* {@link Property} with {@link #getValueType() value type} {@link Boolean}. | ||
*/ | ||
public class EnumProperty<V extends Enum<V>> extends Property<V> { | ||
|
||
private final Class<V> valueType; | ||
|
||
/** | ||
* The constructor. | ||
* | ||
* @param name the {@link #getName() property name}. | ||
* @param required the {@link #isRequired() required flag}. | ||
* @param alias the {@link #getAlias() property alias}. | ||
*/ | ||
public EnumProperty(String name, boolean required, String alias, Class<V> valueType) { | ||
|
||
super(name, required, alias, null); | ||
this.valueType = valueType; | ||
} | ||
|
||
@Override | ||
public Class<V> getValueType() { | ||
|
||
return this.valueType; | ||
} | ||
|
||
@Override | ||
public V parse(String valueAsString, IdeContext context) { | ||
|
||
for (V enumConstant : this.valueType.getEnumConstants()) { | ||
String name = enumConstant.name().toLowerCase(Locale.ROOT); | ||
if (name.equals(valueAsString)) { | ||
return enumConstant; | ||
} | ||
} | ||
|
||
throw new IllegalArgumentException(String.format("Invalid Enum option: %s", valueAsString)); | ||
} | ||
|
||
@Override | ||
protected void completeValue(String arg, IdeContext context, Commandlet commandlet, | ||
CompletionCandidateCollector collector) { | ||
|
||
for (V enumConstant : this.valueType.getEnumConstants()) { | ||
String name = enumConstant.name().toLowerCase(Locale.ROOT); | ||
if (name.startsWith(arg)) { | ||
collector.add(name, null, this, commandlet); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.