001    /*
002     * Sonar, open source software quality management tool.
003     * Copyright (C) 2009 SonarSource SA
004     * mailto:contact AT sonarsource DOT com
005     *
006     * Sonar 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     * Sonar 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
017     * License along with Sonar; if not, write to the Free Software
018     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
019     */
020    package org.sonar.api.checks.profiles;
021    
022    import org.apache.commons.lang.builder.ToStringBuilder;
023    import org.sonar.check.Priority;
024    
025    import java.util.HashMap;
026    import java.util.Map;
027    
028    /**
029     * EXPERIMENTAL - will be used in version 2.2
030     */
031    public class Check {
032    
033      private String repositoryKey;
034      private String templateKey;
035      private Priority priority = null;
036      private final Map<String, String> properties = new HashMap<String,String>();
037    
038      public Check() {
039      }
040    
041      public Check(String repositoryKey, String templateKey) {
042        this.repositoryKey = repositoryKey;
043        this.templateKey = templateKey;
044      }
045    
046      public String getTemplateKey() {
047        return templateKey;
048      }
049    
050      public String getRepositoryKey() {
051        return repositoryKey;
052      }
053    
054      public void setRepositoryKey(String repositoryKey) {
055        this.repositoryKey = repositoryKey;
056      }
057    
058      public void setTemplateKey(String templateKey) {
059        this.templateKey = templateKey;
060      }
061    
062      public Priority getPriority() {
063        return priority;
064      }
065    
066      public void setPriority(Priority priority) {
067        this.priority = priority;
068      }
069    
070      public Map<String, String> getProperties() {
071        return properties;
072      }
073    
074      public String getProperty(String key) {
075        return properties.get(key);
076      }
077    
078      public void addProperty(String key, Object value) {
079        properties.put(key, value.toString());
080      }
081    
082      public void addProperties(Map<String, String> properties) {
083        this.properties.putAll(properties);
084      }
085    
086      public void setProperties(Map<String, String> properties) {
087        this.properties.clear();
088        this.properties.putAll(properties);
089      }
090    
091      @Override
092      public boolean equals(Object o) {
093        return o == this;
094      }
095    
096      @Override
097      public int hashCode() {
098        return super.hashCode();
099      }
100    
101      @Override
102      public String toString() {
103        return new ToStringBuilder(this)
104            .append("repository", repositoryKey)
105            .append("template", templateKey)
106            .append("priority", priority)
107            .toString();
108      }
109    }