com.github.dreamhead.moco.util.Configs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-core Show documentation
Show all versions of moco-core Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
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() {
}
}