View Javadoc

1   package org.springframework.roo.shell;
2   
3   import java.lang.reflect.Method;
4   
5   import org.springframework.roo.support.style.ToStringCreator;
6   import org.springframework.roo.support.util.Assert;
7   import org.springframework.roo.support.util.StringUtils;
8   
9   public class ParseResult {
10  	private Method method;
11  	private Object instance;
12  	private Object[] arguments; // may be null if no arguments needed
13  	
14  	public ParseResult(Method method, Object instance, Object[] arguments) {
15  		Assert.notNull(method, "Method required");
16  		Assert.notNull(instance, "Instance required");
17  		int length = arguments == null ? 0 : arguments.length;
18  		Assert.isTrue(method.getParameterTypes().length == length, "Required " + method.getParameterTypes().length + " arguments, but received " + length);
19  		this.method = method;
20  		this.instance = instance;
21  		this.arguments = arguments;
22  	}
23  
24  	public Method getMethod() {
25  		return method;
26  	}
27  
28  	public Object getInstance() {
29  		return instance;
30  	}
31  
32  	public Object[] getArguments() {
33  		return arguments;
34  	}
35  	
36  	@Override
37  	public String toString() {
38  		ToStringCreator tsc = new ToStringCreator(this);
39  		tsc.append("method", method);
40  		tsc.append("instance", instance);
41  		tsc.append("arguments", StringUtils.arrayToCommaDelimitedString(arguments));
42  		return tsc.toString();
43  	}
44  
45  }