001/*
002 * SonarQube
003 * Copyright (C) 2009-2017 SonarSource SA
004 * mailto:info AT sonarsource DOT com
005 *
006 * This program is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020package org.sonar.api;
021
022import java.lang.annotation.ElementType;
023import java.lang.annotation.Retention;
024import java.lang.annotation.RetentionPolicy;
025import java.lang.annotation.Target;
026
027/**
028 * Property value can be set in different ways :
029 * <ul>
030 * <li>System property</li>
031 * <li>Batch command-line (-Dfoo=bar in Maven or sonar-runner)</li>
032 * <li>Maven pom.xml (element {@literal <properties>})</li>
033 * <li>Maven settings.xml</li>
034 * <li>SonarQube web administration console</li>
035 * </ul>
036 *
037 * @since 1.10
038 */
039@Retention(RetentionPolicy.RUNTIME)
040@Target(ElementType.TYPE)
041public @interface Property {
042
043  /**
044   * Unique key within all plugins. It's recommended to prefix the key by 'sonar.' and the plugin name. Examples :
045   * 'sonar.cobertura.reportPath' and 'sonar.cpd.minimumTokens'.
046   */
047  String key();
048
049  /**
050   * The empty string "" is considered as null, so it's not possible to have empty strings for default values.
051   */
052  String defaultValue() default "";
053
054  String name();
055
056  String description() default "";
057
058  /**
059   * @since 2.11
060   * @see org.sonar.api.config.PropertyDefinition#category()
061   */
062  String category() default "";
063
064  /**
065   * Is the property displayed in project settings page ?
066   */
067  boolean project() default false;
068
069  /**
070   * Is the property displayed in module settings page ? A module is a maven sub-project.
071   */
072  boolean module() default false;
073
074  /**
075   * Is the property displayed in global settings page ?
076   */
077  boolean global() default true;
078
079  /**
080   * @since 3.0
081   */
082  PropertyType type() default PropertyType.STRING;
083
084  /**
085   * Options for *_LIST types
086   *
087   * @since 3.0  Options for property of type {@link PropertyType#SINGLE_SELECT_LIST}
088   * For example {"property_1", "property_3", "property_3"}).
089   *
090   * @since 3.3  Options for property of type {@link PropertyType#METRIC}<br>
091   * If no option is specified, any metric will match.<br>
092   * If options are specified, all must match for the metric to be displayed.<br>
093   * Three types of filter are supported <code>key:REGEXP</code>, <code>domain:REGEXP</code> and <code>type:comma_separated__list_of_types</code>.<br>
094   * For example <code>key:new_.*</code> will match any metric which key starts by <code>new_</code>.<br>
095   * For example <code>type:INT,FLOAT</code> will match any metric of type <code>INT</code> or <code>FLOAT</code>.<br>
096   * For example <code>type:NUMERIC</code> will match any metric of numerictype.
097   */
098  String[] options() default {};
099
100  /**
101   * Can the property take multiple values. Eg: list of email addresses.
102   *
103   * @since 3.3
104   */
105  boolean multiValues() default false;
106
107  /**
108   * A Property of type <code>PropertyType.PROPERTY_SET</code> can reference a set of properties
109   * by its key.
110   *
111   * @since 3.3
112   * @deprecated since 6.1, as it was not used and too complex to maintain.
113   */
114  @Deprecated
115  String propertySetKey() default "";
116
117  /**
118   * A Property with fields is considered a property set.
119   *
120   * @since 3.3
121   */
122  PropertyField[] fields() default {};
123
124  /**
125   * Relocation of key.
126   * @since 3.4
127   */
128  String deprecatedKey() default "";
129}