本文整理汇总了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);
}
}
示例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);
}
}
示例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; }
示例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();
}
示例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;
}
示例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];
}
示例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;
}
示例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];
}
示例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;
}
示例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);
}
}
示例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];
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}