All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.search.engine.cfg.spi.ConsumedPropertyTrackingConfigurationPropertySource Maven / Gradle / Ivy

There is a newer version: 8.0.0.Alpha1
Show newest version
/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright Red Hat Inc. and Hibernate Authors
 */
package org.hibernate.search.engine.cfg.spi;

import java.util.Optional;
import java.util.function.Consumer;

import org.hibernate.search.engine.cfg.ConfigurationPropertySource;

public final class ConsumedPropertyTrackingConfigurationPropertySource implements ConfigurationPropertySource {

	private final ConfigurationPropertySource delegate;

	private final Consumer tracker;

	public ConsumedPropertyTrackingConfigurationPropertySource(ConfigurationPropertySource delegate,
			Consumer tracker) {
		this.delegate = delegate;
		this.tracker = tracker;
	}

	@Override
	public Optional get(String key) {
		Optional resolved = resolve( key );
		if ( resolved.isPresent() ) {
			tracker.accept( resolved.get() );
		}
		return delegate.get( key );
	}

	@Override
	public Optional resolve(String key) {
		return delegate.resolve( key );
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy