net.zerobuilder.compiler.generate.DtoProjectedParameter Maven / Gradle / Ivy
package net.zerobuilder.compiler.generate;
import net.zerobuilder.compiler.generate.DtoBeanParameter.AbstractBeanParameter;
import net.zerobuilder.compiler.generate.DtoRegularParameter.ProjectedParameter;
import java.util.function.Function;
public final class DtoProjectedParameter {
interface AbstractProjectedParameter {
R acceptProjected(ProjectedParameterCases cases);
}
interface ProjectedParameterCases {
R projectedRegular(ProjectedParameter regular);
R projectedBean(AbstractBeanParameter bean);
}
static Function asFunction(ProjectedParameterCases cases) {
return parameter -> parameter.acceptProjected(cases);
}
static Function projectedParameterCases(
Function regularFunction,
Function beanFunction) {
return asFunction(new ProjectedParameterCases() {
@Override
public R projectedRegular(ProjectedParameter regular) {
return regularFunction.apply(regular);
}
@Override
public R projectedBean(AbstractBeanParameter bean) {
return beanFunction.apply(bean);
}
});
}
private DtoProjectedParameter() {
throw new UnsupportedOperationException("no instances");
}
}