Skip to content

Commit

Permalink
#973 Resolve minor issues related to property holders
Browse files Browse the repository at this point in the history
  • Loading branch information
GuusLieben committed Aug 2, 2023
1 parent 3430150 commit abdd43b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.dockbox.hartshorn.config.properties.StandardURIConfigProcessor;
import org.dockbox.hartshorn.config.properties.URIConfigProcessor;

import jakarta.inject.Singleton;

@Service
@RequiresActivator(UseConfigurations.class)
@Configuration({"application", "classpath:application"})
Expand All @@ -43,6 +45,7 @@ public class ConfigurationProviders {
* @return {@link StandardPropertyHolder}
*/
@Binds
@Singleton
public PropertyHolder propertyHolder(final ApplicationContext applicationContext,
final ApplicationPropertyHolder propertyHolder,
final ObjectMapper objectMapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -88,19 +87,6 @@ public <T> Option<T> get(final String key, final Class<T> type) {
return this.restore(key, serialized -> this.objectMapper.read(serialized, type));
}

private <T> T copyOf(final T value) {
if (value instanceof Collection<?> collection) {
return (T) new ArrayList<>(collection);
}
else if (value instanceof Map<?, ?> map) {
return (T) new LinkedHashMap<>(map);
}
else {
// Primitive or String
return value;
}
}

@Override
public <T> Option<T> get(final String key, final GenericType<T> type) {
return Option.of(this.find(key))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ protected String dialect() throws ApplicationException {
}

return this.applicationContext()
.property(HH_HIBERNATE_DIALECT)
.get(PropertyHolder.class)
.get(HH_HIBERNATE_DIALECT, String.class)
.orElseThrow(() -> new ApplicationException("No default dialect was configured"));
}

Expand Down

0 comments on commit abdd43b

Please sign in to comment.