return newModelBuilder;
}
public static void enhanceResource(RuntimeResource resource, ResourceModel.Builder newModelBuilder,
List<Method> methods, boolean extended) {
final Resource firstResource = resource.getResources().get(0);
if (methodsSuitableForResource(firstResource, methods)) {
for (Method method : methods) {
final Set<MediaType> produces = Sets.newHashSet(method.produces);
for (ResourceMethod resourceMethod : resource.getResourceMethods()) {
for (final MediaType produce : method.produces) {
if (ModelProcessorUtil.isMethodOverridden(
resourceMethod,
method.httpMethod,
method.consumes.get(0),
produce)) {
produces.remove(produce);
}
}
}
if (!produces.isEmpty()) {
final Resource parentResource = resource.getParentResources().get(0);
if (parentResource != null && method.path != null) {
continue;
}
final Resource.Builder resourceBuilder = Resource.builder(firstResource.getPath());
final Resource.Builder builder = method.path != null
? resourceBuilder.addChildResource(method.path) : resourceBuilder;
final ResourceMethod.Builder methodBuilder = builder
.addMethod(method.httpMethod)
.consumes(method.consumes)
.produces(produces);
if (method.inflector != null) {
methodBuilder.handledBy(method.inflector);
} else {
methodBuilder.handledBy(method.inflectorClass);
}
methodBuilder.extended(extended);
final Resource newResource = resourceBuilder.build();
if (parentResource != null) {
final Resource.Builder parentBuilder = Resource.builder(parentResource.getPath());
parentBuilder.addChildResource(newResource);
newModelBuilder.addResource(parentBuilder.build());
} else {