/*******************************************************************************
 * Copyright (C) 2016 Push Technology Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/

package com.pushtechnology.diffusion.transform.transformer;

/**
 * A transformer. Converts values of one type into values of a different
 * type. It will not throw an exception.
 *
 * @param <S> the type of the source values
 * @param <T> the type of the transformed values
 * @author Push Technology Limited
 * @deprecated since 2.0.0 in favour of {@link java.util.function.Function}
 */
@SuppressWarnings("deprecation")
@Deprecated
public interface SafeTransformer<S, T> extends Transformer<S, T> {
    @Override
    T transform(S value);
}

/*******************************************************************************
 * Copyright (C) 2016 Push Technology Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/

package com.pushtechnology.diffusion.transform.transformer;

import java.util.function.Function;

/**
 * A transformer. Converts values of one type into values of a different
 * type. It will not throw an exception.
 *
 * @param <S> the type of the source values
 * @param <T> the type of the transformed values
 * @author Push Technology Limited
 * @deprecated since 2.0.0 in favour of {@link java.util.function.Function}
 */
@SuppressWarnings("deprecation")
@Deprecated
public interface SafeTransformer<S, T> extends Transformer<S, T> {
    @Override
    T transform(S value);

    /**
     * Convert the transformer to a function.
     *
     * @return the transformer as a function
     */
    default Function<S, T> asFunction() {
        return this::transform;
    }
}

Add a method to convert a safe transformer to a function.
Add a method to convert a safe transformer to a function.
