diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2012-03-29 16:49:40 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2012-03-29 16:49:40 +0200 |
commit | 2dab91a6c29fe829b1413a6ec469ff82a20ee1a7 (patch) | |
tree | d4fb5aeeea65e863553f35c38ba08985a4307d31 /sonar-plugin-api/src | |
parent | 8fcbd9607c8c18cf8b91e8b26da46721de5db11e (diff) | |
download | sonarqube-2dab91a6c29fe829b1413a6ec469ff82a20ee1a7.tar.gz sonarqube-2dab91a6c29fe829b1413a6ec469ff82a20ee1a7.zip |
SONAR-3287 Add properties on ResourceType and use them in Ruby
=> To be able to tell, for instance, that a resource is "deletable"
and so to display the "Deletion" link accordingly.
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java index b040ef1378c..a86d0b411ab 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java @@ -19,9 +19,12 @@ */ package org.sonar.api.resources; +import java.util.Map; + import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; import com.google.common.base.Strings; +import com.google.common.collect.Maps; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; @@ -40,6 +43,7 @@ public final class ResourceType { private String iconPath; private boolean availableForFilters = false; private boolean hasSourceCode = false; + private Map<String, String> properties = Maps.newHashMap(); public Builder(String qualifier) { this.qualifier = qualifier; @@ -63,6 +67,16 @@ public final class ResourceType { return this; } + /** + * @since 2.15 + */ + public Builder setProperty(String key, String value) { + Preconditions.checkNotNull(key); + Preconditions.checkNotNull(value); + properties.put(key, value); + return this; + } + public ResourceType build() { if (Strings.isNullOrEmpty(iconPath)) { iconPath = "/images/q/" + qualifier + ".png"; @@ -81,12 +95,14 @@ public final class ResourceType { private final String iconPath; private final boolean hasSourceCode; private final boolean availableForFilters; + private Map<String, String> properties; private ResourceType(Builder builder) { this.qualifier = builder.qualifier; this.iconPath = builder.iconPath; this.availableForFilters = builder.availableForFilters; this.hasSourceCode = builder.hasSourceCode; + this.properties = Maps.newHashMap(builder.properties); } /** @@ -108,6 +124,22 @@ public final class ResourceType { return hasSourceCode; } + /** + * @since 2.15 + */ + public String getStringProperty(String key) { + Preconditions.checkNotNull(key); + return properties.get(key); + } + + /** + * @since 2.15 + */ + public Boolean getBooleanProperty(String key) { + Preconditions.checkNotNull(key); + return Boolean.valueOf(properties.get(key)); + } + @Override public boolean equals(Object o) { if (this == o) { |