本文整理汇总了Java中com.github.czyzby.kiwi.util.gdx.reflection.Annotations类的典型用法代码示例。如果您正苦于以下问题:Java Annotations类的具体用法?Java Annotations怎么用?Java Annotations使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Annotations类属于com.github.czyzby.kiwi.util.gdx.reflection包,在下文中一共展示了Annotations类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleLazyAssetInjection
import com.github.czyzby.kiwi.util.gdx.reflection.Annotations; //导入依赖的package包/类
private void handleLazyAssetInjection(final Object component, final Field field, final Asset assetData) {
if (Annotations.isNotVoid(assetData.lazyCollection())) {
handleLazyAssetCollectionInjection(component, field, assetData);
return;
} else if (assetData.value().length != 1) {
throw new GdxRuntimeException(
"Lazy wrapper can contain only one asset if lazy collection type is not provided. Found multiple assets in field: "
+ field + " of component: " + component);
}
final String assetPath = assetData.value()[0];
if (!assetData.loadOnDemand()) {
load(assetPath, assetData.type());
}
try {
Reflection.setFieldValue(field, component,
Lazy.providedBy(new AssetProvider(this, assetPath, assetData.type(), assetData.loadOnDemand())));
} catch (final ReflectionException exception) {
throw new GdxRuntimeException("Unable to inject lazy asset.", exception);
}
}
示例2: processField
import com.github.czyzby.kiwi.util.gdx.reflection.Annotations; //导入依赖的package包/类
@Override
public void processField(final Field field, final Inject annotation, final Object component, final Context context,
final ContextInitializer initializer, final ContextDestroyer contextDestroyer) {
if (Annotations.isNotVoid(annotation.lazy())) {
processLazyInjection(field, annotation, component, context);
} else {
processRegularInjection(field, annotation, component, context);
}
}
示例3: processRegularInjection
import com.github.czyzby.kiwi.util.gdx.reflection.Annotations; //导入依赖的package包/类
/** @param field will have its value injected.
* @param annotation used to determine dependency type.
* @param component owner of the field.
* @param context used to resolve dependencies. */
protected void processRegularInjection(final Field field, final Inject annotation, final Object component,
final Context context) {
final Class<?> dependencyClass = Annotations.isNotVoid(annotation.value()) ? annotation.value()
: field.getType();
setFieldValue(field, component, context.provide(dependencyClass));
}
示例4: convertToProviders
import com.github.czyzby.kiwi.util.gdx.reflection.Annotations; //导入依赖的package包/类
/** @param component is the owner of the methods.
* @param methods will be converted to dependency providers and added to context.
* @param context will contain the providers. Used to resolve methods' dependencies. */
protected void convertToProviders(final Object component, final Method[] methods, final Context context) {
for (final Method method : methods) {
final Class<?> returnType = method.getReturnType();
if (Annotations.isNotVoid(returnType)) { // Not null, void or Void.
context.addProvider(new ReflectionDependencyProvider(context, method, component));
}
}
}
示例5: getLmlInjectedValueType
import com.github.czyzby.kiwi.util.gdx.reflection.Annotations; //导入依赖的package包/类
protected Class<?> getLmlInjectedValueType(final Field field, final LmlInject injectionData) {
if (Annotations.isNotVoid(injectionData.value())) {
return injectionData.value();
}
return field.getType();
}