001    /*
002     * SonarQube, open source software quality management tool.
003     * Copyright (C) 2008-2014 SonarSource
004     * mailto:contact AT sonarsource DOT com
005     *
006     * SonarQube 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     * SonarQube 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     */
020    package org.sonar.wsclient.issue;
021    
022    import javax.annotation.Nullable;
023    import java.util.HashMap;
024    import java.util.Map;
025    
026    /**
027     * @since 3.6
028     */
029    public class NewIssue {
030    
031      private final Map<String, Object> params = new HashMap<String, Object>();
032    
033      private NewIssue() {
034      }
035    
036      public static NewIssue create() {
037        return new NewIssue();
038      }
039    
040      public Map<String, Object> urlParams() {
041        return params;
042      }
043    
044      /**
045       * Optionally set the severity, in INFO, MINOR, MAJOR, CRITICAL or BLOCKER. Default value is MAJOR.
046       */
047      public NewIssue severity(@Nullable String s) {
048        params.put("severity", s);
049        return this;
050      }
051    
052      public NewIssue component(String s) {
053        params.put("component", s);
054        return this;
055      }
056    
057      /**
058       * Rule key prefixed by the repository, for example "checkstyle:AvoidCycle".
059       */
060      public NewIssue rule(String s) {
061        params.put("rule", s);
062        return this;
063      }
064    
065      /**
066       * Optional line, starting from 1.
067       */
068      public NewIssue line(@Nullable Integer i) {
069        params.put("line", i);
070        return this;
071      }
072    
073      public NewIssue message(@Nullable String s) {
074        params.put("message", s);
075        return this;
076      }
077    
078      public NewIssue effortToFix(@Nullable Double d) {
079        params.put("effortToFix", d);
080        return this;
081      }
082    
083      public NewIssue attribute(String key, String value) {
084        params.put("attr[" + key + "]", value);
085        return this;
086      }
087    }