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 org.spongepowered.configurate.transformation; 018 019import org.spongepowered.configurate.ConfigurationNode; 020 021/** 022 * Strategy to use when moving a node from one path to another. 023 * 024 * @since 4.0.0 025 */ 026public enum MoveStrategy { 027 028 /** 029 * Moves nodes using {@link ConfigurationNode#mergeFrom(ConfigurationNode)}. 030 * 031 * @since 4.0.0 032 */ 033 MERGE { 034 @Override 035 public <T extends ConfigurationNode> void move(final T source, final T target) { 036 target.mergeFrom(source); 037 } 038 }, 039 040 /** 041 * Moves nodes using {@link ConfigurationNode#set(Object)}. 042 * 043 * @since 4.0.0 044 */ 045 OVERWRITE { 046 @Override 047 public <T extends ConfigurationNode> void move(final T source, final T target) { 048 target.from(source); 049 } 050 }; 051 052 /** 053 * Moves <code>source</code> to <code>target</code>. 054 * 055 * @param <T> the type of node being processed 056 * @param source the source node 057 * @param target the target node 058 * @since 4.0.0 059 */ 060 public abstract <T extends ConfigurationNode> void move(T source, T target); 061 062}