All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dreamhead.moco.util.Configs Maven / Gradle / Ivy

Go to download

Moco is an easy setup stub framework, mainly focusing on testing and integration.

There is a newer version: 1.5.0
Show newest version
package com.github.dreamhead.moco.util;

import com.github.dreamhead.moco.ConfigApplier;
import com.github.dreamhead.moco.MocoConfig;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;

import java.util.List;

import static com.google.common.collect.FluentIterable.from;

public final class Configs {
    public static > T configItem(final T source, final MocoConfig... configs) {
        if (source == null) {
            return null;
        }

        T target = source;
        for (MocoConfig config : configs) {
            target = target.apply(config);
        }
        return target;
    }

    public static > ImmutableList configItems(final List items,
                                                                            final MocoConfig... configs) {
        return from(items).transform(Configs.config(configs)).toList();
    }

    private static > Function config(final MocoConfig... configs) {
        return new Function() {
            @Override
            public T apply(final T item) {
                return configItem(item, configs);
            }
        };
    }

    private Configs() {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy