Skip to content

Commit 04b79f3

Browse files
dmealingclaude
andcommitted
refactor(java): simplify loader-unification code
- MetaDataLoader.fromUris: replace stream/Collectors with a plain for-loop over an ArrayList sized from the input, matching the existing style in loadSourceURIsIfPresent / fromResources / processSources in the same file. - MetaDataLoader: drop the now-unused java.util.stream.Collectors import that was only there for fromUris. - MetaDataSource Javadoc: extend the "Concrete implementations" list and @see block to include the new FileSource and DirectorySource classes added in this branch (the list previously only mentioned InMemoryStringSource and UriSource). No behavior changes; full reactor mvn test passes (17/17 modules). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 8edfb83 commit 04b79f3

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

server/java/metadata/src/main/java/com/metaobjects/loader/MetaDataLoader.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.util.Collections;
3333
import java.util.List;
3434
import java.util.Map;
35-
import java.util.stream.Collectors;
3635
import java.util.concurrent.CompletableFuture;
3736
import java.util.concurrent.ConcurrentHashMap;
3837
import java.util.concurrent.ExecutionException;
@@ -238,9 +237,8 @@ public static MetaDataLoader fromUris(String name, List<URI> uris) {
238237
MetaDataLoader loader = createManual(false, name);
239238
try {
240239
loader.init();
241-
List<MetaDataSource> sources = uris.stream()
242-
.map(uri -> (MetaDataSource) new UriSource(uri))
243-
.collect(Collectors.toList());
240+
List<MetaDataSource> sources = new ArrayList<>(uris.size());
241+
for (URI uri : uris) sources.add(new UriSource(uri));
244242
loader.load(sources);
245243
loader.register();
246244
} catch (MetaDataLoadingException e) {

server/java/metadata/src/main/java/com/metaobjects/loader/MetaDataSource.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
* <p>Concrete implementations:
1313
* <ul>
1414
* <li>{@link InMemoryStringSource} — a pre-loaded string (useful in tests)</li>
15+
* <li>{@link FileSource} — a single filesystem path</li>
16+
* <li>{@link DirectorySource} — expands a directory into a stream of {@link FileSource}</li>
1517
* <li>{@link UriSource} — reads via {@link com.metaobjects.loader.uri.URIHelper}</li>
1618
* </ul>
1719
* </p>
1820
*
1921
* @see InMemoryStringSource
22+
* @see FileSource
23+
* @see DirectorySource
2024
* @see UriSource
2125
*/
2226
public interface MetaDataSource {

0 commit comments

Comments
 (0)