/** * Returns the complex type node contained by the given type. More precisely, * if the given <code>type</code> is a {@link ComplexType} this method * simply return it; if the given <code>type</code> is an {@link ArrayOf} of * a {@link PointerOf}, returns the complex type it contains; else, throws an * {@link IllegalArgumentException} * * @param type a {@link ComplexType} or a container of {@link ComplexType} * @return the complex type node contained by the given type. * @throws IllegalArgumentException if * <code>{@link #isComplexType(Type)}(type)</code> is * <code>false</code>. */ public static ComplexType getComplexType(final Type type) { if (type instanceof ComplexType) { return (ComplexType) type; } else if ((type instanceof ArrayOf) || (type instanceof PointerOf)) { return getComplexType(getContainedType((TypeContainer) type)); } else { throw new IllegalArgumentException( "The given type is not a complex type."); } }