1 2 29 package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify; 30 31 public class ExternalSignature implements ISignature { 32 33 private IClass[] _parameters; 34 35 public ExternalSignature(Class [] parameters) { 36 _parameters = new IClass[parameters.length]; 37 for (int i = 0; i < parameters.length; i++) { 38 if (parameters[i].isArray()) { 39 _parameters[i] = 40 new ArrayDef(new ExternalClass(parameters[i].getComponentType())); 41 } 42 else { 43 _parameters[i] = new ExternalClass(parameters[i]); 44 } 45 } 46 } 47 48 57 public boolean isCompatibleWith(ISignature signature) { 58 boolean result = true; 59 60 if (_parameters.length == signature.getParameters().length) { 61 for (int i = 0; i < _parameters.length; i++) { 62 if (!getParameters()[i].isCompatibleWith(signature.getParameters()[i])) { 63 result = false; 64 break; 65 } 66 } 67 } 68 else { 69 result = false; 70 } 71 72 return result; 73 } 74 75 public boolean isSame(ISignature signature) { 76 return java.util.Arrays.equals(_parameters, signature.getParameters()); 77 } 78 79 public IClass[] getParameters() { 80 return _parameters; 81 } 82 83 public String toString() { 84 StringBuffer result = new StringBuffer (); 85 result.append("("); 86 for (int i = 0; i < _parameters.length; i++) { 87 result.append(_parameters[i]); 88 if (i < _parameters.length - 1) { 89 result.append(", "); 90 } 91 } 92 result.append(")"); 93 94 return result.toString(); 95 } 96 97 } 98 | Popular Tags |