本文整理了Java中com.google.inject.spi.Element
类的一些代码示例,展示了Element
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element
类的具体详情如下:
包路径:com.google.inject.spi.Element
类名称:Element
[英]A core component of a module or injector.
The elements of a module can be inspected, validated and rewritten. Use Elements#getElements(com.google.inject.Module[]) to read the elements from a module, and Elements#getModule(Iterable) to rewrite them. This can be used for static analysis and generation of Guice modules.
The elements of an injector can be inspected and exercised. Use com.google.inject.Injector#getBindings to reflect on Guice injectors.
[中]模块或注入器的核心部件。
可以检查、验证和重写模块的元素。使用Elements#getElements(com.google.inject.Module[])从模块中读取元素,使用Elements#getModule(Iterable)重写它们。这可以用于静态分析和Guice模块的生成。
可以检查和使用喷油器的元件。使用com。谷歌。注射注射器#获取绑定以反映Guice注射器。
代码示例来源:origin: com.google.inject/guice
void writeAll(Iterable<? extends Element> elements) {
for (Element element : elements) {
element.acceptVisitor(this);
}
}
}
代码示例来源:origin: com.google.inject/guice
@Override
public void configure(Binder binder) {
for (Element element : elements) {
element.applyTo(binder);
}
}
}
代码示例来源:origin: com.google.inject/guice
public void process(InjectorImpl injector, List<Element> elements) {
Errors errorsAnyElement = this.errors;
this.injector = injector;
try {
for (Iterator<Element> i = elements.iterator(); i.hasNext(); ) {
Element element = i.next();
this.errors = errorsAnyElement.withSource(element.getSource());
Boolean allDone = element.acceptVisitor(this);
if (allDone) {
i.remove();
}
}
} finally {
this.errors = errorsAnyElement;
this.injector = null;
}
}
代码示例来源:origin: org.atteo.moonshine/container
element.applyTo(binder);
element.acceptVisitor(new DefaultElementVisitor<Void>() {
private <T> void bindKey(Key<T> key) {
Key<T> sourceKey;
代码示例来源:origin: com.netflix.governator/governator-core
/**
* @param elements List of elements
* @return List all Module classes that were involved in setting up bindings for the list of Elements
*/
public static List<String> getAllSourceModules(List<Element> elements) {
List<String> names = new ArrayList<>();
for (Element element : elements) {
if (element.getSource().getClass().isAssignableFrom(ElementSource.class)) {
ElementSource source = (ElementSource)element.getSource();
names.addAll(source.getModuleClassNames());
}
}
return names;
}
代码示例来源:origin: io.github.gwtplus.gin/gin
/**
* Create a {@code Context} storing the context of the given Guice
* {@link Element}.
*/
public static Context forElement(Element element) {
return new Context("%s", element.getSource());
}
代码示例来源:origin: com.google.inject/guice
private static Module extractScanners(Iterable<Element> elements) {
final List<ModuleAnnotatedMethodScannerBinding> scanners = Lists.newArrayList();
ElementVisitor<Void> visitor =
new DefaultElementVisitor<Void>() {
@Override
public Void visit(ModuleAnnotatedMethodScannerBinding binding) {
scanners.add(binding);
return null;
}
};
for (Element element : elements) {
element.acceptVisitor(visitor);
}
return new AbstractModule() {
@Override
protected void configure() {
for (ModuleAnnotatedMethodScannerBinding scanner : scanners) {
scanner.applyTo(binder());
}
}
};
}
}
代码示例来源:origin: com.google/inject
public void process(InjectorImpl injector, List<Element> elements) {
Errors errorsAnyElement = this.errors;
this.injector = injector;
try {
for (Iterator<Element> i = elements.iterator(); i.hasNext(); ) {
Element element = i.next();
this.errors = errorsAnyElement.withSource(element.getSource());
Boolean allDone = element.acceptVisitor(this);
if (allDone) {
i.remove();
}
}
} finally {
this.errors = errorsAnyElement;
this.injector = null;
}
}
代码示例来源:origin: com.google.inject/guice
@Override
protected Void visitOther(Element element) {
element.applyTo(binder);
return null;
}
代码示例来源:origin: com.netflix.governator/governator-core
@Override
protected String visitOther(Element element) {
Object source = element.getSource();
ElementSource elementSource = null;
while (source instanceof ElementSource) {
elementSource = (ElementSource)source;
source = elementSource.getOriginalElementSource();
}
if (elementSource != null) {
return elementSource.getModuleClassNames().toString();
}
return null;
}
}
代码示例来源:origin: org.sonatype.sisu/sisu-guice
void writeAll(Iterable<? extends Element> elements) {
for (Element element : elements) {
element.acceptVisitor(this);
}
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.inject
public void process(InjectorImpl injector, List<Element> elements) {
Errors errorsAnyElement = this.errors;
this.injector = injector;
try {
for (Iterator<Element> i = elements.iterator(); i.hasNext(); ) {
Element element = i.next();
this.errors = errorsAnyElement.withSource(element.getSource());
Boolean allDone = element.acceptVisitor(this);
if (allDone) {
i.remove();
}
}
} finally {
this.errors = errorsAnyElement;
this.injector = null;
}
}
代码示例来源:origin: com.google.inject/guice
@Override
public void applyTo(Binder binder) {
PrivateBinder privateBinder = binder.withSource(source).newPrivateBinder();
for (Element element : getElements()) {
element.applyTo(privateBinder);
}
getExposedKeys(); // ensure exposedKeysToSources is populated
for (Map.Entry<Key<?>, Object> entry : exposedKeysToSources.entrySet()) {
privateBinder.withSource(entry.getValue()).expose(entry.getKey());
}
}
代码示例来源:origin: io.github.gwtplus.gin/gin
protected Void visitOther(Element element) {
visit(new Message(element.getSource(), "Ignoring unsupported Module element: " + element));
return null;
}
代码示例来源:origin: ArcBees/Jukito
private void visitElements(List<Element> elements) {
for (Element element : elements) {
element.acceptVisitor(this);
}
}
代码示例来源:origin: Nextdoor/bender
public void process(InjectorImpl injector, List<Element> elements) {
Errors errorsAnyElement = this.errors;
this.injector = injector;
try {
for (Iterator<Element> i = elements.iterator(); i.hasNext(); ) {
Element element = i.next();
this.errors = errorsAnyElement.withSource(element.getSource());
Boolean allDone = element.acceptVisitor(this);
if (allDone) {
i.remove();
}
}
} finally {
this.errors = errorsAnyElement;
this.injector = null;
}
}
代码示例来源:origin: com.google.inject/guice
void rewrite(Binder binder, PrivateElements privateElements, Set<Key<?>> keysToSkip) {
PrivateBinder privateBinder =
binder.withSource(privateElements.getSource()).newPrivateBinder();
Set<Key<?>> skippedExposes = Sets.newHashSet();
for (Key<?> key : privateElements.getExposedKeys()) {
if (keysToSkip.remove(key)) {
skippedExposes.add(key);
} else {
privateBinder.withSource(privateElements.getExposedSource(key)).expose(key);
}
}
for (Element element : privateElements.getElements()) {
if (element instanceof Binding && skippedExposes.remove(((Binding) element).getKey())) {
continue;
}
if (element instanceof PrivateElements) {
rewrite(privateBinder, (PrivateElements) element, skippedExposes);
continue;
}
element.applyTo(privateBinder);
}
}
代码示例来源:origin: org.atteo.moonshine/container
private <T> void bindKey(Key<T> key) {
Key<T> sourceKey;
Class<? extends Annotation> annotation = dependency.getAnnotation();
if (annotation == ImportService.NoAnnotation.class) {
sourceKey = Key.get(key.getTypeLiteral());
} else {
sourceKey = Key.get(key.getTypeLiteral(), annotation);
}
if (!sourceKey.equals(key)) {
binder.withSource(element.getSource()).bind(sourceKey).to(key);
}
}
代码示例来源:origin: org.jukito/jukito
private void visitElements(List<Element> elements) {
for (Element element : elements) {
element.acceptVisitor(this);
}
}
代码示例来源:origin: org.sonatype.sisu/sisu-guice
public void process(InjectorImpl injector, List<Element> elements) {
Errors errorsAnyElement = this.errors;
this.injector = injector;
try {
for (Iterator<Element> i = elements.iterator(); i.hasNext(); ) {
Element element = i.next();
this.errors = errorsAnyElement.withSource(element.getSource());
Boolean allDone = element.acceptVisitor(this);
if (allDone) {
i.remove();
}
}
} finally {
this.errors = errorsAnyElement;
this.injector = null;
}
}
内容来源于网络,如有侵权,请联系作者删除!