in jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/introspection/ClassIntrospector.java [125:211]
private static Stream<ResourceMethodInfoDTO> convert(
Set<ClassResourceInfo> visited,
String parentPath, String defaultHttpMethod,
List<MediaType> defaultConsumeTypes,
List<MediaType> defaultProduceTypes,
Set<String> defaultNameBindings, boolean recurse,
OperationResourceInfo operationResourceInfo) {
List<MediaType> consumeTypes = getConsumesInfo(
operationResourceInfo.getAnnotatedMethod());
if (consumeTypes == null) {
consumeTypes = defaultConsumeTypes;
}
List<MediaType> produceTypes = getProducesInfo(
operationResourceInfo.getAnnotatedMethod());
if (produceTypes == null) {
produceTypes = defaultProduceTypes;
}
String httpMethod = operationResourceInfo.getHttpMethod();
if (httpMethod == null) {
httpMethod = defaultHttpMethod;
}
Set<String> nameBindings = operationResourceInfo.getNameBindings();
if (nameBindings.isEmpty()) {
nameBindings = defaultNameBindings;
}
String path = parentPath +
operationResourceInfo.getURITemplate().getValue();
if (operationResourceInfo.isSubResourceLocator()) {
ClassResourceInfo classResourceInfo =
operationResourceInfo.getClassResourceInfo();
Class<?> returnType =
operationResourceInfo.getAnnotatedMethod().getReturnType();
ClassResourceInfo subResource = classResourceInfo.getSubResource(
returnType, returnType);
if (subResource != null) {
if (recurse) {
return convert(visited,
path, httpMethod, consumeTypes, produceTypes,
nameBindings, !visited.contains(subResource),
subResource);
}
else {
return Stream.empty();
}
}
}
ResourceMethodInfoDTO resourceMethodInfoDTO =
new ResourceMethodInfoDTO();
resourceMethodInfoDTO.consumingMimeType = consumeTypes == null ? null :
consumeTypes.stream().
map(
MediaType::toString
).toArray(
String[]::new
);
resourceMethodInfoDTO.producingMimeType = produceTypes == null ? null :
produceTypes.stream().
map(
MediaType::toString
).toArray(
String[]::new
);
resourceMethodInfoDTO.nameBindings = nameBindings == null ? null :
nameBindings.toArray(new String[0]);
resourceMethodInfoDTO.path = normalize(path);
resourceMethodInfoDTO.method = httpMethod;
return Stream.of(resourceMethodInfoDTO);
}