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.resources;
021
022 /**
023 * @since 1.10
024 */
025 public final class ResourceUtils {
026
027 private ResourceUtils() {
028 }
029
030 /* SCOPES */
031
032 public static boolean isSet(Resource resource) {
033 return Resource.SCOPE_SET.equals(resource.getScope());
034 }
035
036 public static boolean isSpace(Resource resource) {
037 return Resource.SCOPE_SPACE.equals(resource.getScope());
038 }
039
040 public static boolean isEntity(Resource resource) {
041 return Resource.SCOPE_ENTITY.equals(resource.getScope());
042 }
043
044 /**
045 * Use isSet() instead
046 */
047 @Deprecated
048 public static boolean isProject(Resource resource) {
049 return isSet(resource);
050 }
051
052 /**
053 * Use isSpace() instead
054 */
055 @Deprecated
056 public static boolean isDirectory(Resource resource) {
057 return isSpace(resource);
058 }
059
060 /**
061 * Use isEntity() instead
062 */
063 @Deprecated
064 public static boolean isFile(Resource resource) {
065 return isEntity(resource);
066 }
067
068
069 /* QUALIFIERS */
070
071 public static boolean isClass(Resource resource) {
072 return Resource.QUALIFIER_CLASS.equals(resource.getQualifier());
073 }
074
075 public static boolean isPackage(Resource resource) {
076 return Resource.QUALIFIER_PACKAGE.equals(resource.getQualifier());
077 }
078
079 public static boolean isUnitTestClass(Resource resource) {
080 return Resource.QUALIFIER_UNIT_TEST_CLASS.equals(resource.getQualifier());
081 }
082
083 public static boolean isRootProject(Resource resource) {
084 return Resource.QUALIFIER_PROJECT.equals(resource.getQualifier());
085 }
086
087 public static boolean isModuleProject(Resource resource) {
088 return Resource.QUALIFIER_MODULE.equals(resource.getQualifier());
089 }
090 }