net.openhft.chronicle.wire.internal.extractor.DocumentExtractorBuilder Maven / Gradle / Ivy
/*
* Copyright 2016-2022 chronicle.software
*
* https://chronicle.software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.openhft.chronicle.wire.internal.extractor;
import net.openhft.chronicle.core.util.ThreadConfinementAsserter;
import net.openhft.chronicle.wire.domestic.extractor.DocumentExtractor;
import org.jetbrains.annotations.NotNull;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import static net.openhft.chronicle.core.util.ObjectUtils.requireNonNull;
/**
* Responsible for building and configuring document extractors for a specified type {@code E}.
* This class provides flexibility in the extraction process, enabling efficient document extraction.
*/
public final class DocumentExtractorBuilder implements DocumentExtractor.Builder {
// Represents the type of element to be extracted.
private final Class elementType;
// A supplier to provide instances of the type E.
private Supplier extends E> supplier;
// Flag to determine if reuse of the supplier is confined to the current thread.
private boolean threadConfinedReuse;
// Reference to the method used for extraction.
private MethodRef