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

net.zerobuilder.compiler.generate.DtoRegularGoalContext Maven / Gradle / Ivy

There is a newer version: 1.603
Show newest version
package net.zerobuilder.compiler.generate;

import com.squareup.javapoet.TypeName;
import net.zerobuilder.compiler.generate.DtoGoalContext.AbstractGoalContext;
import net.zerobuilder.compiler.generate.DtoProjectedRegularGoalContext.ProjectedRegularGoalContext;
import net.zerobuilder.compiler.generate.DtoRegularGoal.SimpleRegularGoalContext;

import java.util.List;
import java.util.function.Function;

final class DtoRegularGoalContext {

  public static abstract class RegularGoalContext extends AbstractGoalContext {

    public final List thrownTypes;

    RegularGoalContext(List thrownTypes) {
      this.thrownTypes = thrownTypes;
    }

    abstract  R acceptRegular(RegularGoalContextCases cases);
    @Override
    final  R accept(DtoGoalContext.GoalCases cases) {
      return cases.regularGoal(this);
    }
  }

  interface RegularGoalContextCases {
    R simple(SimpleRegularGoalContext simple);
    R projected(ProjectedRegularGoalContext projected);
  }

  static  Function asFunction(RegularGoalContextCases cases) {
    return goal -> goal.acceptRegular(cases);
  }

  static  Function regularGoalContextCases(
      Function simpleFunction,
      Function projectedFunction) {
    return asFunction(new RegularGoalContextCases() {
      @Override
      public R simple(SimpleRegularGoalContext simple) {
        return simpleFunction.apply(simple);
      }
      @Override
      public R projected(ProjectedRegularGoalContext projected) {
        return projectedFunction.apply(projected);
      }
    });
  }


  private DtoRegularGoalContext() {
    throw new UnsupportedOperationException("no instances");
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy