Skip to content

Commit

Permalink
Add method withCache()
Browse files Browse the repository at this point in the history
  • Loading branch information
alaugks committed Apr 26, 2024
1 parent fb80a11 commit 4d69d77
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,18 @@ private XliffTranslationMessageSource(Builder builder) {
);
}

public static Builder builder(Cache cacheManager) {
return new Builder(cacheManager);
public static Builder builder() {
return new Builder();
}

public static final class Builder {

private final Cache cache;
private Cache cache;
private Locale defaultLocale;
private final Set<String> basenames = new HashSet<>();
private String defaultDomain = "messages";
private List<XliffIdentifierInterface> transUnitIdentifier;

private Builder(Cache cache) {
this.cache = cache;
}

public Builder defaultLocale(Locale locale) {
this.defaultLocale = locale;
return this;
Expand Down Expand Up @@ -87,6 +83,11 @@ public Builder defaultDomain(String defaultDomain) {
return this;
}

public Builder withCache(Cache cache) {
this.cache = cache;
return this;
}

public Builder setTransUnitIdentifier(List<XliffIdentifierInterface> transUnitIdentifier) {
this.transUnitIdentifier = transUnitIdentifier;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class XliffTranslationMessageSourceCasesTest {

XliffTranslationMessageSourceCasesTest() {
this.messageSourceExample = XliffTranslationMessageSource
.builder(TestUtilities.getCache())
.builder()
.basenamePattern("translations_example/*")
.defaultLocale(Locale.forLanguageTag("en"))
.build();
Expand All @@ -25,7 +25,7 @@ class XliffTranslationMessageSourceCasesTest {
@Test
void test_setDefaultDomain() {
var messageSource = XliffTranslationMessageSource
.builder(TestUtilities.getCache())
.builder()
.basenamePattern("translations/*")
.defaultLocale(Locale.forLanguageTag("en"))
.defaultDomain("otherdomain")
Expand All @@ -41,7 +41,7 @@ void test_setDefaultDomain() {
@Test
void test_setBasenamesPattern() {
var messageSource = XliffTranslationMessageSource
.builder(TestUtilities.getCache())
.builder()
.basenamesPattern(
List.of(
"translations_en/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class XliffTranslationMessageSourceTest {
@BeforeAll
static void beforeAll() {
messageSource = XliffTranslationMessageSource
.builder(TestUtilities.getCache())
.builder()
.withCache(TestUtilities.getCache())
.basenamePattern("translations/*")
.defaultLocale(Locale.forLanguageTag("en"))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void test_setTranslationUnitIdentifiersOrdering(
List<XliffVersionInterface.XliffIdentifierInterface> translationUnitIdentifiers,
String code, String expected) {
var messageSource = XliffTranslationMessageSource
.builder(TestUtilities.getCache())
.builder()
.basenamesPattern(
List.of(
"fixtures/identifierv1.xliff",
Expand Down

0 comments on commit 4d69d77

Please sign in to comment.