Skip to content

Commit

Permalink
Rename ConstructorClassMatcher.withParameters(Iterable<Supplier<Type>…
Browse files Browse the repository at this point in the history
…>) to withParametersOfType(Iterable<Supplier<Type>>)

Add ConstructorClassMatcher.withParameters(Iterable<String>)

RELNOTES: rename ConstructorClassMatcher methods.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192515750
  • Loading branch information
kluever authored and eaftan committed Apr 12, 2018
1 parent bea4b1a commit 3df11b7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Expand Up @@ -50,11 +50,16 @@ public ConstructorClassMatcherImpl(ConstructorMatcherImpl baseMatcher, TypePredi

@Override
public ParameterMatcher withParameters(String... parameters) {
return withParameters(Suppliers.fromStrings(Arrays.asList(parameters)));
return withParameters(Arrays.asList(parameters));
}

@Override
public ParameterMatcher withParameters(Iterable<Supplier<Type>> parameters) {
public ParameterMatcher withParameters(Iterable<String> parameters) {
return withParametersOfType(Suppliers.fromStrings(parameters));
}

@Override
public ParameterMatcher withParametersOfType(Iterable<Supplier<Type>> parameters) {
return new ParameterMatcherImpl(this, ImmutableList.copyOf(parameters));
}
}
Expand Up @@ -127,7 +127,10 @@ public interface ConstructorClassMatcher extends Matcher<ExpressionTree> {
ParameterMatcher withParameters(String... parameters);

/** Match constructors whose formal parameters have the given types. */
ParameterMatcher withParameters(Iterable<Supplier<Type>> parameters);
ParameterMatcher withParameters(Iterable<String> parameters);

/** Match constructors whose formal parameters have the given types. */
ParameterMatcher withParametersOfType(Iterable<Supplier<Type>> parameters);
}

public interface ParameterMatcher extends Matcher<ExpressionTree> {}
Expand Down
Expand Up @@ -137,20 +137,20 @@ String replacement() {
anyOf(
constructor()
.forClass(String.class.getName())
.withParameters(ImmutableList.of(Suppliers.arrayOf(Suppliers.BYTE_TYPE))),
.withParametersOfType(ImmutableList.of(Suppliers.arrayOf(Suppliers.BYTE_TYPE))),
constructor()
.forClass(String.class.getName())
.withParameters(
.withParametersOfType(
ImmutableList.of(
Suppliers.arrayOf(Suppliers.BYTE_TYPE),
Suppliers.INT_TYPE,
Suppliers.INT_TYPE)),
constructor()
.forClass(OutputStreamWriter.class.getName())
.withParameters(ImmutableList.of(Suppliers.typeFromClass(OutputStream.class))),
.withParametersOfType(ImmutableList.of(Suppliers.typeFromClass(OutputStream.class))),
constructor()
.forClass(InputStreamReader.class.getName())
.withParameters(ImmutableList.of(Suppliers.typeFromClass(InputStream.class))));
.withParametersOfType(ImmutableList.of(Suppliers.typeFromClass(InputStream.class))));

private static final Matcher<ExpressionTree> BYTESTRING_COPY_FROM =
staticMethod().onClass("com.google.protobuf.ByteString").named("copyFrom");
Expand Down

0 comments on commit 3df11b7

Please sign in to comment.