com.google.inject.Binding.applyTo()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中com.google.inject.Binding.applyTo()方法的一些代码示例,展示了Binding.applyTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.applyTo()方法的具体详情如下:
包路径:com.google.inject.Binding
类名称:Binding
方法名:applyTo

Binding.applyTo介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.junit4

@Override
  public void configure(Binder binder) {
    for(Binding<?> binding: bindings.values()) {
      Type typeLiteral = binding.getKey().getTypeLiteral().getType();
      if (!Injector.class.equals(typeLiteral) && !Logger.class.equals(typeLiteral)) {
        binding.applyTo(binder);
      }
    }
  }
}).with(new Module() {

代码示例来源:origin: com.atlassian.org.eclipse.sisu/org.eclipse.sisu.inject

@Override
public <T> Void visit( final Binding<T> binding )
{
  final Key<T> key = binding.getKey();
  if ( !localKeys.contains( key ) )
  {
    if ( binding.acceptTargetVisitor( verifier ).booleanValue() )
    {
      localKeys.add( key );
      binding.applyTo( binder );
    }
    else
    {
      Logs.debug( "Discard binding: {}", binding, null );
    }
  }
  return null;
}

代码示例来源:origin: com.atlassian.org.eclipse.sisu/org.eclipse.sisu.inject

@Override
public <T> Void visit( final Binding<T> binding )
{
  final Key<T> key = binding.getKey();
  if ( !localKeys.contains( key ) )
  {
    if ( Parameters.class == key.getAnnotationType() )
    {
      mergeParameters( binding );
    }
    else if ( binding.acceptTargetVisitor( analyzer ).booleanValue() )
    {
      localKeys.add( key );
      binding.applyTo( binder );
    }
    else
    {
      Logs.debug( "Discard binding: {}", binding, null );
    }
  }
  return null;
}

代码示例来源:origin: io.sarl.lang/io.sarl.lang

/** Create an injector that override the given injectors with the modules.
 *
 * @param originalInjector the original injector.
 * @param modules the overriding modules.
 * @return the new injector.
 */
public static Injector createOverridingInjector(Injector originalInjector, com.google.inject.Module module) {
  final Map<Key<?>, Binding<?>> bindings = originalInjector.getBindings();
  return Guice.createInjector(Modules2.mixin((binder) -> {
    for(Binding<?> binding: bindings.values()) {
      final Type typeLiteral = binding.getKey().getTypeLiteral().getType();
      if (typeLiteral != null) {
        final String typeName = typeLiteral.getTypeName();
        if (isValid(typeName)) {
          binding.applyTo(binder);
        }
      }
    }
  }, module));
}

相关文章