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.api.batch.sensor.internal; 021 022 import org.sonar.api.batch.sensor.SensorDescriptor; 023 024 import org.sonar.api.batch.fs.InputFile; 025 import org.sonar.api.batch.measure.Metric; 026 027 import java.util.Arrays; 028 import java.util.Collection; 029 030 public class DefaultSensorDescriptor implements SensorDescriptor { 031 032 private String name; 033 private Metric<?>[] dependsOn = new Metric<?>[0]; 034 private Metric<?>[] provides = new Metric<?>[0]; 035 private String[] languages = new String[0]; 036 private InputFile.Type[] types = new InputFile.Type[0]; 037 private String[] ruleRepositories = new String[0]; 038 039 public String name() { 040 return name; 041 } 042 043 public Metric[] dependsOn() { 044 return dependsOn; 045 } 046 047 public Metric[] provides() { 048 return provides; 049 } 050 051 public Collection<String> languages() { 052 return Arrays.asList(languages); 053 } 054 055 public Collection<InputFile.Type> types() { 056 return Arrays.asList(types); 057 } 058 059 public Collection<String> ruleRepositories() { 060 return Arrays.asList(ruleRepositories); 061 } 062 063 @Override 064 public DefaultSensorDescriptor name(String name) { 065 this.name = name; 066 return this; 067 } 068 069 @Override 070 public DefaultSensorDescriptor dependsOn(Metric<?>... metrics) { 071 this.dependsOn = metrics; 072 return this; 073 } 074 075 @Override 076 public DefaultSensorDescriptor provides(Metric<?>... metrics) { 077 this.provides = metrics; 078 return this; 079 } 080 081 @Override 082 public DefaultSensorDescriptor workOnLanguages(String... languageKeys) { 083 this.languages = languageKeys; 084 return this; 085 } 086 087 @Override 088 public DefaultSensorDescriptor workOnFileTypes(InputFile.Type... types) { 089 this.types = types; 090 return this; 091 } 092 093 @Override 094 public DefaultSensorDescriptor createIssuesForRuleRepositories(String... repositoryKeys) { 095 this.ruleRepositories = repositoryKeys; 096 return this; 097 } 098 099 }