Class ModelProcessorUtil
- java.lang.Object
-
- org.glassfish.jersey.server.model.internal.ModelProcessorUtil
-
public final class ModelProcessorUtil extends java.lang.Object
Helper class with methods supporting processing resource model bymodel processors
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ModelProcessorUtil.Method
Method bean containing basic information about enhancing resource method.
-
Constructor Summary
Constructors Modifier Constructor Description private
ModelProcessorUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
enhanceResource(RuntimeResource resource, ResourceModel.Builder enhancedModelBuilder, java.util.List<ModelProcessorUtil.Method> methods, boolean extended)
Enhance the runtime resource referenced byresource
parameter with a list of additional methods.static ResourceModel.Builder
enhanceResourceModel(ResourceModel resourceModel, boolean subResourceModel, java.util.List<ModelProcessorUtil.Method> methods, boolean extendedFlag)
EnhanceresourceModel
with a list of additional methods.static java.util.Set<java.lang.String>
getAllowedMethods(RuntimeResource resource)
Return allowed methods for the givenresource
.private static boolean
isMethodOverridden(ResourceMethod resourceMethod, java.lang.String httpMethod, javax.ws.rs.core.MediaType consumes, javax.ws.rs.core.MediaType produces)
private static boolean
methodsSuitableForResource(Resource resource, java.util.List<ModelProcessorUtil.Method> methods)
Determines whether the given methods can enhance the resource.private static boolean
overrides(java.util.List<javax.ws.rs.core.MediaType> mediaTypes, javax.ws.rs.core.MediaType mediaType)
private static boolean
overrides(javax.ws.rs.core.MediaType mt1, javax.ws.rs.core.MediaType mt2)
-
-
-
Method Detail
-
getAllowedMethods
public static java.util.Set<java.lang.String> getAllowedMethods(RuntimeResource resource)
Return allowed methods for the givenresource
. OPTIONS and HEAD are always returned in the result.- Parameters:
resource
- Resource for which resource methods should be found.- Returns:
- Set of resource methods that can be invoked on the given resource.
-
isMethodOverridden
private static boolean isMethodOverridden(ResourceMethod resourceMethod, java.lang.String httpMethod, javax.ws.rs.core.MediaType consumes, javax.ws.rs.core.MediaType produces)
-
overrides
private static boolean overrides(java.util.List<javax.ws.rs.core.MediaType> mediaTypes, javax.ws.rs.core.MediaType mediaType)
-
overrides
private static boolean overrides(javax.ws.rs.core.MediaType mt1, javax.ws.rs.core.MediaType mt2)
-
enhanceResourceModel
public static ResourceModel.Builder enhanceResourceModel(ResourceModel resourceModel, boolean subResourceModel, java.util.List<ModelProcessorUtil.Method> methods, boolean extendedFlag)
EnhanceresourceModel
with a list of additional methods. TheresourceModel
is traversed and for each available runtime resource URI in the modelmethods
are added. In case of method conflicts, the existing resource methods will be preserved and will not be 'overridden' by any new method from themethods
list. Overriding check takes into account media types of methods so that new resource methods with same HTTP method can be defined only for a more more specific media type.- Parameters:
resourceModel
- Resource model to be enhanced.subResourceModel
-true
if theresourceModel
to be enhanced is a sub resource model,false
if it is application resource model.methods
- List of enhancing methods.extendedFlag
- This flag will initialize the propertyResourceMethod.isExtended()
.- Returns:
- New resource model builder enhanced by
methods
.
-
enhanceResource
public static void enhanceResource(RuntimeResource resource, ResourceModel.Builder enhancedModelBuilder, java.util.List<ModelProcessorUtil.Method> methods, boolean extended)
Enhance the runtime resource referenced byresource
parameter with a list of additional methods. The newmethods
are added to the runtime resource. In case of method conflicts, the existing resource methods will be preserved and will not be 'overridden' by any new method from themethods
list. Overriding check takes into account media types of methods so that new resource methods with same HTTP method can be defined only for a more more specific media type.- Parameters:
resource
- Runtime resource to be enhanced.enhancedModelBuilder
- Builder for the enhanced resource model to be used.methods
- List of enhancing methods.extended
- This flag will initialize the propertyResourceMethod.isExtended()
.
-
methodsSuitableForResource
private static boolean methodsSuitableForResource(Resource resource, java.util.List<ModelProcessorUtil.Method> methods)
Determines whether the given methods can enhance the resource.- Parameters:
resource
- resource to add the methods to.methods
- methods to add.- Returns:
true
if methods can enhance the resource,false
otherwise.
-
-