
com.github.phantomthief.model.builder.impl.LazyBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of model-view-builder Show documentation
Show all versions of model-view-builder Show documentation
A hierarchy model builder with view mapper
The newest version!
package com.github.phantomthief.model.builder.impl;
import java.util.Collection;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
import com.github.phantomthief.model.builder.impl.SimpleModelBuilder.Lazy;
/**
* @author w.vela
*/
public class LazyBuilder {
public static Lazy on(Object sourceNamespace, Function, Map> builder,
Object targetNamespace) {
return new Lazy() {
@Override
public Object sourceNamespace() {
return sourceNamespace;
}
@Override
public Object targetNamespace() {
return targetNamespace;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public BiFunction, ?, ?> builder() {
return (context, ids) -> ((Function) builder).apply(ids);
}
};
}
public static Lazy on(Object sourceNamespace,
BiFunction, Map> builder, Object targetNamespace) {
return new Lazy() {
@Override
public Object sourceNamespace() {
return sourceNamespace;
}
@Override
public Object targetNamespace() {
return targetNamespace;
}
@Override
public BiFunction, ?, ?> builder() {
return builder;
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy