@Test public void testHasCompatibleMimeType() { List<String> mimeTypes = Arrays.asList("application/pdf", "text/plain"); assertTrue(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "application/pdf")); assertTrue(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "text/plain")); assertFalse(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "image/png")); assertFalse(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "text/html")); mimeTypes = Arrays.asList("video/*", "image/png"); assertTrue(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "video/mp4")); assertTrue(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "video/avi")); assertTrue(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "image/png")); assertFalse(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "image/jpeg")); assertFalse(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "image/bmp")); mimeTypes = Collections.singletonList("*"); assertTrue(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "video/mp4")); assertTrue(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "image/jpeg")); assertTrue(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "text/plain")); assertTrue(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "text/html")); assertTrue(mimeTypeTranslationHelper.hasCompatibleMimeType(mimeTypes, "application/pdf")); }
public boolean hasCompatibleMimeType(List<String> mimeTypes, String mimeType) { String mt = parseMimeType(mimeType); Set<String> expectedMimeTypes = new HashSet<>(); expectedMimeTypes.add(ANY_MIME_TYPE); if (mt != null) { expectedMimeTypes.add(mt); expectedMimeTypes.add(computeMimeTypeWithWildcardSubType(mt)); } return mimeTypes.stream().anyMatch(expectedMimeTypes::contains); }
MimeTypeTranslationHelper { public boolean hasCompatibleMimeType(List<String> mimeTypes, String mimeType) { String mt = parseMimeType(mimeType); Set<String> expectedMimeTypes = new HashSet<>(); expectedMimeTypes.add(ANY_MIME_TYPE); if (mt != null) { expectedMimeTypes.add(mt); expectedMimeTypes.add(computeMimeTypeWithWildcardSubType(mt)); } return mimeTypes.stream().anyMatch(expectedMimeTypes::contains); } }
MimeTypeTranslationHelper { public boolean hasCompatibleMimeType(List<String> mimeTypes, String mimeType) { String mt = parseMimeType(mimeType); Set<String> expectedMimeTypes = new HashSet<>(); expectedMimeTypes.add(ANY_MIME_TYPE); if (mt != null) { expectedMimeTypes.add(mt); expectedMimeTypes.add(computeMimeTypeWithWildcardSubType(mt)); } return mimeTypes.stream().anyMatch(expectedMimeTypes::contains); }  }
MimeTypeTranslationHelper { public boolean hasCompatibleMimeType(List<String> mimeTypes, String mimeType) { String mt = parseMimeType(mimeType); Set<String> expectedMimeTypes = new HashSet<>(); expectedMimeTypes.add(ANY_MIME_TYPE); if (mt != null) { expectedMimeTypes.add(mt); expectedMimeTypes.add(computeMimeTypeWithWildcardSubType(mt)); } return mimeTypes.stream().anyMatch(expectedMimeTypes::contains); }  void addConverter(ConverterDescriptor desc); String getConverterName(String sourceMimeType, String destinationMimeType); String getConverterName(String sourceMimeType, String destinationMimeType, boolean allowWildcard); boolean hasCompatibleMimeType(List<String> mimeTypes, String mimeType); List<String> getConverterNames(String sourceMimeType, String destinationMimeType); List<String> getConverterNames(String sourceMimeType, String destinationMimeType, boolean allowWildcard); @Deprecated List<String> getDestinationMimeTypes(String sourceMimeType); @Deprecated List<String> getSourceMimeTypes(String destinationMimeType); void clear(); }
MimeTypeTranslationHelper { public boolean hasCompatibleMimeType(List<String> mimeTypes, String mimeType) { String mt = parseMimeType(mimeType); Set<String> expectedMimeTypes = new HashSet<>(); expectedMimeTypes.add(ANY_MIME_TYPE); if (mt != null) { expectedMimeTypes.add(mt); expectedMimeTypes.add(computeMimeTypeWithWildcardSubType(mt)); } return mimeTypes.stream().anyMatch(expectedMimeTypes::contains); }  void addConverter(ConverterDescriptor desc); String getConverterName(String sourceMimeType, String destinationMimeType); String getConverterName(String sourceMimeType, String destinationMimeType, boolean allowWildcard); boolean hasCompatibleMimeType(List<String> mimeTypes, String mimeType); List<String> getConverterNames(String sourceMimeType, String destinationMimeType); List<String> getConverterNames(String sourceMimeType, String destinationMimeType, boolean allowWildcard); @Deprecated List<String> getDestinationMimeTypes(String sourceMimeType); @Deprecated List<String> getSourceMimeTypes(String destinationMimeType); void clear(); static final String ANY_MIME_TYPE; static final Pattern MIME_TYPE_PATTERN; }