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; 019import org.apiguardian.api.API; 020import org.apiguardian.api.API.Status; 021 022/** 023 * Interface for a {@link JctFileManager} configurer. 024 * 025 * <p>Configurers are designed to be chained to enable applying sets of operation to file managers 026 * during creation. 027 * 028 * <p>The configurer itself must return a {@link JctFileManager} instance. This will usually 029 * be the same value that is passed in the input parameter, as most configurers will only 030 * want to mutate an existing file manager. Configurers may instead opt to return a different 031 * file manager as the result, enabling wrapping the input in proxies or delegating 032 * implementations. 033 * 034 * <p>Configurers may also decide to not run at all by marking themselves as being disabled, 035 * which will result in them being skipped by any configurer chain or file manager that 036 * respects this attribute. 037 * 038 * @author Ashley Scopes 039 * @since 0.0.1 040 */ 041@API(since = "0.0.1", status = Status.STABLE) 042@FunctionalInterface 043public interface JctFileManagerConfigurer { 044 045 /** 046 * Configure the file manager implementation. 047 * 048 * @param fileManager the file manager implementation. 049 * @return the new file manager (this may be the same as the input file manager). 050 */ 051 JctFileManager configure(JctFileManager fileManager); 052 053 /** 054 * Determine if this configurer is enabled or not. 055 * 056 * <p>Default implementations are enabled automatically unless otherwise 057 * specified. 058 * 059 * @return {@code true} if enabled, {@code false} if disabled. 060 */ 061 default boolean isEnabled() { 062 return true; 063 } 064}