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 */ 020package org.sonar.api.resources; 021 022/** 023 * @deprecated in 4.2. Only file system components are managed by SQ core (files/directories). 024 */ 025@Deprecated 026public class Method extends Resource { 027 028 public static final String SCOPE = Scopes.BLOCK_UNIT; 029 030 protected String qualifier; 031 protected Language language; 032 033 protected Method(String key, String qualifier, Language language) { 034 setKey(key); 035 this.qualifier = qualifier; 036 this.language = language; 037 } 038 039 @Override 040 public String getName() { 041 return getKey(); 042 } 043 044 @Override 045 public String getLongName() { 046 return getKey(); 047 } 048 049 @Override 050 public String getDescription() { 051 return null; 052 } 053 054 @Override 055 public final Language getLanguage() { 056 return language; 057 } 058 059 @Override 060 public final String getScope() { 061 return SCOPE; 062 } 063 064 @Override 065 public final String getQualifier() { 066 return qualifier; 067 } 068 069 @Override 070 public Resource getParent() { 071 return null; 072 } 073 074 @Override 075 public final boolean matchFilePattern(String antPattern) { 076 return false; 077 } 078 079 @Override 080 public final boolean equals(Object o) { 081 if (this == o) { 082 return true; 083 } 084 if (!(o instanceof Method)) { 085 return false; 086 } 087 Method method = (Method) o; 088 if (!getKey().equals(method.getKey())) { 089 return false; 090 } 091 if (!qualifier.equals(method.qualifier)) { 092 return false; 093 } 094 return true; 095 } 096 097 @Override 098 public final int hashCode() { 099 int result = super.hashCode(); 100 result = 31 * result + qualifier.hashCode(); 101 result = 31 * result + getKey().hashCode(); 102 return result; 103 } 104 105 public static Method createMethod(String key, Language language) { 106 return new Method(key, Qualifiers.METHOD, language); 107 } 108}