001/*
002 * Copyright (C) 2022 - 2024, the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *    http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package io.github.ascopes.jct.filemanagers.config;
017
018import io.github.ascopes.jct.filemanagers.JctFileManager;
019
020/**
021 * Interface for a {@link JctFileManager} configurer.
022 *
023 * <p>Configurers are designed to be chained to enable applying sets of operation to file managers
024 * during creation.
025 *
026 * <p>The configurer itself must return a {@link JctFileManager} instance. This will usually
027 * be the same value that is passed in the input parameter, as most configurers will only
028 * want to mutate an existing file manager. Configurers may instead opt to return a different
029 * file manager as the result, enabling wrapping the input in proxies or delegating
030 * implementations.
031 *
032 * <p>Configurers may also decide to not run at all by marking themselves as being disabled,
033 * which will result in them being skipped by any configurer chain or file manager that
034 * respects this attribute.
035 *
036 * @author Ashley Scopes
037 * @since 0.0.1
038 */
039@FunctionalInterface
040public interface JctFileManagerConfigurer {
041
042  /**
043   * Configure the file manager implementation.
044   *
045   * @param fileManager the file manager implementation.
046   * @return the new file manager (this may be the same as the input file manager).
047   */
048  JctFileManager configure(JctFileManager fileManager);
049
050  /**
051   * Determine if this configurer is enabled or not.
052   *
053   * <p>Default implementations are enabled automatically unless otherwise
054   * specified.
055   *
056   * @return {@code true} if enabled, {@code false} if disabled.
057   */
058  default boolean isEnabled() {
059    return true;
060  }
061}