diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-04-25 20:42:57 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-04-25 20:43:08 +0200 |
commit | 097437f96c9d57375e7537da53a5a95bc096655a (patch) | |
tree | 2e7b8a7cdbaddb43b9a7c29f2bef9ed0e10c5638 /sonar-plugin-api/src/main/java | |
parent | f3209b446356db78f90a102890d453f0c487f047 (diff) | |
download | sonarqube-097437f96c9d57375e7537da53a5a95bc096655a.tar.gz sonarqube-097437f96c9d57375e7537da53a5a95bc096655a.zip |
Complete WebService with new param metadata
Diffstat (limited to 'sonar-plugin-api/src/main/java')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java | 65 |
1 files changed, 61 insertions, 4 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java index a4725146bdd..0dbcfd0aa5c 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/WebService.java @@ -35,10 +35,10 @@ import java.util.Map; /** * Defines a web service. Note that contrary to the deprecated {@link org.sonar.api.web.Webservice} * the ws is fully implemented in Java and does not require any Ruby on Rails code. - * + * <p/> * <p/> * The classes implementing this extension point must be declared in {@link org.sonar.api.SonarPlugin#getExtensions()}. - * + * <p/> * <h3>How to use</h3> * <pre> * public class HelloWs implements WebService { @@ -370,7 +370,9 @@ public interface WebService extends ServerExtension { } class NewParam { - private String key, description; + private String key, description, exampleValue; + private boolean required = false; + private String[] possibleValues = null; private NewParam(String key) { this.key = key; @@ -381,6 +383,33 @@ public interface WebService extends ServerExtension { return this; } + /** + * Is the parameter required or optional ? Default value is false (optional). + * @since 4.4 + */ + public NewParam setRequired(boolean b) { + this.required = b; + return this; + } + + /** + * @since 4.4 + */ + public NewParam setExampleValue(@Nullable String s) { + this.exampleValue = s; + return this; + } + + /** + * Exhaustive list of possible values when it makes sense, for example + * list of severities. + * @since 4.4 + */ + public NewParam setPossibleValues(@Nullable String... s) { + this.possibleValues = s; + return this; + } + @Override public String toString() { return key; @@ -389,11 +418,16 @@ public interface WebService extends ServerExtension { @Immutable class Param { - private final String key, description; + private final String key, description, exampleValue; + private final boolean required; + private final String[] possibleValues; public Param(NewParam newParam) { this.key = newParam.key; this.description = newParam.description; + this.exampleValue = newParam.exampleValue; + this.required = newParam.required; + this.possibleValues = (newParam.possibleValues == null ? new String[0] : newParam.possibleValues); } public String key() { @@ -405,6 +439,29 @@ public interface WebService extends ServerExtension { return description; } + /** + * @since 4.4 + */ + @CheckForNull + public String exampleValue() { + return exampleValue; + } + + /** + * Is the parameter required or optional ? + * @since 4.4 + */ + public boolean isRequired() { + return required; + } + + /** + * @since 4.4 + */ + public String[] possibleValues() { + return possibleValues; + } + @Override public String toString() { return key; |