Parses string to content type. @param str string representation of content type. @return ContentType instance or ContentType#UNDEFINED, if there is no such content type.
(String str)
| 51 | * content type. |
| 52 | */ |
| 53 | public static ContentType of(String str) { |
| 54 | if (str == null) { |
| 55 | return UNDEFINED; |
| 56 | } |
| 57 | |
| 58 | val trimmed = str.trim(); |
| 59 | for (val type : values()) { |
| 60 | if (trimmed.startsWith(type.getHeader())) { |
| 61 | return type; |
| 62 | } |
| 63 | } |
| 64 | return UNDEFINED; |
| 65 | } |
| 66 | } |
no outgoing calls