From 116ae0ab65d88b776c091a6ccee13578b4e3314c Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Tue, 16 Jul 2013 18:04:14 +0200 Subject: SONAR-4501 Moved Category & SubCategory to internal package --- .../main/java/org/sonar/api/config/Category.java | 73 ---------------------- .../org/sonar/api/config/PropertyDefinitions.java | 3 + .../java/org/sonar/api/config/SubCategory.java | 35 ----------- .../org/sonar/api/config/internal/Category.java | 73 ++++++++++++++++++++++ .../org/sonar/api/config/internal/SubCategory.java | 36 +++++++++++ .../sonar/api/config/internal/package-info.java | 23 +++++++ .../java/org/sonar/api/config/CategoryTest.java | 37 ----------- .../sonar/api/config/PropertyDefinitionsTest.java | 3 + .../sonar/api/config/internal/CategoryTest.java | 40 ++++++++++++ 9 files changed, 178 insertions(+), 145 deletions(-) delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java create mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/config/internal/CategoryTest.java (limited to 'sonar-plugin-api/src') diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java deleted file mode 100644 index ddb8ff34367..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.config; - -import org.apache.commons.lang.StringUtils; - -import java.util.Locale; - -/** - * @since 3.7 - */ -public class Category { - - private final String originalKey; - private final boolean special; - - public Category(String originalKey) { - this(originalKey, false); - } - - Category(String originalKey, boolean special) { - this.originalKey = originalKey; - this.special = special; - } - - public String originalKey() { - return originalKey; - } - - public String key() { - return StringUtils.lowerCase(originalKey, Locale.ENGLISH); - } - - public boolean isSpecial() { - return special; - } - - @Override - public int hashCode() { - return key().hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Category)) { - return false; - } - return StringUtils.equalsIgnoreCase(((Category) obj).originalKey, this.originalKey); - } - - @Override - public String toString() { - return this.originalKey; - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java index 94edae487ff..c27f1a0babd 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java @@ -19,6 +19,9 @@ */ package org.sonar.api.config; +import org.sonar.api.config.internal.SubCategory; + +import org.sonar.api.config.internal.Category; import com.google.common.base.Strings; import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java deleted file mode 100644 index cd90b20e2f0..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.config; - -/** - * @since 3.7 - */ -public class SubCategory extends Category { - - public SubCategory(String originalKey) { - super(originalKey); - } - - SubCategory(String originalKey, boolean special) { - super(originalKey, special); - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java new file mode 100644 index 00000000000..ff7b958a2d1 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java @@ -0,0 +1,73 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.api.config.internal; + +import org.apache.commons.lang.StringUtils; + +import java.util.Locale; + +/** + * @since 3.7 + */ +public class Category { + + private final String originalKey; + private final boolean special; + + public Category(String originalKey) { + this(originalKey, false); + } + + public Category(String originalKey, boolean special) { + this.originalKey = originalKey; + this.special = special; + } + + public String originalKey() { + return originalKey; + } + + public String key() { + return StringUtils.lowerCase(originalKey, Locale.ENGLISH); + } + + public boolean isSpecial() { + return special; + } + + @Override + public int hashCode() { + return key().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Category)) { + return false; + } + return StringUtils.equalsIgnoreCase(((Category) obj).originalKey, this.originalKey); + } + + @Override + public String toString() { + return this.originalKey; + } + +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java new file mode 100644 index 00000000000..04cf2747473 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java @@ -0,0 +1,36 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.api.config.internal; + + +/** + * @since 3.7 + */ +public class SubCategory extends Category { + + public SubCategory(String originalKey) { + super(originalKey); + } + + public SubCategory(String originalKey, boolean special) { + super(originalKey, special); + } + +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java new file mode 100644 index 00000000000..139939481bf --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.api.config.internal; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java deleted file mode 100644 index e8ee207892f..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.config; - -import org.junit.Test; - -import static org.fest.assertions.Assertions.assertThat; - -public class CategoryTest { - - @Test - public void category_key_is_case_insentive() { - assertThat(new Category("Licenses")).isEqualTo(new Category("licenses")); - } - - @Test - public void should_preserve_original_key() { - assertThat(new Category("Licenses").originalKey()).isEqualTo("Licenses"); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java index 9bc2eace66b..dacbb9106dc 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java @@ -19,6 +19,9 @@ */ package org.sonar.api.config; +import org.sonar.api.config.internal.SubCategory; + +import org.sonar.api.config.internal.Category; import org.junit.Test; import org.sonar.api.Properties; import org.sonar.api.Property; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/internal/CategoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/internal/CategoryTest.java new file mode 100644 index 00000000000..7ac22319e63 --- /dev/null +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/internal/CategoryTest.java @@ -0,0 +1,40 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.api.config.internal; + +import org.junit.Test; + +import static org.fest.assertions.Assertions.assertThat; + +public class CategoryTest { + + @Test + public void category_key_is_case_insentive() { + assertThat(new Category("Licenses")).isEqualTo(new Category("licenses")); + + // Just to raise coverage + assertThat(new Category("Licenses")).isNotEqualTo(new SubCategory("foo")); + } + + @Test + public void should_preserve_original_key() { + assertThat(new Category("Licenses").originalKey()).isEqualTo("Licenses"); + } +} -- cgit v1.2.3