diff options
author | David Gageot <david@gageot.net> | 2012-07-04 18:02:37 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-07-04 19:14:10 +0200 |
commit | b547f32a3de0381e41b2da6cfab1545f7447b315 (patch) | |
tree | 774cd48198c1789b13fb431e2bc16bb07c6b04cd /sonar-plugin-api | |
parent | d9ec502ee20a45003ab3d55884cd95e1adfc22f2 (diff) | |
download | sonarqube-b547f32a3de0381e41b2da6cfab1545f7447b315.tar.gz sonarqube-b547f32a3de0381e41b2da6cfab1545f7447b315.zip |
SONAR-3529 First baby step in providing property sets
Diffstat (limited to 'sonar-plugin-api')
4 files changed, 78 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/PropertyValidation.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/PropertyValidation.java new file mode 100644 index 00000000000..d49158d732e --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/PropertyValidation.java @@ -0,0 +1,30 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.api.web; + +public interface PropertyValidation { + boolean validate(String value); + + class None implements PropertyValidation { + public boolean validate(String value) { + return true; + } + }; +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperties.java index 03b302cd395..f4fd18a874f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperties.java @@ -25,4 +25,6 @@ import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) public @interface WidgetProperties { WidgetProperty[] value() default {}; + + WidgetPropertySet[] sets() default {}; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperty.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperty.java index 4fd661a7dfb..652076a1d48 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperty.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetProperty.java @@ -37,4 +37,6 @@ public @interface WidgetProperty { String description() default ""; boolean optional() default true; + + Class<? extends PropertyValidation> validation() default PropertyValidation.None.class; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertySet.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertySet.java new file mode 100644 index 00000000000..28de523e788 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/WidgetPropertySet.java @@ -0,0 +1,44 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.api.web; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface WidgetPropertySet { + String key(); + + WidgetProperty[] value(); + + static WidgetPropertySet DEFAULT = new WidgetPropertySet() { + public Class<WidgetPropertySet> annotationType() { + return WidgetPropertySet.class; + } + + public WidgetProperty[] value() { + return null; + } + + public String key() { + return ""; + } + }; +} |