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


Java TypeResolver.resolveRawArguments方法代码示例

本文整理汇总了Java中net.jodah.typetools.TypeResolver.resolveRawArguments方法的典型用法代码示例。如果您正苦于以下问题:Java TypeResolver.resolveRawArguments方法的具体用法?Java TypeResolver.resolveRawArguments怎么用?Java TypeResolver.resolveRawArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.jodah.typetools.TypeResolver的用法示例。


在下文中一共展示了TypeResolver.resolveRawArguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setInterfaceClass

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
/**
 * Extracts information about listClass, listMetaClass, listLinkClass from the provided document
 * interface.
 *
 * @param interfaceClass of the document
 * @return this builder
 */
@SuppressWarnings("unchecked")
public Builder<T> setInterfaceClass(Class<? extends ResourceRepositoryV2<T, ?>> interfaceClass) {

	try {
		Method findMethod = interfaceClass.getDeclaredMethod("findAll", QuerySpec.class);
		Class<?> returnType = findMethod.getReturnType();
		if (!ResourceListBase.class.isAssignableFrom(returnType)) {
			throw new IllegalStateException("findAll return type must extend " + ResourceListBase.class.getName());
		}
		setListClass((Class<? extends DefaultResourceList<T>>) returnType);

		Class<?>[] typeArgs = TypeResolver.resolveRawArguments(ResourceListBase.class, returnType);
		setListMetaClass((Class<? extends MetaInformation>) typeArgs[1]);
		setListLinksClass((Class<? extends LinksInformation>) typeArgs[2]);
		return this;
	} catch (NoSuchMethodException e) {
		throw new IllegalStateException("findAll method not overriden by " + interfaceClass.getName(), e);
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:27,代码来源:JpaRepositoryConfig.java

示例2: setInterfaceClass

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
/**
 * Extracts information about listClass, listMetaClass, listLinkClass from the provided repository
 * interface.
 * 
 * @param interfaceClass of the repository
 * @return this builder
 */
@SuppressWarnings("unchecked")
public Builder<T> setInterfaceClass(Class<? extends ResourceRepositoryV2<T, ?>> interfaceClass) {

	try {
		Method findMethod = interfaceClass.getDeclaredMethod("findAll", QuerySpec.class);
		Class<?> returnType = findMethod.getReturnType();
		if (!ResourceListBase.class.isAssignableFrom(returnType)) {
			throw new IllegalStateException("findAll return type must extend " + ResourceListBase.class.getName());
		}
      setListClass((Class<? extends DefaultResourceList<T>>) returnType);

		Class<?>[] typeArgs = TypeResolver.resolveRawArguments(ResourceListBase.class, returnType);
      setListMetaClass((Class<? extends MetaInformation>) typeArgs[1]);
      setListLinksClass((Class<? extends LinksInformation>) typeArgs[2]);
		return this;
	}
	catch (NoSuchMethodException e) {
		throw new IllegalStateException("findAll method not overriden by " + interfaceClass.getName(), e);
	}
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:28,代码来源:JpaRepositoryConfig.java

示例3: decode

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
@Override public <T> T decode(BitBuffer bitbuffer,
    Class<T> classOfT,
    Annotation[] extraAnnotations) {
AnnotationStore annotations = new AnnotationStore(classOfT.getAnnotations(),
        extraAnnotations);
UperEncoder.logger.debug("SEQUENCE OF for {}", classOfT);
FixedSize fixedSize = annotations.getAnnotation(FixedSize.class);
SizeRange sizeRange = annotations.getAnnotation(SizeRange.class);
long size =
  (fixedSize != null) ? fixedSize.value() :
      (sizeRange != null) ? UperEncoder.decodeConstrainedInt(bitbuffer, UperEncoder.intRangeFromSizeRange(sizeRange)) :
          UperEncoder.decodeLengthDeterminant(bitbuffer);
Collection<Object> coll = new ArrayList<Object>((int) size);
for (int i = 0; i < size; i++) {
    Class<?>[] typeArgs = TypeResolver.resolveRawArguments(List.class, classOfT);
    Class<?> classOfElements = typeArgs[0];
    if (classOfElements == Unknown.class) { throw new IllegalArgumentException(
            "Can't resolve type of elements for " + classOfT.getName()); }
    coll.add(UperEncoder.decode2(bitbuffer, classOfElements, new Annotation[] {}));
}
T result = UperEncoder.instantiate(classOfT, coll);
return result;        }
 
开发者ID:alexvoronov,项目名称:geonetworking,代码行数:23,代码来源:SeqOfCoder.java

示例4: getTargetResourceType

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
@Override
public String getTargetResourceType() {
	Class<?> repoClass = repositoryInstanceBuilder.getRepositoryClass();
	Class<?> repoInterface = RelationshipRepositoryV2.class.isAssignableFrom(repoClass) ? RelationshipRepositoryV2.class
			: RelationshipRepository.class;

	Class<?>[] typeArgs = TypeResolver
			.resolveRawArguments(repoInterface, repoClass);

	Class<?> typeArg = typeArgs[TARGET_TYPE_GENERIC_PARAMETER_IDX];
	Optional<JsonApiResource> annotation = ClassUtils.getAnnotation(typeArg, JsonApiResource.class);
	return annotation.get().type();
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:14,代码来源:DirectResponseRelationshipEntry.java

示例5: createTypesafeList

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
private Object createTypesafeList(Object result, Class<?> returnType) {
	DefaultResourceList defaultList = (DefaultResourceList) result;

	Class<?>[] typeArguments = TypeResolver.resolveRawArguments(ResourceListBase.class, returnType);
	Class<?> metaType = typeArguments[1];
	Class<?> linksType = typeArguments[2];

	ResourceListBase typedList = (ResourceListBase) ClassUtils.newInstance(returnType);
	typedList.addAll(defaultList);
	typedList.setMeta(defaultList.getMeta(metaType));
	typedList.setLinks(defaultList.getLinks(linksType));
	return typedList;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:15,代码来源:ClientStubInvocationHandler.java

示例6: getTargetAffiliation

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
@Override
public Class<?> getTargetAffiliation() {
	Class<?> repoClass = repositoryInstanceBuilder.getRepositoryClass();
	Class<?> repoInterface = RelationshipRepositoryV2.class.isAssignableFrom(repoClass) ? RelationshipRepositoryV2.class : RelationshipRepository.class; 
	
    Class<?>[] typeArgs = TypeResolver
        .resolveRawArguments(repoInterface, repoClass);
    
    return typeArgs[RelationshipRepository.TARGET_TYPE_GENERIC_PARAMETER_IDX];
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:11,代码来源:DirectResponseRelationshipEntry.java

示例7: createTypesafeList

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private Object createTypesafeList(Object result, Class<?> returnType) {
	DefaultResourceList defaultList = (DefaultResourceList) result;

	Class<?>[] typeArguments = TypeResolver.resolveRawArguments(ResourceListBase.class, returnType);
	Class<?> metaType = typeArguments[1];
	Class<?> linksType = typeArguments[2];

	ResourceListBase typedList = (ResourceListBase) ClassUtils.newInstance(returnType);
	typedList.addAll(defaultList);
	typedList.setMeta(defaultList.getMeta(metaType));
	typedList.setLinks(defaultList.getLinks(linksType));
	return typedList;
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:15,代码来源:ClientStubInvocationHandler.java

示例8: extractParameterClass

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
/**
 * @param parameterIndex
 * @return class if extracted properly, Unknown.class if it cannot be read
 */
public Class<?> extractParameterClass(int parameterIndex) {
    if (parameterIndex >= parameterCount || parameterIndex < 0) {
        throw new IllegalArgumentException("Invalid parameter index.");
    }
    return TypeResolver.resolveRawArguments(clazz, lambda.getClass())[parameterIndex];
}
 
开发者ID:Qubite,项目名称:tomoko,代码行数:11,代码来源:LambdaDescriptor.java

示例9: getRequestClass

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
public Class<?> getRequestClass(Class<?> usecaseClass) {
    Class<?>[] typeArgs = TypeResolver.resolveRawArguments(Usecase.class, usecaseClass);
    Class<?> requestClass = typeArgs[0];
    if (requestClass == TypeResolver.Unknown.class) {
        throw new UsecaseExecutorException("Could not resolve usecase request type for class '" + usecaseClass.getName() + "'. Hint: The concrete usecase class is required to resolve the request class.");
    }

    return requestClass;
}
 
开发者ID:casid,项目名称:jusecase,代码行数:10,代码来源:UsecaseRequestResolver.java

示例10: createRequest

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
@Before
public void createRequest() {
    try {
        Class<?> requestClass = TypeResolver.resolveRawArguments(UsecaseTest.class, getClass())[0];
        request = (Request) requestClass.newInstance();
    } catch (Exception e) {
        throw new RuntimeException("Failed to instantiate request. You need to override createRequest() and do it manually.", e);
    }
}
 
开发者ID:casid,项目名称:jusecase,代码行数:10,代码来源:UsecaseTest.java

示例11: ConsumerMessageListener

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
/**
 * Construct a MessageListener that wraps around a Java 8+ lambda to support quick and easy listener generation.
 * @param consumer Lambda logic to be run against the received message.
 */
@SuppressWarnings("unchecked")
public ConsumerMessageListener(Consumer<T> consumer) {
    Class typeArguments[] = TypeResolver.resolveRawArguments(Consumer.class, consumer.getClass());
    this.consumer = consumer;
    this.messageType = typeArguments[0];
}
 
开发者ID:reapzor,项目名称:FiloFirmata,代码行数:11,代码来源:ConsumerMessageListener.java

示例12: createRequest

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@BeforeEach
void createRequest() {
    try {
        Class<?> requestClass = TypeResolver.resolveRawArguments(UsecaseTest.class, getClass())[1];
        request = (Request) requestClass.newInstance();
    } catch (Exception e) {
        throw new RuntimeException("Failed to instantiate request. You need to override createRequest() and do it manually.", e);
    }
}
 
开发者ID:casid,项目名称:mazebert-ladder,代码行数:11,代码来源:UsecaseTest.java

示例13: Factory

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
/**
 * Creates a new factory with a constructor function that instantiates the factory object,
 * and with a processor that is capable of mutating the instantiated object after its initialization.
 *
 * A factory's processor may be modified to allow specific customization of instantiated objects before it is used.
 * @param id The identifier for this factory type
 * @param constructor The construction function
 * @param processor The processor function
 */
@SuppressWarnings("unchecked")
public Factory(String id, Supplier<T> constructor, Function<T, T> processor) {
	this.id = id;
	this.constructor = constructor;
	this.processor = processor;
	Class<?> type = TypeResolver.resolveRawArguments(Function.class, processor.getClass())[1];
	if (type == TypeResolver.Unknown.class || type == Identifiable.class) {
		type = TypeResolver.resolveRawArgument(Supplier.class, constructor.getClass());
	}
	this.type = (Class<? extends T>) type;
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:21,代码来源:Factory.java

示例14: resolveSimpleFunctionGenericTypes

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
static <O, A, F> FunctionGenericTypes<O, A> resolveSimpleFunctionGenericTypes(Class<?> subType) {
    Class<?>[] typeArgs = TypeResolver.resolveRawArguments(SimpleFunction.class, subType);

    validateSimpleFunctionGenericTypes(typeArgs, subType);

    @SuppressWarnings("unchecked") Class<O> objectType = (Class<O>) typeArgs[0];
    @SuppressWarnings("unchecked") Class<A> attributeType = (Class<A>) typeArgs[1];
    return new FunctionGenericTypes<O, A>(objectType, attributeType);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:10,代码来源:QueryFactory.java

示例15: resolveMultiValueFunctionGenericObjectType

import net.jodah.typetools.TypeResolver; //导入方法依赖的package包/类
static <O> Class<O> resolveMultiValueFunctionGenericObjectType(Class<?> subType) {
    Class<?>[] typeArgs = TypeResolver.resolveRawArguments(MultiValueFunction.class, subType);

    validateMultiValueFunctionGenericTypes(typeArgs, subType);

    @SuppressWarnings("unchecked") Class<O> objectType = (Class<O>) typeArgs[0];
    return objectType;
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:9,代码来源:QueryFactory.java


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