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 */
014package de.softwareforge.testing.postgres.embedded;
015
016import java.io.File;
017import java.io.IOException;
018
019import edu.umd.cs.findbugs.annotations.NonNull;
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@FunctionalInterface
025public interface NativeBinaryManager {
026
027    /**
028     * Returns the location (installation directory) for the installed binary.
029     *
030     * @return Installation directory with the native binary installed.
031     * @throws IOException If the binary could not be located or installed.
032     */
033    @NonNull
034    File getLocation() throws IOException;
035
036    /**
037     * Sets the installation directory. This method must be called before the first call to {@link NativeBinaryManager#getLocation()}.
038     * <p>
039     * Implementing this method is optional if no local installation directory is required.
040     *
041     * @param installationBaseDirectory Base directory in which the binary distribution is unpacked. Must not be null.
042     */
043    default void setInstallationBaseDirectory(File installationBaseDirectory) {
044    }
045}