diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-02-21 12:31:23 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-02-21 12:31:23 +0100 |
commit | 47f803be07c81dac2396f364deca15a2bb1fa7e8 (patch) | |
tree | 95a94de509eeb0def2aa3d17e03f88becb002f7d /sonar-plugin-api | |
parent | b27c50696631e0b9d4183a576e7c9783d5084ad7 (diff) | |
download | sonarqube-47f803be07c81dac2396f364deca15a2bb1fa7e8.tar.gz sonarqube-47f803be07c81dac2396f364deca15a2bb1fa7e8.zip |
Add ResourceDefinition#hasSourceCode
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceDefinition.java | 26 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceDefinitionTest.java | 1 |
2 files changed, 21 insertions, 6 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceDefinition.java index 09a057373cc..a3d89ce7e25 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceDefinition.java @@ -22,18 +22,22 @@ package org.sonar.api.resources; import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.base.Strings; +import org.sonar.api.BatchExtension; import org.sonar.api.ServerExtension; /** + * Experimental extension to declare types of resources. + * * @since 2.14 */ @Beta -public final class ResourceDefinition implements ServerExtension { +public final class ResourceDefinition implements BatchExtension, ServerExtension { public static class Builder { private String qualifier; private String iconPath; private boolean availableForFilters = false; + private boolean hasSourceCode = false; public Builder(String qualifier) { this.qualifier = qualifier; @@ -52,11 +56,16 @@ public final class ResourceDefinition implements ServerExtension { return this; } + public Builder hasSourceCode() { + this.hasSourceCode = true; + return this; + } + public ResourceDefinition build() { if (Strings.isNullOrEmpty(iconPath)) { iconPath = "/images/q/" + qualifier + ".png"; } - return new ResourceDefinition(qualifier, iconPath, availableForFilters); + return new ResourceDefinition(this); } } @@ -68,12 +77,14 @@ public final class ResourceDefinition implements ServerExtension { private final String qualifier; private final String iconPath; + private final boolean hasSourceCode; private final boolean availableForFilters; - private ResourceDefinition(String qualifier, String iconPath, boolean availableForFilters) { - this.qualifier = qualifier; - this.iconPath = iconPath; - this.availableForFilters = availableForFilters; + private ResourceDefinition(Builder builder) { + this.qualifier = builder.qualifier; + this.iconPath = builder.iconPath; + this.availableForFilters = builder.availableForFilters; + this.hasSourceCode = builder.hasSourceCode; } public String getQualifier() { @@ -88,4 +99,7 @@ public final class ResourceDefinition implements ServerExtension { return availableForFilters; } + public boolean hasSourceCode() { + return hasSourceCode; + } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceDefinitionTest.java index c18d59a7f58..1c86725afe4 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceDefinitionTest.java @@ -32,6 +32,7 @@ public class ResourceDefinitionTest { .build(); assertThat(def.getQualifier(), is("qualifier")); assertThat(def.getIconPath(), is("/images/q/qualifier.png")); + assertThat(def.hasSourceCode(), is(false)); } @Test |