From 47f803be07c81dac2396f364deca15a2bb1fa7e8 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 21 Feb 2012 12:31:23 +0100 Subject: Add ResourceDefinition#hasSourceCode --- .../sonar/api/resources/ResourceDefinition.java | 26 +++++++++++++++++----- .../api/resources/ResourceDefinitionTest.java | 1 + 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'sonar-plugin-api') 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 -- cgit v1.2.3