-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b10d6a
commit 7061581
Showing
11 changed files
with
214 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
compiler/src/main/java/io/jbock/simple/processor/step/BindingRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.jbock.simple.processor.step; | ||
|
||
import io.jbock.simple.Inject; | ||
import io.jbock.simple.processor.binding.Key; | ||
import io.jbock.simple.processor.binding.KeyFactory; | ||
import io.jbock.simple.processor.util.ValidationFailure; | ||
|
||
import javax.lang.model.element.Element; | ||
import javax.lang.model.element.ExecutableElement; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class BindingRegistry { | ||
|
||
private final Map<Key, Element> bindings = new HashMap<>(); | ||
private final KeyFactory keyFactory; | ||
|
||
@Inject | ||
public BindingRegistry(KeyFactory keyFactory) { | ||
this.keyFactory = keyFactory; | ||
} | ||
|
||
void register(ExecutableElement method) { | ||
Key key = keyFactory.getKey(method); | ||
Element previous = bindings.put(key, method); | ||
if (previous != null && !previous.equals(method)) { | ||
throw new ValidationFailure("Duplicate binding for " + key, method); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.