001/*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 * http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014
015package de.softwareforge.testing.postgres.embedded;
016
017import jakarta.annotation.Nonnull;
018import java.io.File;
019import java.io.IOException;
020
021/**
022 * Returns an installation location for a native binary. The implementation is responsible for locating and optionally unpacking installing the binary.
023 *
024 * @since 3.0
025 */
026@FunctionalInterface
027public interface NativeBinaryManager {
028
029    /**
030     * Returns the location (installation directory) for the installed binary.
031     *
032     * @return Installation directory with the native binary installed.
033     * @throws IOException If the binary could not be located or installed.
034     */
035    @Nonnull
036    File getLocation() throws IOException;
037
038    /**
039     * Sets the installation directory. This method must be called before the first call to {@link NativeBinaryManager#getLocation()}.
040     * <p>
041     * Implementing this method is optional if no local installation directory is required.
042     *
043     * @param installationBaseDirectory Base directory in which the binary distribution is unpacked. Must not be null.
044     */
045    default void setInstallationBaseDirectory(File installationBaseDirectory) {
046    }
047}