org.hibernate.search.engine.cfg.impl.MapConfigurationPropertySource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-search-engine Show documentation
Show all versions of hibernate-search-engine Show documentation
Hibernate Search engine, always required
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.search.engine.cfg.impl;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
import org.hibernate.search.engine.cfg.spi.AllAwareConfigurationPropertySource;
public class MapConfigurationPropertySource implements AllAwareConfigurationPropertySource {
private final Map map;
public MapConfigurationPropertySource(Map map) {
this.map = map;
}
@Override
public Optional> get(String key) {
Object value = map.get( key );
return Optional.ofNullable( value );
}
@Override
public Optional resolve(String key) {
return Optional.of( key );
}
@Override
public Set resolveAll(BiPredicate predicate) {
return map.entrySet().stream()
.filter( e -> predicate.test( e.getKey(), e.getValue() ) )
.map( Map.Entry::getKey )
.collect( Collectors.toSet() );
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder( getClass().getSimpleName() )
.append( "[" )
.append( "map=" ).append( map )
.append( "]" );
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy