-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45232 from geoand/mediatype-delegate
Avoid using the RuntimeDelegate indirection for MediaType
- Loading branch information
Showing
13 changed files
with
33 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import org.jboss.resteasy.reactive.common.headers.MediaTypeHeaderDelegate; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Bill Burke</a> | ||
*/ | ||
|
@@ -21,6 +23,14 @@ public class MediaTypeHelper { | |
public static final MediaTypeComparator QS_COMPARATOR = new MediaTypeComparator("qs"); | ||
private static final String MEDIA_TYPE_SUFFIX_DELIM = "+"; | ||
|
||
public static MediaType valueOf(String value) { | ||
return MediaTypeHeaderDelegate.INSTANCE.fromString(value); | ||
} | ||
|
||
public static String toString(MediaType mediaType) { | ||
return MediaTypeHeaderDelegate.INSTANCE.toString(mediaType); | ||
} | ||
|
||
private static float getQTypeWithParamInfo(MediaType type, String parameterName) { | ||
if (type.getParameters() != null) { | ||
String val = type.getParameters().get(parameterName); | ||
|
@@ -212,7 +222,7 @@ public static List<MediaType> parseHeader(String header) { | |
ArrayList<MediaType> types = new ArrayList<>(); | ||
String[] medias = header.split(","); | ||
for (String media : medias) { | ||
types.add(MediaType.valueOf(media.trim())); | ||
types.add(valueOf(media.trim())); | ||
} | ||
return types; | ||
} | ||
|
@@ -289,7 +299,7 @@ public static List<MediaType> toListOfMediaType(String[] mediaTypes) { | |
|
||
List<MediaType> list = new ArrayList<>(mediaTypes.length); | ||
for (String mediaType : mediaTypes) { | ||
list.add(MediaType.valueOf(mediaType)); | ||
list.add(valueOf(mediaType)); | ||
} | ||
|
||
return Collections.unmodifiableList(list); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters