Skip to content

Commit

Permalink
Add javadoc and rename merge method to mergeProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Feb 6, 2024
1 parent 9c15b3f commit 9698dbc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -110,6 +110,7 @@ public void addBasenames(String... basenames) {
* in the order of registration.
* <p>Calling code may introspect this set as well as add or remove entries.
* @since 4.3
* @see #setBasenames
* @see #addBasenames
*/
public Set<String> getBasenameSet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,23 +250,31 @@ protected MessageFormat resolveCode(String code, Locale locale) {
* <p>Only used when caching resource bundle contents forever, i.e.
* with cacheSeconds &lt; 0. Therefore, merged properties are always
* cached forever.
* @see #collectPropertiesToMerge
* @see #mergeProperties
*/
protected PropertiesHolder getMergedProperties(Locale locale) {
PropertiesHolder mergedHolder = this.cachedMergedProperties.get(locale);
if (mergedHolder != null) {
return mergedHolder;
}

List<PropertiesHolder> holders = collectPropertiesToMerge(locale);

mergedHolder = merge(holders);
mergedHolder = mergeProperties(collectPropertiesToMerge(locale));
PropertiesHolder existing = this.cachedMergedProperties.putIfAbsent(locale, mergedHolder);
if (existing != null) {
mergedHolder = existing;
}
return mergedHolder;
}

/**
* Determine the properties to merge based on the specified basenames.
* @param locale the locale
* @return the list of properties holders
* @since 6.1.4
* @see #getBasenameSet()
* @see #calculateAllFilenames
* @see #mergeProperties
*/
protected List<PropertiesHolder> collectPropertiesToMerge(Locale locale) {
String[] basenames = StringUtils.toStringArray(getBasenameSet());
List<PropertiesHolder> holders = new ArrayList<>(basenames.length);
Expand All @@ -283,7 +291,16 @@ protected List<PropertiesHolder> collectPropertiesToMerge(Locale locale) {
return holders;
}

protected PropertiesHolder merge(List<PropertiesHolder> holders) {
/**
* Merge the given properties holders into a single holder.
* @param holders the list of properties holders
* @return a single merged holder
* @since 6.1.4
* @see #newProperties()
* @see #getMergedProperties
* @see #collectPropertiesToMerge
*/
protected PropertiesHolder mergeProperties(List<PropertiesHolder> holders) {
Properties mergedProps = newProperties();
long latestTimestamp = -1;
for (PropertiesHolder holder : holders) {
Expand Down

0 comments on commit 9698dbc

Please sign in to comment.