Skip to content

Commit

Permalink
ROASTER-5: Added addParameter(JavaType, String) method
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Apr 7, 2014
1 parent f66b742 commit 1f98f72
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public interface MethodSource<O extends JavaSource<O>> extends Method<O, MethodS
*/
ParameterSource<O> addParameter(String type, String name);

/**
* Add a parameter with the specified {@link JavaType} type and name to this method
*/
ParameterSource<O> addParameter(JavaType<?> type, String name);

/**
* Remove a parameter from this method
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,12 @@ public ParameterSource<O> addParameter(Class<?> type, String name)
return addParameter(type.getName(), name);
}

@Override
public ParameterSource<O> addParameter(JavaType<?> type, String name)
{
return addParameter(type.getQualifiedName(), name);
}

@SuppressWarnings("unchecked")
@Override
public ParameterSource<O> addParameter(String type, String name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ public void testAddParameterStringType() throws Exception
Assert.assertEquals(3, method.getParameters().size());
}

@Test
public void testAddParameterJavaType() throws Exception
{
JavaClassSource type = Roaster.create(JavaClassSource.class).setName("Mock").setPackage("mock.pkg");
ParameterSource<JavaClassSource> param = method.addParameter(type, "mock");
Assert.assertNotNull(param);
Assert.assertEquals(3, method.getParameters().size());
Assert.assertTrue(method.getOrigin().hasImport(type));
}

@Test
public void testRemoveParameter() throws Exception
{
Expand Down

0 comments on commit 1f98f72

Please sign in to comment.