001/*
002 * Configurate
003 * Copyright (C) zml and Configurate contributors
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package ninja.leaping.configurate.transformation;
018
019import ninja.leaping.configurate.ConfigurationNode;
020import org.checkerframework.checker.nullness.qual.NonNull;
021import org.checkerframework.checker.nullness.qual.Nullable;
022
023/**
024 * Represents an action to be performed that transforms a node in the configuration tree
025 */
026@FunctionalInterface
027public interface TransformAction {
028
029    /**
030     * Called at a certain path, with the node at that path.
031     *
032     * <p>The state of the <code>inputPath</code> is only guaranteed to be accurate during a run of
033     * the transform function. Use {@link NodePath#getArray()} if its' state needs to be stored.</p>
034     *
035     * @param inputPath The path of the given node
036     * @param valueAtPath The node at the input path. May be modified
037     * @return A modified path, or null if the path is to stay the same
038     */
039    @Nullable
040    Object[] visitPath(ConfigurationTransformation.@NonNull NodePath inputPath, @NonNull ConfigurationNode valueAtPath);
041
042}