Esempio n. 1
0
  public static BiFunction<AlgebraicDataType, DeriveContext, DeriveResult<DerivedCodeSpec>>
      derivator(DeriveUtils deriveUtils) {

    return (adt, deriveContext) ->
        traverseResults(
                deriveContext.makes(),
                Makes.cases()
                    .lambdaVisitor(
                        lazy(() -> MapperDerivator.derive(adt, deriveContext, deriveUtils)))
                    .constructors(
                        lazy(
                            () ->
                                StrictConstructorDerivator.derive(adt, deriveContext, deriveUtils)))
                    .lazyConstructor(
                        lazy(
                            () -> LazyConstructorDerivator.derive(adt, deriveContext, deriveUtils)))
                    .patternMatching(
                        lazy(
                            () -> PatternMatchingDerivator.derive(adt, deriveContext, deriveUtils)))
                    .getters(lazy(() -> GettersDerivator.derive(adt, deriveContext, deriveUtils)))
                    .modifiers(lazy(() -> ModiersDerivator.derive(adt, deriveContext, deriveUtils)))
                    .catamorphism(
                        lazy(() -> new CataDerivator(deriveUtils, deriveContext, adt).derive()))
                    .hktCoerce(DeriveResult.result(DerivedCodeSpec.none())))
            .map(
                codeSpecList ->
                    codeSpecList.stream().reduce(DerivedCodeSpec.none(), DerivedCodeSpec::append));
  }
Esempio n. 2
0
 public static BiFunction<AlgebraicDataType, DeriveContext, DeriveResult<DerivedCodeSpec>>
     derivator(DeriveUtils deriveUtils) {
   return (adt, deriveContext) ->
       traverseResults(
               Arrays.asList(
                   lazy(() -> StrictConstructorDerivator.derive(adt, deriveContext, deriveUtils)),
                   lazy(() -> LazyConstructorDerivator.derive(adt, deriveContext, deriveUtils)),
                   lazy(() -> MapperDerivator.derive(adt, deriveContext, deriveUtils)),
                   lazy(() -> GettersDerivator.derive(adt, deriveContext, deriveUtils)),
                   lazy(() -> ModiersDerivator.derive(adt, deriveContext, deriveUtils)),
                   lazy(() -> PatternMatchingDerivator.derive(adt, deriveContext, deriveUtils))))
           .map(
               codeSpecList ->
                   codeSpecList.stream().reduce(DerivedCodeSpec.none(), Utils::appendCodeSpecs));
 }