}
if (mms2.isEmpty()) {
return Util.getFirstKey(mms1);
}
for (final MediaType accMediaType : accMediaTypes) {
ResourceMethod bestResMethod = null;
for (final Map.Entry<ResourceMethod, List<MediaType>> mm : mms2
.entrySet()) {
for (final MediaType methodMediaType : mm.getValue()) {
if (accMediaType.includes(methodMediaType)) {
final ResourceMethod currentResMethod = mm.getKey();
if (bestResMethod == null) {
bestResMethod = currentResMethod;
} else {
if (requHttpMethod.equals(Method.HEAD)) {
// special handling for HEAD
final Method bestMethodHttp;
bestMethodHttp = bestResMethod.getHttpMethod();
if (bestMethodHttp.equals(Method.GET)
&& currentResMethod.getHttpMethod()
.equals(Method.HEAD)) {
// ignore HEAD method
} else if (bestMethodHttp.equals(Method.HEAD)
&& currentResMethod.getHttpMethod()
.equals(Method.GET)) {
bestResMethod = currentResMethod;
} else {
// use one of the methods, e.g. the first
}