package com.atlassian.bitbucket.mesh.layout;

import javax.annotation.Nonnull;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;

/**
 * A helper interface to abstract getting home subdirectory overrides.
 */
public interface HomeSubdirectoryResolver {

    /**
     * Resolves <i>and creates</i> the requested subdirectory, with any configured override applied.
     *
     * @param parent the parent directory
     * @param name   the name of the subdirectory
     * @return the target subdirectory
     * @throws InvalidPathException if the path string cannot be converted to a {@code Path}
     * @throws IllegalStateException if the {@code directory} path already exists and is not a directory, or if the
     * directory cannot be created
     */
    @Nonnull
    Path resolve(@Nonnull Path parent, @Nonnull String name);
}
