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.java.language; 021 022 public class ArgumentAndReturnType { 023 024 private final JavaType javaType; 025 private final String classCanonicalName; 026 private final boolean isArray; 027 028 public ArgumentAndReturnType(JavaType javaType, boolean isArray) { 029 this(javaType, null, isArray); 030 } 031 032 public ArgumentAndReturnType(String classCanonicalName, boolean isArray) { 033 this(JavaType.OBJECT, classCanonicalName, isArray); 034 } 035 036 ArgumentAndReturnType(JavaType javaType, String classCanonicalName, boolean isArray) { 037 if (javaType == JavaType.OBJECT && (classCanonicalName == null || classCanonicalName.equals(""))) { 038 throw new IllegalStateException("With an Object JavaType, this is mandatory to specify the canonical name of the class."); 039 } 040 this.javaType = javaType; 041 this.classCanonicalName = classCanonicalName; 042 this.isArray = isArray; 043 } 044 045 public ArgumentAndReturnType(ArgumentAndReturnType argumentAndReturnType) { 046 this(argumentAndReturnType.javaType, argumentAndReturnType.classCanonicalName, argumentAndReturnType.isArray); 047 } 048 049 public boolean isVoid() { 050 return javaType == JavaType.VOID; 051 } 052 053 public JavaType getJavaType() { 054 return javaType; 055 } 056 057 public String getClassCanonicalName() { 058 return classCanonicalName; 059 } 060 061 public boolean isArray() { 062 return isArray; 063 } 064 065 public boolean isOject() { 066 return javaType == JavaType.OBJECT; 067 } 068 }