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

org.hibernate.search.engine.cfg.impl.DefaultedConfigurationProperty Maven / Gradle / Ivy

/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright Red Hat Inc. and Hibernate Authors
 */
package org.hibernate.search.engine.cfg.impl;

import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;

final class DefaultedConfigurationProperty extends AbstractConfigurationProperty {

	private final Function converter;
	private final Supplier defaultValueSupplier;

	DefaultedConfigurationProperty(String key, Function converter, Supplier defaultValueSupplier) {
		super( key );
		this.converter = converter;
		this.defaultValueSupplier = defaultValueSupplier;
	}

	@Override
	 R convert(Optional rawValue, Function transform) {
		T defaultedValue = rawValue.map( converter ).orElseGet( defaultValueSupplier );
		return transform.apply( defaultedValue );
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy