Skip to content

Commit

Permalink
Fixes from pull request review in square#373.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgruber committed Jan 10, 2014
1 parent 89c834a commit 1ac981c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import java.io.IOException;
import java.util.Comparator;
import java.util.HashSet;
import java.util.TreeSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -125,7 +125,7 @@ String shortName(String key) {
return result.toString();
}

/** A Comparator for BindingsGroup so we can insure a consistent ordering of output. */
/** A Comparator for Bindings so we can insure a consistent ordering of output. */
private static class BindingComparator implements Comparator<Binding<?>> {
@Override
public int compare(Binding<?> left, Binding<?> right) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/dagger/internal/BindingsGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package dagger.internal;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
Expand All @@ -26,7 +26,7 @@
* the initial set of bindings for a graph (from provides methods).
*/
public abstract class BindingsGroup {
private final Map<String, Binding<?>> bindings = new HashMap<String, Binding<?>>();
private final Map<String, Binding<?>> bindings = new LinkedHashMap<String, Binding<?>>();

public abstract Binding<?> contributeSetBinding(String key, SetBinding<?> value);

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/dagger/internal/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* qualified by the annotation.
* <li>{@code members/com.square.Foo}: injects members of Foo.
* </ol>
* BindingsGroup from {@code @Provides} methods are of the first two types. BindingsGroup
* Bindings from {@code @Provides} methods are of the first two types. BindingsGroup
* created from {@code @Inject}-annotated members of a class are of the first
* and last types.
*/
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/dagger/internal/Linker.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class Linker {
*/
private final Linker base;

/** BindingsGroup requiring a call to attach(). May contain deferred bindings. */
/** Bindings requiring a call to attach(). May contain deferred bindings. */
private final Queue<Binding<?>> toLink = new LinkedList<Binding<?>>();

/** True unless calls to requestBinding() were unable to satisfy the binding. */
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/java/dagger/internal/SetBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public int size() {
@Override public Set<T> get() {
List<T> result = new ArrayList<T>();
for (SetBinding<T> setBinding = this; setBinding != null; setBinding = setBinding.parent) {
for (Binding<?> contributor : setBinding.contributors) {
for (int i = 0, size = setBinding.contributors.size(); i < size; i++) {
Binding<?> contributor = setBinding.contributors.get(i);
Object contribution = contributor.get(); // Let runtime exceptions through.
if (contributor.provideKey.equals(provideKey)) {
result.addAll((Set<T>) contribution);
Expand All @@ -130,11 +131,11 @@ public int size() {
boolean first = true;
StringBuilder builder = new StringBuilder("SetBinding[");
for (SetBinding<T> setBinding = this; setBinding != null; setBinding = setBinding.parent) {
for (Binding<?> contributor : setBinding.contributors) {
for (int i = 0, size = setBinding.contributors.size(); i < size; i++) {
if (!first) {
builder.append(",");
}
builder.append(contributor);
builder.append(setBinding.contributors.get(i));
first = false;
}
}
Expand Down

0 comments on commit 1ac981c

Please sign in to comment.