Java Code Examples for org.codehaus.groovy.runtime.InvokerHelper#toString()
The following examples show how to use
org.codehaus.groovy.runtime.InvokerHelper#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VertexiumScript.java From vertexium with Apache License 2.0 | 5 votes |
public static String resultToString(Object obj) { if (obj instanceof Vertex) { return LazyVertex.toString((Vertex) obj); } if (obj instanceof Edge) { return LazyEdge.toString((Edge) obj); } if (obj instanceof Property) { return LazyProperty.toString((Property) obj, "property"); } if (obj instanceof VertexiumCypherResult) { return vertexiumCypherResultToString((VertexiumCypherResult) obj); } return InvokerHelper.toString(obj); }
Example 2
Source File: GroovyTestCase.java From groovy with Apache License 2.0 | 5 votes |
/** * Asserts that the arrays are equivalent and contain the same values * * @param expected * @param value */ protected void assertArrayEquals(Object[] expected, Object[] value) { String message = "expected array: " + InvokerHelper.toString(expected) + " value array: " + InvokerHelper.toString(value); assertNotNull(message + ": expected should not be null", expected); assertNotNull(message + ": value should not be null", value); assertEquals(message, expected.length, value.length); for (int i = 0, size = expected.length; i < size; i++) { assertEquals("value[" + i + "] when " + message, expected[i], value[i]); } }
Example 3
Source File: CachedConstructor.java From groovy with Apache License 2.0 | 5 votes |
private static GroovyRuntimeException createException(String init, Constructor constructor, Object[] argumentArray, Throwable e, boolean setReason) { return new GroovyRuntimeException( init + constructor + " with arguments: " + InvokerHelper.toString(argumentArray) + " reason: " + e, setReason ? e : null); }
Example 4
Source File: DefaultTypeTransformation.java From groovy with Apache License 2.0 | 5 votes |
public static Object castToType(Object object, Class type) { if (object == null) return null; if (type == Object.class) return object; final Class aClass = object.getClass(); if (type == aClass) return object; if (type.isAssignableFrom(aClass)) return object; if (ReflectionCache.isArray(type)) return asArray(object, type); if (type.isEnum()) { return ShortTypeHandling.castToEnum(object, type); } else if (Collection.class.isAssignableFrom(type)) { return continueCastOnCollection(object, type); } else if (type == String.class) { return InvokerHelper.toString(object); } else if (type == Character.class) { return ShortTypeHandling.castToChar(object); } else if (type == Boolean.class) { return castToBoolean(object); } else if (type == Class.class) { return ShortTypeHandling.castToClass(object); } else if (type.isPrimitive()) { return castToPrimitive(object, type); } return continueCastOnNumber(object, type); }
Example 5
Source File: MetaMethod.java From groovy with Apache License 2.0 | 5 votes |
/** * Checks that the given parameters are valid to call this method * * @param arguments the arguments to check * @throws IllegalArgumentException if the parameters are not valid */ public void checkParameters(Class[] arguments) { // lets check that the argument types are valid if (!isValidMethod(arguments)) { throw new IllegalArgumentException( "Parameters to method: " + getName() + " do not match types: " + InvokerHelper.toString(getParameterTypes()) + " for arguments: " + InvokerHelper.toString(arguments)); } }
Example 6
Source File: MetaMethod.java From groovy with Apache License 2.0 | 5 votes |
/** * Returns a string representation of this method */ public String toString() { return super.toString() + "[name: " + getName() + " params: " + InvokerHelper.toString(getParameterTypes()) + " returns: " + getReturnType() + " owner: " + getDeclaringClass() + "]"; }
Example 7
Source File: IncorrectClosureArgumentsException.java From groovy with Apache License 2.0 | 5 votes |
public IncorrectClosureArgumentsException(Closure closure, Object arguments, Class[] expected) { super( "Incorrect arguments to closure: " + closure + ". Expected: " + InvokerHelper.toString(expected) + ", actual: " + InvokerHelper.toString(arguments)); this.closure = closure; this.arguments = arguments; this.expected = expected; }
Example 8
Source File: ClosureExpression.java From groovy with Apache License 2.0 | 4 votes |
public String toString() { return super.toString() + InvokerHelper.toString(parameters) + "{ " + code + " }"; }