本文整理汇总了Java中com.google.inject.internal.Annotations.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java Annotations.getKey方法的具体用法?Java Annotations.getKey怎么用?Java Annotations.getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.inject.internal.Annotations
的用法示例。
在下文中一共展示了Annotations.getKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import com.google.inject.internal.Annotations; //导入方法依赖的package包/类
@Override
public Object resolve(Injectee injectee, ServiceHandle<?> serviceHandle) {
if (injectee.getRequiredType() instanceof Class) {
TypeLiteral<?> typeLiteral = TypeLiteral.get(injectee.getRequiredType());
Errors errors = new Errors(injectee.getParent());
Key<?> key;
try {
key = Annotations.getKey(typeLiteral, (Member) injectee.getParent(),
injectee.getParent().getDeclaredAnnotations(), errors);
} catch (ErrorsException e) {
errors.merge(e.getErrors());
throw new ConfigurationException(errors.getMessages());
}
return injector.getInstance(key);
}
throw new IllegalStateException("Can't process injection point: " + injectee.getRequiredType());
}
示例2: configure
import com.google.inject.internal.Annotations; //导入方法依赖的package包/类
@Override
protected void configure()
{
final Errors errors = new Errors(testClass);
for (FrameworkField field : fields)
{
try
{
final Field f = field.getField();
final Key key = Annotations.getKey(TypeLiteral.get(f.getGenericType()), f, field.getAnnotations(), errors);
bindMock(key, f.getType(), "Automock[" + field.getName() + "] " + key);
}
catch (ErrorsException e)
{
// Add it to the error list and hold them all until the end
errors.merge(e.getErrors());
}
}
errors.throwConfigurationExceptionIfErrorsExist();
}
示例3: evaluate
import com.google.inject.internal.Annotations; //导入方法依赖的package包/类
@Override
public void evaluate() throws Throwable
{
List<Object> params = new ArrayList<>();
if (method.getMethod().getParameterTypes().length > 0)
{
final Method m = method.getMethod();
final Errors errors = new Errors(m);
for (int paramIndex = 0; paramIndex < method.getMethod().getParameterTypes().length; paramIndex++)
{
final Annotation[] annotations = m.getParameterAnnotations()[paramIndex];
final TestEach annotation = TestEachUtils.getAnnotation(annotations, TestEach.class);
if (annotation != null)
{
// Value from a collection param
final Object param = getCollectionParamValue(errors, paramIndex, annotation);
params.add(param);
}
else
{
// Regular parameter
final TypeLiteral<?> type = TypeLiteral.get(m.getGenericParameterTypes()[paramIndex]);
final Key<?> key = Annotations.getKey(type, m, annotations, errors);
params.add(registry.getInjector().getInstance(key));
}
}
errors.throwCreationExceptionIfErrorsExist();
}
// Call the method
method.invokeExplosively(test, params.toArray(new Object[params.size()]));
}
示例4: fieldType
import com.google.inject.internal.Annotations; //导入方法依赖的package包/类
public static Key<?> fieldType(TypeLiteral<?> owner, Field field, Errors errors) throws ErrorsException {
return Annotations.getKey(owner.getFieldType(field), field, field.getAnnotations(), errors);
}
示例5: returnType
import com.google.inject.internal.Annotations; //导入方法依赖的package包/类
public static <T> Key<T> returnType(Invokable<?, T> method, Errors errors) throws ErrorsException {
return (Key<T>) Annotations.getKey(Types.toLiteral(method.getReturnType()), method, method.getAnnotations(), errors);
}