Skip to content

How to create method: public <T> List<T> apiGet(String url, Class<T> clazz) #250

@rob-stoecklein

Description

@rob-stoecklein

Hello,

We're trying to create the following method:

public <T> List<T> apiGet(String url, Class<T> clazz)

but am unable to generate the first "" marker. Is this possible?

Here's the code I'm using:

    public static void main(final String[] args) {

        final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);
        javaClass.setName("TestClass");

        final MethodSource<?> methodSource = javaClass.addMethod();
        methodSource.setName("apiGet").setPublic().setBody("return null;");
        methodSource.addParameter("String", "url");
        methodSource.addParameter("Class<T>", "clazz");
        methodSource.setReturnType("List<T>");
        //methodSource.setReturnType("<T> List<T>");  // does not work: throws StringIndexOutOfBoundsException

        log.info("\n\n" + javaClass.toString() + "\n");
    }

Thanks for any help you can offer!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions