    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  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.apache.commons.configuration2.convert;
    018
    019/**
    020 * <p>
    021 * Definition of an interface used by {@link ListDelimiterHandler} to perform additional transformations on behalf of a
    022 * configuration when a property value is escaped.
    023 * </p>
    024 * <p>
    025 * Some {@code Configuration} implementations require a special encoding of their property values before they get
    026 * written on disk. In some constellations, for example when a property with multiple values is to be forced on a single line,
    027 * this encoding has to be done together with the escaping of list delimiter characters - which is in the responsibility
    028 * of {@link ListDelimiterHandler}.
    029 * </p>
    030 * <p>
    031 * In order to allow a proper collaboration between the parties involved, this interface was introduced. A configuration
    032 * object provides an implementation of {@code ValueTransformer} and passes it to the {@code ListDelimiterHandler} when
    033 * escaping of properties is needed. The delimiter handler can then call back to perform the additional encoding as its
    034 * pleasure.
    035 * </p>
    036 *
    037 * @since 2.0
    038 */
    039public interface ValueTransformer {
    040    /**
    041     * Performs an arbitrary encoding of the passed in value object. This method is called by a {@link ListDelimiterHandler}
    042     * implementation before or after list delimiters have been escaped.
    043     *
    044     * @param value the property value to be transformed
    045     * @return the transformed property value
    046     */
    047    Object transformValue(Object value);
    048}