Extract MIME-type mapping data into dedicated WellKnownMimeTypes class - #3399
Open
ChneYangOLP wants to merge 1 commit into
Open
Extract MIME-type mapping data into dedicated WellKnownMimeTypes class#3399ChneYangOLP wants to merge 1 commit into
ChneYangOLP wants to merge 1 commit into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WellKnownFileExtensionsUtils.java contained ~1,312 lines of static m.put(...) data (ported from tika-core 2.9.1) mixed with ~70 lines of actual business logic, totaling 1,383 lines. This made the file difficult to read and maintain.
This PR extracts the pure extension-to-MIME-type mapping data into a new dedicated class WellKnownMimeTypes, reducing WellKnownFileExtensionsUtils from 1,383 lines to 67 lines.
Changes:
New file: WellKnownMimeTypes.java — a package-private data class holding the static Map<String, String> EXT_TO_MIME_TYPE with all ~1,312 m.put(...) entries.
Rewritten: WellKnownFileExtensionsUtils.java — now delegates EXT_TO_MIME_TYPE to WellKnownMimeTypes and builds MIME_TYPE_TO_EXT by inverting it. Introduced ALLURE_HTTP_EXCHANGE and OCTET_STREAM constants to eliminate magic strings. Removed the no-longer-needed @SuppressWarnings("MultipleStringLiterals") annotation.
All public API (EXT_TO_MIME_TYPE, MIME_TYPE_TO_EXT, lookup(), getExtensionByMimeType()) remains unchanged. No caller modifications required (DefaultResultsVisitor, Allure1Plugin, Allure2Plugin, WellKnownFileExtensionsUtilsTest all compile and work as before).
Verified with: ./gradlew :allure-generator:compileJava :allure-generator:compileTestJava — BUILD SUCCESSFUL
Checklist
Sign Allure CLA
Provide unit tests