本文整理匯總了Java中com.google.inject.Key.ofType方法的典型用法代碼示例。如果您正苦於以下問題:Java Key.ofType方法的具體用法?Java Key.ofType怎麽用?Java Key.ofType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.inject.Key
的用法示例。
在下文中一共展示了Key.ofType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: InnerFactoryManifest
import com.google.inject.Key; //導入方法依賴的package包/類
public InnerFactoryManifest(Key<I> innerKey, TypeLiteral<O> outerType) {
if(innerKey == null) {
innerKey = Key.get(new ResolvableType<I>(){}.in(getClass()));
}
this.innerType = innerKey.getTypeLiteral();
this.outerType = outerType != null ? outerType : new ResolvableType<O>(){}.in(getClass());
this.factoryKey = innerKey.ofType(new ResolvableType<InnerFactory<O, I>>(){}
.with(new TypeArgument<O>(this.outerType){},
new TypeArgument<I>(this.innerType){}));
}
示例2: analyzeDependencies
import com.google.inject.Key; //導入方法依賴的package包/類
private void analyzeDependencies(final Collection<Dependency<?>> dependencies)
{
for( final Dependency<?> d : dependencies )
{
final Key<?> key = d.getKey();
InjectionPoint injectionPoint = d.getInjectionPoint();
if( injectionPoint != null && injectionPoint.isOptional() )
{
continue;
}
if( key.getAnnotationType() == Assisted.class )
{
continue;
}
TypeLiteral<?> typeLiteral = key.getTypeLiteral();
Class<?> rawType = typeLiteral.getRawType();
if( rawType == Injector.class )
{
continue;
}
if( rawType == MembersInjector.class )
{
Key<?> injectedKey = key
.ofType(((ParameterizedType) typeLiteral.getType()).getActualTypeArguments()[0]);
dependentKeys.add(injectedKey);
analyzeImplementation(injectedKey.getTypeLiteral(), true);
}
else if( rawType == Provider.class )
{
dependentKeys.add(key.ofType(((ParameterizedType) typeLiteral.getType()).getActualTypeArguments()[0]));
}
else
{
dependentKeys.add(key);
}
}
}
示例3: bindPrimitiveParser
import com.google.inject.Key; //導入方法依賴的package包/類
default <T> LinkedBindingBuilder<PrimitiveParser<T>> bindPrimitiveParser(Key<T> key) {
final Key<PrimitiveParser<T>> parserKey = key.ofType(PrimitiveParser.typeOf(key.getTypeLiteral()));
bindParser(key).to(parserKey);
return bind(parserKey);
}
示例4: bindElementParser
import com.google.inject.Key; //導入方法依賴的package包/類
default <T> LinkedBindingBuilder<ElementParser<T>> bindElementParser(Key<T> key) {
final Key<ElementParser<T>> parserKey = key.ofType(new ResolvableType<ElementParser<T>>(){}.with(new TypeArgument<T>(key.getTypeLiteral()){}));
bindParser(key).to(parserKey);
return bind(parserKey);
}