From 2eb0811c7b1e02600bf7bafdd0e0b80a3c2dd56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hohwiller?= Date: Tue, 19 Dec 2023 19:23:27 +0100 Subject: [PATCH] ServiceHelper refactoring --- .../impl/StructuredFormatFactoryImpl.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/io/github/mmm/marshall/impl/StructuredFormatFactoryImpl.java b/core/src/main/java/io/github/mmm/marshall/impl/StructuredFormatFactoryImpl.java index e6800ca..ce01dba 100644 --- a/core/src/main/java/io/github/mmm/marshall/impl/StructuredFormatFactoryImpl.java +++ b/core/src/main/java/io/github/mmm/marshall/impl/StructuredFormatFactoryImpl.java @@ -7,6 +7,7 @@ import java.util.ServiceLoader; import io.github.mmm.base.exception.ObjectNotFoundException; +import io.github.mmm.base.service.ServiceHelper; import io.github.mmm.marshall.StructuredFormatFactory; import io.github.mmm.marshall.StructuredFormatProvider; @@ -29,21 +30,8 @@ protected StructuredFormatFactoryImpl() { super(); this.providerMap = new HashMap<>(); - ServiceLoader serviceLoader = ServiceLoader.load(StructuredFormatProvider.class); - for (StructuredFormatProvider provider : serviceLoader) { - register(provider); - } - } - - /** - * @param provider the {@link StructuredFormatProvider} to register. - */ - public void register(StructuredFormatProvider provider) { - - StructuredFormatProvider duplicate = this.providerMap.put(provider.getId(), provider); - if (duplicate != null) { - - } + ServiceHelper.all(ServiceLoader.load(StructuredFormatProvider.class), this.providerMap, + StructuredFormatProvider::getId); } @Override