A Java library for searching anagrams in a dictionary with different implementations.
- Multiple dictionary search implementations:
SimpleDictionarySearch: Basic implementation for finding anagramsSimpleCachedDictionarySearch: Caches anagram search resultsPreloadedDictionarySearch: Preloads all anagrams for faster lookupsExpiringCacheDictionarySearch: Caches anagram search results with expiration
// Create a dictionary
List<String> dictionary = Arrays.asList("StEt", "tEts", "SETt", "etTS", "EstT");
// Create a dictionary search implementation
DictionarySearch search = new SimpleDictionarySearch(dictionary);
// Search for anagrams
List<String> anagrams = search.searchAll("test");
// Returns: ["StEt", "tEts", "SETt", "etTS", "EstT"]Basic implementation that searches for anagrams in the dictionary.
Caches anagram search results to improve performance for repeated searches.
Preloads all anagrams during initialization for instant lookups.
Caches anagram search results with a configurable expiration time.
The project includes comprehensive test coverage for all implementations:
- Base test class
DictionarySearchTestwith common test cases - Implementation-specific test classes extending the base test
- Additional tests for caching and expiration functionality
- JaCoCo test coverage reporting with minimum 80% line coverage requirement
mvn clean testThis will:
- Run all tests
- Generate a coverage report in
target/site/jacoco/ - Fail the build if line coverage is below 80%
src/
├── main/
│ └── java/
│ └── com/
│ └── example/
│ └── labs/
│ └── search/
│ ├── DictionarySearch.java
│ ├── DictionaryUtils.java
│ ├── ExpiringCacheDictionarySearch.java
│ ├── PreloadedDictionarySearch.java
│ ├── SimpleCachedDictionarySearch.java
│ └── SimpleDictionarySearch.java
└── test/
└── java/
└── com/
└── example/
└── labs/
└── search/
├── DictionarySearchTest.java
├── ExpiringCacheDictionarySearchTest.java
├── PreloadedDictionarySearchTest.java
├── SimpleCachedDictionarySearchTest.java
└── SimpleDictionarySearchTest.java
- Clone the repository:
git clone https://github.com/yourusername/dictionary-search-anagrams-java.git
cd dictionary-search-anagrams-java- Build the project:
mvn clean install- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project uses GitHub Actions for continuous integration and deployment. The workflow is defined in .github/workflows/maven.yml and includes:
-
Build and Test Process:
- Runs on every push to
mainand on pull requests - Sets up JDK 21 using Temurin distribution
- Builds the project using Maven
- Runs all tests with coverage reporting
- Runs on every push to
-
Code Coverage:
- Uses JaCoCo for test coverage reporting
- Generates coverage reports in
target/site/jacoco/ - Uploads coverage reports as workflow artifacts
- Fails the build if line coverage falls below 80%
-
Coverage Badges:
- Uses
cicirello/jacoco-badge-generatorto create dynamic coverage badges - Generates both line coverage and branch coverage badges
- Automatically updates badges after each build
- Stores badges in the
badgesdirectory
- Uses
To enable the automatic badge updates, you need to configure the following permissions:
- Go to your repository's Settings
- Navigate to Actions > General
- Under "Workflow permissions", select:
- "Read and write permissions"
- "Allow GitHub Actions to create and approve pull requests"
This configuration allows the workflow to:
- Commit and push updated coverage badges
- Create pull requests if needed
- Access repository contents for badge generation
After each build, you can find:
- Coverage reports in the workflow artifacts
- Updated coverage badges in the
badgesdirectory - Build status and coverage information in the README badges
This project is licensed under the MIT License - see the LICENSE.md file for details.