Skip to content

Commit

Permalink
Stop implementing Function for DependencyVariableNamer and use a meth…
Browse files Browse the repository at this point in the history
…od reference instead.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171541381
  • Loading branch information
ronshapiro committed Oct 9, 2017
1 parent 4b5bcee commit 6d1e6ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions java/dagger/internal/codegen/DependencyVariableNamer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import com.google.common.base.Ascii;
import com.google.common.base.CaseFormat;
import com.google.common.base.Function;
import dagger.Lazy;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -36,11 +35,10 @@
* @since 2.0
*/
//TODO(gak): develop the heuristics to get better names
final class DependencyVariableNamer implements Function<DependencyRequest, String> {
final class DependencyVariableNamer {
private static final Pattern LAZY_PROVIDER_PATTERN = Pattern.compile("lazy(\\w+)Provider");

@Override
public String apply(DependencyRequest dependency) {
static String name(DependencyRequest dependency) {
if (dependency.overriddenVariableName().isPresent()) {
return dependency.overriddenVariableName().get();
}
Expand Down Expand Up @@ -83,7 +81,7 @@ public String apply(DependencyRequest dependency) {
}
}

private String toLowerCamel(String name) {
private static String toLowerCamel(String name) {
return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, name);
}
}
4 changes: 2 additions & 2 deletions java/dagger/internal/codegen/SourceFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
import static dagger.internal.codegen.TypeNames.SET_OF_PRODUCED_PRODUCER;
import static dagger.internal.codegen.TypeNames.SET_PRODUCER;
import static dagger.internal.codegen.Util.toImmutableList;
import static dagger.internal.codegen.Util.toImmutableSet;
import static java.util.Comparator.comparing;
import static javax.lang.model.SourceVersion.isName;

import com.google.common.base.CaseFormat;
import com.google.common.base.Joiner;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -126,7 +126,7 @@ static ImmutableMap<BindingKey, FrameworkField> generateBindingFieldsForDependen
private static String fieldNameForDependency(ImmutableSet<DependencyRequest> dependencyRequests) {
// collect together all of the names that we would want to call the provider
ImmutableSet<String> dependencyNames =
FluentIterable.from(dependencyRequests).transform(new DependencyVariableNamer()).toSet();
dependencyRequests.stream().map(DependencyVariableNamer::name).collect(toImmutableSet());

if (dependencyNames.size() == 1) {
// if there's only one name, great! use it!
Expand Down

0 comments on commit 6d1e6ac

Please sign in to comment.