当前位置: 首页>>代码示例>>Java>>正文


Java Annotations.getKey方法代码示例

本文整理汇总了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());
}
 
开发者ID:bootique,项目名称:bootique-jersey-client,代码行数:22,代码来源:ClientGuiceInjectInjector.java

示例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();
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:24,代码来源:AutomockAnnotatedMockModule.java

示例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()]));
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:38,代码来源:GuiceAwareInvokeStatement.java

示例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);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:Keys.java

示例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);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:Keys.java


注:本文中的com.google.inject.internal.Annotations.getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。