*/
package org.sonar.api.config;
-import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.sonar.api.server.ServerSide;
import org.sonarsource.api.sonarlint.SonarLintSide;
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.sonar.api.PropertyType.PROPERTY_SET;
+
/**
* Declare a plugin property. Values are available at runtime through the component {@link Settings}.
* <br>
}
public PropertyDefinition build() {
- Preconditions.checkArgument(!Strings.isNullOrEmpty(key), "Key must be set");
+ checkArgument(!Strings.isNullOrEmpty(key), "Key must be set");
fixType(key, type);
- Preconditions.checkArgument(onQualifiers.isEmpty() || onlyOnQualifiers.isEmpty(), "Cannot define both onQualifiers and onlyOnQualifiers");
- Preconditions.checkArgument(!hidden || (onQualifiers.isEmpty() && onlyOnQualifiers.isEmpty()), "Cannot be hidden and defining qualifiers on which to display");
+ checkArgument(onQualifiers.isEmpty() || onlyOnQualifiers.isEmpty(), "Cannot define both onQualifiers and onlyOnQualifiers");
+ checkArgument(!hidden || (onQualifiers.isEmpty() && onlyOnQualifiers.isEmpty()), "Cannot be hidden and defining qualifiers on which to display");
if (hidden) {
global = false;
}
+ if (!fields.isEmpty()) {
+ type = PROPERTY_SET;
+ }
return new PropertyDefinition(this);
}
PropertyFieldDefinition.build("second").name("Second").type(PropertyType.INTEGER).indicativeSize(5).build())
.build();
+ assertThat(def.type()).isEqualTo(PropertyType.PROPERTY_SET);
assertThat(def.fields()).hasSize(2);
assertThat(def.fields().get(0).key()).isEqualTo("first");
assertThat(def.fields().get(0).name()).isEqualTo("First");
PropertyDefinition def = PropertyDefinition.create(prop);
+ assertThat(def.type()).isEqualTo(PropertyType.PROPERTY_SET);
assertThat(def.fields()).hasSize(2);
assertThat(def.fields().get(0).key()).isEqualTo("first");
assertThat(def.fields().get(0).name()).isEqualTo("First");