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;
020
021/**
022 * Strategy to use when moving a node from one path to another
023 */
024public enum MoveStrategy {
025
026    /**
027     * Moves nodes using {@link ConfigurationNode#mergeValuesFrom(ConfigurationNode)}.
028     */
029    MERGE {
030        @Override
031        public void move(ConfigurationNode source, ConfigurationNode target) {
032            target.mergeValuesFrom(source);
033        }
034    },
035
036    /**
037     * Moves nodes using {@link ConfigurationNode#setValue(Object)}.
038     */
039    OVERWRITE {
040        @Override
041        public void move(ConfigurationNode source, ConfigurationNode target) {
042            target.setValue(source);
043        }
044    };
045
046    /**
047     * Moves <code>source</code> to <code>target</code>.
048     *
049     * @param source The source node
050     * @param target The target node
051     */
052    public abstract void move(ConfigurationNode source, ConfigurationNode target);
053}