├── .github └── workflows │ └── build.yml ├── .gitignore ├── .java-version ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .vscode └── settings.json ├── CODESTYLE ├── LICENSE ├── README.md ├── build.sh ├── docs ├── access_lens.md ├── choice_type.md ├── disclaimers.md ├── event.md ├── functions.md ├── index.md ├── list_map.md ├── pipeable_pipeline.md ├── ref.md ├── result.md ├── rule_type.md ├── side_effect.md ├── stream_iterator.md ├── struct_type.md └── youtube.png ├── example └── TimeGapExample2.java ├── functionalj-all ├── pom.xml └── src │ ├── main │ └── java │ │ └── functionalj │ │ └── FunctionalJAll.java │ └── test │ └── java │ └── .empty-dir ├── functionalj-core-21 └── pom.xml ├── functionalj-core ├── TODO ├── pom.xml └── src │ ├── experiment │ └── java │ │ └── functionalj │ │ └── experiment │ │ └── coroutine │ │ ├── CoroutineTest.java │ │ └── GeneratorTest.java │ ├── guarantee │ └── java │ │ └── functionalj │ │ └── types │ │ └── GuaranteeCoreAnnotationsDependencyTest.java │ ├── main │ └── java │ │ └── functionalj │ │ ├── data │ │ └── FuncData.java │ │ ├── environments │ │ ├── Console.java │ │ ├── ConsoleInQueue.java │ │ ├── Env.java │ │ ├── Log.java │ │ ├── Time.java │ │ └── VirtualThreadRunner.java │ │ ├── event │ │ ├── Cancellation.java │ │ ├── MainTopic.java │ │ ├── Publisher.java │ │ ├── SubTopic.java │ │ ├── Subscription.java │ │ └── Topic.java │ │ ├── exception │ │ ├── ExceptionUtils.java │ │ ├── FunctionInvocationException.java │ │ ├── InterruptedRuntimeException.java │ │ ├── WrapException.java │ │ └── WrapThrowable.java │ │ ├── function │ │ ├── Absent.java │ │ ├── Annotated.java │ │ ├── Apply.java │ │ ├── CharSupplier.java │ │ ├── CharToIntFunction.java │ │ ├── Check.java │ │ ├── Compare.java │ │ ├── DoubleComparator.java │ │ ├── DoubleDoubleFunction.java │ │ ├── DoubleDoublePredicatePrimitive.java │ │ ├── DoubleDoubleToDoubleFunctionPrimitive.java │ │ ├── DoubleDoubleToIntFunctionPrimitive.java │ │ ├── DoubleIntegerToDoubleFunction.java │ │ ├── DoubleIntegerToIntegerFunction.java │ │ ├── DoubleLongToDoubleFunction.java │ │ ├── DoubleObjBiConsumer.java │ │ ├── DoubleObjBiFunction.java │ │ ├── DoubleObjBiPredicate.java │ │ ├── DoublePredicatePrimitive.java │ │ ├── Drop.java │ │ ├── Func.java │ │ ├── Func0.java │ │ ├── Func1.java │ │ ├── Func10.java │ │ ├── Func2.java │ │ ├── Func3.java │ │ ├── Func4.java │ │ ├── Func5.java │ │ ├── Func6.java │ │ ├── Func7.java │ │ ├── Func8.java │ │ ├── Func9.java │ │ ├── FuncUnit.java │ │ ├── FuncUnit0.java │ │ ├── FuncUnit1.java │ │ ├── FuncUnit10.java │ │ ├── FuncUnit2.java │ │ ├── FuncUnit3.java │ │ ├── FuncUnit4.java │ │ ├── FuncUnit5.java │ │ ├── FuncUnit6.java │ │ ├── FuncUnit7.java │ │ ├── FuncUnit8.java │ │ ├── FuncUnit9.java │ │ ├── IntBiConsumer.java │ │ ├── IntBiFunctionPrimitive.java │ │ ├── IntBiPredicatePrimitive.java │ │ ├── IntComparator.java │ │ ├── IntDoubleBiFunction.java │ │ ├── IntDoubleConsumer.java │ │ ├── IntDoublePredicate.java │ │ ├── IntDoubleToDoubleFunctionPrimitive.java │ │ ├── IntDoubleToIntFunction.java │ │ ├── IntDoubleToIntFunctionPrimitive.java │ │ ├── IntFunctionPrimitive.java │ │ ├── IntIntBiFunction.java │ │ ├── IntIntToDoubleFunctionPrimitive.java │ │ ├── IntIntToIntFunctionPrimitive.java │ │ ├── IntIntToLongFunctionPrimitive.java │ │ ├── IntLongBiFunction.java │ │ ├── IntLongConsumer.java │ │ ├── IntLongFunctionPrimitive.java │ │ ├── IntLongPredicatePrimitive.java │ │ ├── IntLongToIntFunction.java │ │ ├── IntLongToLongFunctionPrimitive.java │ │ ├── IntObjBiConsumer.java │ │ ├── IntObjBiFunction.java │ │ ├── IntObjBiPredicate.java │ │ ├── IntObjToDoubleBiFunction.java │ │ ├── IntObjToIntBiFunction.java │ │ ├── IntObjToLongBiFunction.java │ │ ├── IntPredicatePrimitive.java │ │ ├── IntSupplierPrimitive.java │ │ ├── IntToByteFunction.java │ │ ├── IntToCharFunction.java │ │ ├── Lambda.java │ │ ├── LongBiConsumer.java │ │ ├── LongBiFunctionPrimitive.java │ │ ├── LongBiPredicatePrimitive.java │ │ ├── LongComparator.java │ │ ├── LongLongBiFunction.java │ │ ├── LongLongToDoubleFunctionPrimitive.java │ │ ├── LongLongToIntFunctionPrimitive.java │ │ ├── LongObjBiConsumer.java │ │ ├── LongObjBiFunction.java │ │ ├── LongObjBiPredicate.java │ │ ├── LongPredicatePrimitive.java │ │ ├── Named.java │ │ ├── ObjDoubleBiFunction.java │ │ ├── ObjIntBiFunction.java │ │ ├── ObjIntToIntFunctionPrimitive.java │ │ ├── ObjLongBiFunction.java │ │ ├── ObjectDoubleToDoubleFunctionPrimitive.java │ │ ├── ObjectDoubleToIntegerFunctionPrimitive.java │ │ ├── ObjectLongToLongFunctionPrimitive.java │ │ ├── ObjectObjectToDoubleFunctionPrimitive.java │ │ ├── ObjectObjectToIntFunctionPrimitive.java │ │ ├── ObjectObjectToIntegerFunction.java │ │ ├── Operators.java │ │ ├── ToByteFunction.java │ │ ├── ToCharBiCharFunction.java │ │ ├── ToCharFunction.java │ │ ├── ToDoubleBiIntFunction.java │ │ ├── ToDoubleBiLongFunction.java │ │ ├── ToIntBiDoubleFunctionPrimitive.java │ │ ├── ToIntBiIntFunction.java │ │ ├── ToIntBiLongFunction.java │ │ ├── ToIntBiLongFunctionPrimitive.java │ │ ├── ToIntegerBiDoubleFunction.java │ │ ├── ToLongBiIntFunction.java │ │ ├── ToLongBiLongFunction.java │ │ ├── ToLongBiLongFunctionPrimitive.java │ │ ├── Traced.java │ │ └── aggregator │ │ │ ├── Aggregation.java │ │ │ ├── AggregationToBoolean.java │ │ │ ├── AggregationToDouble.java │ │ │ ├── AggregationToInt.java │ │ │ ├── AggregationToLong.java │ │ │ ├── Aggregator.java │ │ │ ├── AggregatorToBoolean.java │ │ │ ├── AggregatorToDouble.java │ │ │ ├── AggregatorToInt.java │ │ │ ├── AggregatorToLong.java │ │ │ ├── DoubleAggregation.java │ │ │ ├── DoubleAggregationToBoolean.java │ │ │ ├── DoubleAggregationToDouble.java │ │ │ ├── DoubleAggregationToInt.java │ │ │ ├── DoubleAggregationToLong.java │ │ │ ├── DoubleAggregator.java │ │ │ ├── DoubleAggregatorToBoolean.java │ │ │ ├── DoubleAggregatorToDouble.java │ │ │ ├── DoubleAggregatorToInt.java │ │ │ ├── DoubleAggregatorToLong.java │ │ │ ├── DoubleReduceAggregationToDouble.java │ │ │ ├── IntAggregation.java │ │ │ ├── IntAggregationToBoolean.java │ │ │ ├── IntAggregationToDouble.java │ │ │ ├── IntAggregationToInt.java │ │ │ ├── IntAggregationToLong.java │ │ │ ├── IntAggregator.java │ │ │ ├── IntAggregatorToBoolean.java │ │ │ ├── IntAggregatorToDouble.java │ │ │ ├── IntAggregatorToInt.java │ │ │ ├── IntAggregatorToLong.java │ │ │ ├── IntReduceAggregationToInt.java │ │ │ ├── LongAggregation.java │ │ │ ├── LongAggregationToBoolean.java │ │ │ ├── LongAggregationToDouble.java │ │ │ ├── LongAggregationToInt.java │ │ │ ├── LongAggregationToLong.java │ │ │ ├── LongAggregator.java │ │ │ ├── LongAggregatorToBoolean.java │ │ │ ├── LongAggregatorToDouble.java │ │ │ ├── LongAggregatorToInt.java │ │ │ ├── LongAggregatorToLong.java │ │ │ ├── LongReduceAggregationToLong.java │ │ │ ├── ReduceAggregation.java │ │ │ └── aggregations │ │ │ ├── Product.java │ │ │ └── Sum.java │ │ ├── functions │ │ ├── IntFuncs.java │ │ ├── LongFuncs.java │ │ ├── MapTo.java │ │ ├── ObjFuncs.java │ │ ├── PathFuncs.java │ │ ├── RegExFlag.java │ │ ├── RegExMatchResult.java │ │ ├── RegExMatchResultStream.java │ │ ├── StrFuncs.java │ │ ├── ThrowFuncs.java │ │ └── TimeFuncs.java │ │ ├── lens │ │ ├── Access.java │ │ ├── Accesses.java │ │ ├── LensTypes.java │ │ ├── TheDouble.java │ │ ├── TheInteger.java │ │ ├── TheLong.java │ │ ├── core │ │ │ ├── AbstractLensType.java │ │ │ ├── AccessCreator.java │ │ │ ├── AccessParameterized.java │ │ │ ├── AccessParameterized2.java │ │ │ ├── AccessUtils.java │ │ │ ├── LensSpec.java │ │ │ ├── LensSpecParameterized.java │ │ │ ├── LensSpecParameterized2.java │ │ │ ├── LensType.java │ │ │ ├── LensUtils.java │ │ │ └── WriteLens.java │ │ └── lenses │ │ │ ├── AnyAccess.java │ │ │ ├── AnyLens.java │ │ │ ├── BigDecimalAccess.java │ │ │ ├── BigDecimalLens.java │ │ │ ├── BigIntegerAccess.java │ │ │ ├── BigIntegerLens.java │ │ │ ├── BooleanAccess.java │ │ │ ├── BooleanAccessBoxed.java │ │ │ ├── BooleanAccessPrimitive.java │ │ │ ├── BooleanLens.java │ │ │ ├── CharacterAccess.java │ │ │ ├── CharacterAccessBoxed.java │ │ │ ├── CharacterAccessPrimitive.java │ │ │ ├── CollectionAccess.java │ │ │ ├── ComparableAccess.java │ │ │ ├── ComparableLens.java │ │ │ ├── ConcreteAccess.java │ │ │ ├── DoubleAccess.java │ │ │ ├── DoubleAccessBoxed.java │ │ │ ├── DoubleAccessEqual.java │ │ │ ├── DoubleAccessEqualPrecision.java │ │ │ ├── DoubleAccessEqualPrecisionPrimitive.java │ │ │ ├── DoubleAccessEqualPrimitive.java │ │ │ ├── DoubleAccessPrimitive.java │ │ │ ├── DoubleLens.java │ │ │ ├── DoubleMathOperators.java │ │ │ ├── DoubleToBooleanAccessPrimitive.java │ │ │ ├── DoubleToDoubleAccessBoxed.java │ │ │ ├── DoubleToDoubleAccessPrimitive.java │ │ │ ├── DoubleToIntegerAccessBoxed.java │ │ │ ├── DoubleToIntegerAccessPrimitive.java │ │ │ ├── DoubleToLongAccessPrimitive.java │ │ │ ├── DoubleToStringAccessPrimitive.java │ │ │ ├── FuncListAccess.java │ │ │ ├── FuncListLens.java │ │ │ ├── FuncMapAccess.java │ │ │ ├── FuncMapEntryAccess.java │ │ │ ├── FuncMapLens.java │ │ │ ├── IndexedDoubleAccess.java │ │ │ ├── IndexedIntAccess.java │ │ │ ├── IndexedItemAccess.java │ │ │ ├── IndexedLongAccess.java │ │ │ ├── IntMathOperators.java │ │ │ ├── IntegerAccess.java │ │ │ ├── IntegerAccessBoxed.java │ │ │ ├── IntegerAccessPrimitive.java │ │ │ ├── IntegerLens.java │ │ │ ├── IntegerToBooleanAccessPrimitive.java │ │ │ ├── IntegerToDoubleAccessEqualPrecisionPrimitive.java │ │ │ ├── IntegerToDoubleAccessEqualPrimitive.java │ │ │ ├── IntegerToDoubleAccessPrimitive.java │ │ │ ├── IntegerToIntegerAccessBoxed.java │ │ │ ├── IntegerToIntegerAccessPrimitive.java │ │ │ ├── IntegerToLongAccessPrimitive.java │ │ │ ├── IntegerToStringAccessPrimitive.java │ │ │ ├── ListAccess.java │ │ │ ├── ListLens.java │ │ │ ├── ListLensEach.java │ │ │ ├── LongAccess.java │ │ │ ├── LongAccessBoxed.java │ │ │ ├── LongAccessPrimitive.java │ │ │ ├── LongLens.java │ │ │ ├── LongMathOperators.java │ │ │ ├── LongToBooleanAccessPrimitive.java │ │ │ ├── LongToDoubleAccessEqualPrecisionPrimitive.java │ │ │ ├── LongToDoubleAccessEqualPrimitive.java │ │ │ ├── LongToDoubleAccessPrimitive.java │ │ │ ├── LongToIntegerAccessBoxed.java │ │ │ ├── LongToIntegerAccessPrimitive.java │ │ │ ├── LongToLongAccessBoxed.java │ │ │ ├── LongToLongAccessPrimitive.java │ │ │ ├── LongToStringAccessPrimitive.java │ │ │ ├── MapAccess.java │ │ │ ├── MapEntryAccess.java │ │ │ ├── MapLens.java │ │ │ ├── MathOperators.java │ │ │ ├── NullableAccess.java │ │ │ ├── NullableLens.java │ │ │ ├── NumberAccess.java │ │ │ ├── ObjectAccess.java │ │ │ ├── ObjectLens.java │ │ │ ├── ObjectLensImpl.java │ │ │ ├── OptionalAccess.java │ │ │ ├── OptionalLens.java │ │ │ ├── PrimitiveLensSpecs.java │ │ │ ├── ResultAccess.java │ │ │ ├── ResultLens.java │ │ │ ├── RuleLens.java │ │ │ ├── StreamPlusAccess.java │ │ │ ├── StringAccess.java │ │ │ ├── StringLens.java │ │ │ ├── Tuple2Access.java │ │ │ ├── Tuple2Lens.java │ │ │ └── java │ │ │ └── time │ │ │ ├── ChronoLocalDateAccess.java │ │ │ ├── ChronoLocalDateTimeAccess.java │ │ │ ├── ChronoPeriodAccess.java │ │ │ ├── ChronoZonedDateTimeAccess.java │ │ │ ├── ChronologyAccess.java │ │ │ ├── DayOfWeekAccess.java │ │ │ ├── DayOfWeekLens.java │ │ │ ├── DurationAccess.java │ │ │ ├── DurationLens.java │ │ │ ├── EraAccess.java │ │ │ ├── InstantAccess.java │ │ │ ├── InstantLens.java │ │ │ ├── IsoChronologyAccess.java │ │ │ ├── IsoEraAccess.java │ │ │ ├── LocalDateAccess.java │ │ │ ├── LocalDateLens.java │ │ │ ├── LocalDateTimeAccess.java │ │ │ ├── LocalDateTimeLens.java │ │ │ ├── LocalTimeAccess.java │ │ │ ├── LocalTimeLens.java │ │ │ ├── MonthAccess.java │ │ │ ├── MonthLens.java │ │ │ ├── OffsetDateTimeAccess.java │ │ │ ├── OffsetDateTimeLens.java │ │ │ ├── OffsetTimeAccess.java │ │ │ ├── PeriodAccess.java │ │ │ ├── PeriodLens.java │ │ │ ├── TemporalAccess.java │ │ │ ├── TemporalAccessorAccess.java │ │ │ ├── TemporalAdjusterAccess.java │ │ │ ├── TemporalAmountAccess.java │ │ │ ├── TemporalUnitAccess.java │ │ │ ├── TimeDefinitionAccess.java │ │ │ ├── ValueRangeAccess.java │ │ │ ├── ZoneIdAccess.java │ │ │ ├── ZoneIdLens.java │ │ │ ├── ZoneOffsetAccess.java │ │ │ ├── ZoneOffsetLens.java │ │ │ ├── ZoneOffsetTransitionAccess.java │ │ │ ├── ZoneOffsetTransitionLens.java │ │ │ ├── ZoneOffsetTransitionRuleAccess.java │ │ │ ├── ZoneOffsetTransitionRuleLens.java │ │ │ ├── ZoneRulesAccess.java │ │ │ ├── ZonedDateTimeAccess.java │ │ │ └── ZonedDateTimeLens.java │ │ ├── list │ │ ├── AbstractZoomFuncList.java │ │ ├── AsFuncList.java │ │ ├── FuncList.java │ │ ├── FuncListBuilder.java │ │ ├── FuncListDerived.java │ │ ├── FuncListHelper.java │ │ ├── FuncListWithCombine.java │ │ ├── FuncListWithFillNull.java │ │ ├── FuncListWithFilter.java │ │ ├── FuncListWithFlatMap.java │ │ ├── FuncListWithLimit.java │ │ ├── FuncListWithMap.java │ │ ├── FuncListWithMapFirst.java │ │ ├── FuncListWithMapGroup.java │ │ ├── FuncListWithMapMulti.java │ │ ├── FuncListWithMapThen.java │ │ ├── FuncListWithMapToMap.java │ │ ├── FuncListWithMapToTuple.java │ │ ├── FuncListWithMapWithIndex.java │ │ ├── FuncListWithModify.java │ │ ├── FuncListWithPeek.java │ │ ├── FuncListWithPipe.java │ │ ├── FuncListWithSegment.java │ │ ├── FuncListWithSort.java │ │ ├── FuncListWithSplit.java │ │ ├── ImmutableFuncList.java │ │ ├── ReadOnlyList.java │ │ ├── ReadOnlyListException.java │ │ ├── StreamBackedFuncList.java │ │ ├── ZoomFuncList.java │ │ ├── ZoomZoomFuncList.java │ │ ├── doublelist │ │ │ ├── AsDoubleFuncList.java │ │ │ ├── DoubleFuncList.java │ │ │ ├── DoubleFuncListBuilder.java │ │ │ ├── DoubleFuncListDerived.java │ │ │ ├── DoubleFuncListHelper.java │ │ │ ├── DoubleFuncListWithCombine.java │ │ │ ├── DoubleFuncListWithFilter.java │ │ │ ├── DoubleFuncListWithFlatMap.java │ │ │ ├── DoubleFuncListWithLimit.java │ │ │ ├── DoubleFuncListWithMap.java │ │ │ ├── DoubleFuncListWithMapFirst.java │ │ │ ├── DoubleFuncListWithMapGroup.java │ │ │ ├── DoubleFuncListWithMapMulti.java │ │ │ ├── DoubleFuncListWithMapThen.java │ │ │ ├── DoubleFuncListWithMapToMap.java │ │ │ ├── DoubleFuncListWithMapToTuple.java │ │ │ ├── DoubleFuncListWithMapWithIndex.java │ │ │ ├── DoubleFuncListWithModify.java │ │ │ ├── DoubleFuncListWithPeek.java │ │ │ ├── DoubleFuncListWithPipe.java │ │ │ ├── DoubleFuncListWithSegment.java │ │ │ ├── DoubleFuncListWithSort.java │ │ │ ├── DoubleFuncListWithSplit.java │ │ │ ├── ImmutableDoubleFuncList.java │ │ │ └── StreamBackedDoubleFuncList.java │ │ ├── intlist │ │ │ ├── AsIntFuncList.java │ │ │ ├── ImmutableIntFuncList.java │ │ │ ├── IntFuncList.java │ │ │ ├── IntFuncListBuilder.java │ │ │ ├── IntFuncListDerived.java │ │ │ ├── IntFuncListHelper.java │ │ │ ├── IntFuncListWithCombine.java │ │ │ ├── IntFuncListWithFilter.java │ │ │ ├── IntFuncListWithFlatMap.java │ │ │ ├── IntFuncListWithLimit.java │ │ │ ├── IntFuncListWithMap.java │ │ │ ├── IntFuncListWithMapFirst.java │ │ │ ├── IntFuncListWithMapGroup.java │ │ │ ├── IntFuncListWithMapMulti.java │ │ │ ├── IntFuncListWithMapThen.java │ │ │ ├── IntFuncListWithMapToMap.java │ │ │ ├── IntFuncListWithMapToTuple.java │ │ │ ├── IntFuncListWithMapWithIndex.java │ │ │ ├── IntFuncListWithModify.java │ │ │ ├── IntFuncListWithPeek.java │ │ │ ├── IntFuncListWithPipe.java │ │ │ ├── IntFuncListWithSegment.java │ │ │ ├── IntFuncListWithSort.java │ │ │ ├── IntFuncListWithSplit.java │ │ │ └── StreamBackedIntFuncList.java │ │ └── longlist │ │ │ ├── AsLongFuncList.java │ │ │ ├── ImmutableLongFuncList.java │ │ │ ├── LongFuncList.java │ │ │ ├── LongFuncListBuilder.java │ │ │ ├── LongFuncListDerived.java │ │ │ ├── LongFuncListHelper.java │ │ │ ├── LongFuncListWithCombine.java │ │ │ ├── LongFuncListWithFilter.java │ │ │ ├── LongFuncListWithFlatMap.java │ │ │ ├── LongFuncListWithLimit.java │ │ │ ├── LongFuncListWithMap.java │ │ │ ├── LongFuncListWithMapFirst.java │ │ │ ├── LongFuncListWithMapGroup.java │ │ │ ├── LongFuncListWithMapMulti.java │ │ │ ├── LongFuncListWithMapThen.java │ │ │ ├── LongFuncListWithMapToMap.java │ │ │ ├── LongFuncListWithMapToTuple.java │ │ │ ├── LongFuncListWithMapWithIndex.java │ │ │ ├── LongFuncListWithModify.java │ │ │ ├── LongFuncListWithPeek.java │ │ │ ├── LongFuncListWithPipe.java │ │ │ ├── LongFuncListWithSegment.java │ │ │ ├── LongFuncListWithSort.java │ │ │ ├── LongFuncListWithSplit.java │ │ │ └── StreamBackedLongFuncList.java │ │ ├── map │ │ ├── FuncMap.java │ │ ├── FuncMapBuilder.java │ │ ├── FuncMapDerived.java │ │ ├── ImmutableFuncMap.java │ │ ├── MapAction.java │ │ ├── ReadOnlyMap.java │ │ └── ReadOnlyMapException.java │ │ ├── pipeable │ │ ├── Catch.java │ │ ├── NullSafeOperator.java │ │ ├── PipeLine.java │ │ ├── Pipeable.java │ │ └── WhenNull.java │ │ ├── promise │ │ ├── Action.java │ │ ├── ActionAsyncRunner.java │ │ ├── AsyncRunner.java │ │ ├── AsyncRunnerGlobalScope.java │ │ ├── AsyncRunnerNestedScope.java │ │ ├── AsyncRunnerScope.java │ │ ├── AsyncRunnerScopeManaged.java │ │ ├── AsyncRunnerScopeNoScope.java │ │ ├── AsyncRunnerScopeProvider.java │ │ ├── AsyncRunnerScopeProviderFixScope.java │ │ ├── AsyncRunnerScopeProviderGlobal.java │ │ ├── AsyncRunnerScopeProviderNested.java │ │ ├── AsyncRunnerScopeProviderNoScope.java │ │ ├── CombineResult.java │ │ ├── CompletedAction.java │ │ ├── DeferAction.java │ │ ├── DeferActionBuilder.java │ │ ├── DeferActionConfig.java │ │ ├── DeferActionCreator.java │ │ ├── DeferValue.java │ │ ├── DeferValueAlreadyCompletedException.java │ │ ├── DeferValueHelper.java │ │ ├── HasPromise.java │ │ ├── Loop.java │ │ ├── NamedDeferValue.java │ │ ├── NamedPromise.java │ │ ├── OnStart.java │ │ ├── PendingAction.java │ │ ├── Promise.java │ │ ├── PromiseChainAddOn.java │ │ ├── PromiseFilterAddOn.java │ │ ├── PromiseMapAddOn.java │ │ ├── PromisePartiallyFailException.java │ │ ├── PromisePeekAddOn.java │ │ ├── PromiseStatus.java │ │ ├── PromiseStatusAddOn.java │ │ ├── RaceFailedException.java │ │ ├── RaceResult.java │ │ ├── Retry.java │ │ ├── RetryConfig.java │ │ ├── RetryableDeferActionCreator.java │ │ ├── StartableAction.java │ │ ├── SubscriptionHolder.java │ │ ├── SubscriptionRecord.java │ │ ├── UncheckedInterruptedException.java │ │ ├── UncompletedAction.java │ │ ├── Wait.java │ │ ├── WaitAwhile.java │ │ ├── WaitForever.java │ │ ├── WaitOrDefault.java │ │ └── WaitSession.java │ │ ├── ref │ │ ├── ComputeBody.java │ │ ├── DefaultValue.java │ │ ├── DictatedRef.java │ │ ├── Holder.java │ │ ├── ProcessBody.java │ │ ├── Ref.java │ │ ├── RefBuilder.java │ │ ├── RefOf.java │ │ ├── RefTo.java │ │ ├── RetainChecker.java │ │ ├── RetainedRef.java │ │ ├── Run.java │ │ ├── RunBody.java │ │ ├── Substitute.java │ │ ├── Substitution.java │ │ ├── Utils.java │ │ └── WhenAbsent.java │ │ ├── result │ │ ├── Acceptable.java │ │ ├── AsResult.java │ │ ├── AutoCloseableResult.java │ │ ├── DerivedResult.java │ │ ├── Either.java │ │ ├── HasResult.java │ │ ├── Helper.java │ │ ├── NoMoreResultException.java │ │ ├── NullSafePredicate.java │ │ ├── Result.java │ │ ├── ResultCancelledException.java │ │ ├── ResultChainAddOn.java │ │ ├── ResultFilterAddOn.java │ │ ├── ResultMapAddOn.java │ │ ├── ResultNotAvailableException.java │ │ ├── ResultNotExistException.java │ │ ├── ResultNotReadyException.java │ │ ├── ResultPeekAddOn.java │ │ ├── ResultStatus.java │ │ ├── ResultStatusAddOn.java │ │ ├── Specs.java │ │ ├── UnacceptableForUnknownReasonException.java │ │ ├── Validation.java │ │ ├── ValidationException.java │ │ ├── Value.java │ │ └── ValueException.java │ │ ├── stream │ │ ├── ArrayBackedIteratorPlus.java │ │ ├── ArrayBackedStreamPlus.java │ │ ├── AsStreamPlus.java │ │ ├── AsStreamPlusWithCalculate.java │ │ ├── AsStreamPlusWithCollect.java │ │ ├── AsStreamPlusWithConversion.java │ │ ├── AsStreamPlusWithForEach.java │ │ ├── AsStreamPlusWithGroupingBy.java │ │ ├── AsStreamPlusWithMatch.java │ │ ├── AsStreamPlusWithReduce.java │ │ ├── AsStreamPlusWithStatistic.java │ │ ├── AsStreamProcessor.java │ │ ├── BlockingQueueIteratorPlus.java │ │ ├── EnumerationBackedIterator.java │ │ ├── IncompletedSegment.java │ │ ├── IndexedItem.java │ │ ├── IterablePlus.java │ │ ├── IteratorPlus.java │ │ ├── Step.java │ │ ├── StreamBackedIteratorPlus.java │ │ ├── StreamPlus.java │ │ ├── StreamPlusHelper.java │ │ ├── StreamPlusUtils.java │ │ ├── StreamPlusWithCombine.java │ │ ├── StreamPlusWithFillNull.java │ │ ├── StreamPlusWithFilter.java │ │ ├── StreamPlusWithFlatMap.java │ │ ├── StreamPlusWithLimit.java │ │ ├── StreamPlusWithMap.java │ │ ├── StreamPlusWithMapFirst.java │ │ ├── StreamPlusWithMapFlat.java │ │ ├── StreamPlusWithMapGroup.java │ │ ├── StreamPlusWithMapMulti.java │ │ ├── StreamPlusWithMapThen.java │ │ ├── StreamPlusWithMapToMap.java │ │ ├── StreamPlusWithMapToTuple.java │ │ ├── StreamPlusWithMapWithIndex.java │ │ ├── StreamPlusWithModify.java │ │ ├── StreamPlusWithPeek.java │ │ ├── StreamPlusWithPipe.java │ │ ├── StreamPlusWithSegment.java │ │ ├── StreamPlusWithSort.java │ │ ├── StreamPlusWithSplit.java │ │ ├── SupplierBackedIterator.java │ │ ├── ToBigDecimalStreamProcessor.java │ │ ├── ToBigIntegerStreamProcessor.java │ │ ├── ZipWithOption.java │ │ ├── collect │ │ │ ├── Collected.java │ │ │ ├── CollectedToBoolean.java │ │ │ ├── CollectedToDouble.java │ │ │ ├── CollectedToInt.java │ │ │ ├── CollectedToLong.java │ │ │ ├── CollectorExtensible.java │ │ │ ├── CollectorPlus.java │ │ │ ├── CollectorToBooleanPlus.java │ │ │ ├── CollectorToDoublePlus.java │ │ │ ├── CollectorToIntPlus.java │ │ │ ├── CollectorToLongPlus.java │ │ │ ├── DerivedCollectorPlus.java │ │ │ ├── DerivedCollectorToBooleanPlus.java │ │ │ ├── DerivedCollectorToDoublePlus.java │ │ │ ├── DerivedCollectorToIntPlus.java │ │ │ └── DerivedCollectorToLongPlus.java │ │ ├── doublestream │ │ │ ├── ArrayBackedDoubleIteratorPlus.java │ │ │ ├── ArrayBackedDoubleStreamPlus.java │ │ │ ├── AsDoubleStreamPlus.java │ │ │ ├── AsDoubleStreamPlusWithCalculate.java │ │ │ ├── AsDoubleStreamPlusWithCollect.java │ │ │ ├── AsDoubleStreamPlusWithConversion.java │ │ │ ├── AsDoubleStreamPlusWithForEach.java │ │ │ ├── AsDoubleStreamPlusWithGroupingBy.java │ │ │ ├── AsDoubleStreamPlusWithReduce.java │ │ │ ├── AsDoubleStreamPlusWithStatistic.java │ │ │ ├── DoubleIterable.java │ │ │ ├── DoubleIteratorPlus.java │ │ │ ├── DoubleStep.java │ │ │ ├── DoubleStreamPlus.java │ │ │ ├── DoubleStreamPlusHelper.java │ │ │ ├── DoubleStreamPlusWithCombine.java │ │ │ ├── DoubleStreamPlusWithFilter.java │ │ │ ├── DoubleStreamPlusWithFlatMap.java │ │ │ ├── DoubleStreamPlusWithLimit.java │ │ │ ├── DoubleStreamPlusWithMap.java │ │ │ ├── DoubleStreamPlusWithMapFirst.java │ │ │ ├── DoubleStreamPlusWithMapGroup.java │ │ │ ├── DoubleStreamPlusWithMapMulti.java │ │ │ ├── DoubleStreamPlusWithMapThen.java │ │ │ ├── DoubleStreamPlusWithMapToMap.java │ │ │ ├── DoubleStreamPlusWithMapToTuple.java │ │ │ ├── DoubleStreamPlusWithMapWithIndex.java │ │ │ ├── DoubleStreamPlusWithModify.java │ │ │ ├── DoubleStreamPlusWithPeek.java │ │ │ ├── DoubleStreamPlusWithPipe.java │ │ │ ├── DoubleStreamPlusWithSegment.java │ │ │ ├── DoubleStreamPlusWithSort.java │ │ │ ├── DoubleStreamPlusWithSplit.java │ │ │ ├── DoubleSupplierBackedIterator.java │ │ │ ├── GrowOnlyDoubleArray.java │ │ │ ├── IndexedDouble.java │ │ │ ├── StreamBackedDoubleIteratorPlus.java │ │ │ └── collect │ │ │ │ ├── DerivedDoubleCollectorPlus.java │ │ │ │ ├── DerivedDoubleCollectorToBooleanPlus.java │ │ │ │ ├── DerivedDoubleCollectorToDoublePlus.java │ │ │ │ ├── DerivedDoubleCollectorToIntPlus.java │ │ │ │ ├── DerivedDoubleCollectorToLongPlus.java │ │ │ │ ├── DoubleCollected.java │ │ │ │ ├── DoubleCollectedToBoolean.java │ │ │ │ ├── DoubleCollectedToDouble.java │ │ │ │ ├── DoubleCollectedToInt.java │ │ │ │ ├── DoubleCollectedToLong.java │ │ │ │ ├── DoubleCollectorPlus.java │ │ │ │ ├── DoubleCollectorToBooleanPlus.java │ │ │ │ ├── DoubleCollectorToDoublePlus.java │ │ │ │ ├── DoubleCollectorToIntPlus.java │ │ │ │ └── DoubleCollectorToLongPlus.java │ │ ├── intstream │ │ │ ├── ArrayBackedIntIteratorPlus.java │ │ │ ├── ArrayBackedIntStreamPlus.java │ │ │ ├── AsIntStreamPlus.java │ │ │ ├── AsIntStreamPlusWithCalculate.java │ │ │ ├── AsIntStreamPlusWithCollect.java │ │ │ ├── AsIntStreamPlusWithConversion.java │ │ │ ├── AsIntStreamPlusWithForEach.java │ │ │ ├── AsIntStreamPlusWithGroupingBy.java │ │ │ ├── AsIntStreamPlusWithReduce.java │ │ │ ├── AsIntStreamPlusWithStatistic.java │ │ │ ├── CollectorPlusHelper.java │ │ │ ├── GrowOnlyIntArray.java │ │ │ ├── IndexedInt.java │ │ │ ├── IntIterable.java │ │ │ ├── IntIteratorPlus.java │ │ │ ├── IntStep.java │ │ │ ├── IntStreamPlus.java │ │ │ ├── IntStreamPlusHelper.java │ │ │ ├── IntStreamPlusWithCombine.java │ │ │ ├── IntStreamPlusWithFilter.java │ │ │ ├── IntStreamPlusWithFlatMap.java │ │ │ ├── IntStreamPlusWithLimit.java │ │ │ ├── IntStreamPlusWithMap.java │ │ │ ├── IntStreamPlusWithMapFirst.java │ │ │ ├── IntStreamPlusWithMapGroup.java │ │ │ ├── IntStreamPlusWithMapMulti.java │ │ │ ├── IntStreamPlusWithMapThen.java │ │ │ ├── IntStreamPlusWithMapToMap.java │ │ │ ├── IntStreamPlusWithMapToTuple.java │ │ │ ├── IntStreamPlusWithMapWithIndex.java │ │ │ ├── IntStreamPlusWithModify.java │ │ │ ├── IntStreamPlusWithPeek.java │ │ │ ├── IntStreamPlusWithPipe.java │ │ │ ├── IntStreamPlusWithSegment.java │ │ │ ├── IntStreamPlusWithSort.java │ │ │ ├── IntStreamPlusWithSplit.java │ │ │ ├── IntSupplierBackedIterator.java │ │ │ ├── StreamBackedIntIteratorPlus.java │ │ │ └── collect │ │ │ │ ├── DerivedIntCollectorPlus.java │ │ │ │ ├── DerivedIntCollectorToBooleanPlus.java │ │ │ │ ├── DerivedIntCollectorToDoublePlus.java │ │ │ │ ├── DerivedIntCollectorToIntPlus.java │ │ │ │ ├── DerivedIntCollectorToLongPlus.java │ │ │ │ ├── IntCollected.java │ │ │ │ ├── IntCollectedToBoolean.java │ │ │ │ ├── IntCollectedToDouble.java │ │ │ │ ├── IntCollectedToInt.java │ │ │ │ ├── IntCollectedToLong.java │ │ │ │ ├── IntCollectorPlus.java │ │ │ │ ├── IntCollectorToBooleanPlus.java │ │ │ │ ├── IntCollectorToDoublePlus.java │ │ │ │ ├── IntCollectorToIntPlus.java │ │ │ │ └── IntCollectorToLongPlus.java │ │ ├── longstream │ │ │ ├── ArrayBackedLongIteratorPlus.java │ │ │ ├── ArrayBackedLongStreamPlus.java │ │ │ ├── AsLongStreamPlus.java │ │ │ ├── AsLongStreamPlusWithCalculate.java │ │ │ ├── AsLongStreamPlusWithCollect.java │ │ │ ├── AsLongStreamPlusWithConversion.java │ │ │ ├── AsLongStreamPlusWithForEach.java │ │ │ ├── AsLongStreamPlusWithGroupingBy.java │ │ │ ├── AsLongStreamPlusWithReduce.java │ │ │ ├── AsLongStreamPlusWithStatistic.java │ │ │ ├── GrowOnlyLongArray.java │ │ │ ├── IndexedLong.java │ │ │ ├── LongIterable.java │ │ │ ├── LongIteratorPlus.java │ │ │ ├── LongStep.java │ │ │ ├── LongStreamPlus.java │ │ │ ├── LongStreamPlusHelper.java │ │ │ ├── LongStreamPlusWithCombine.java │ │ │ ├── LongStreamPlusWithFilter.java │ │ │ ├── LongStreamPlusWithFlatMap.java │ │ │ ├── LongStreamPlusWithLimit.java │ │ │ ├── LongStreamPlusWithMap.java │ │ │ ├── LongStreamPlusWithMapFirst.java │ │ │ ├── LongStreamPlusWithMapGroup.java │ │ │ ├── LongStreamPlusWithMapMulti.java │ │ │ ├── LongStreamPlusWithMapThen.java │ │ │ ├── LongStreamPlusWithMapToMap.java │ │ │ ├── LongStreamPlusWithMapToTuple.java │ │ │ ├── LongStreamPlusWithMapWithIndex.java │ │ │ ├── LongStreamPlusWithModify.java │ │ │ ├── LongStreamPlusWithPeek.java │ │ │ ├── LongStreamPlusWithPipe.java │ │ │ ├── LongStreamPlusWithSegment.java │ │ │ ├── LongStreamPlusWithSort.java │ │ │ ├── LongStreamPlusWithSplit.java │ │ │ ├── LongSupplierBackedIterator.java │ │ │ ├── StreamBackedLongIteratorPlus.java │ │ │ └── collect │ │ │ │ ├── DerivedLongCollectorPlus.java │ │ │ │ ├── DerivedLongCollectorToBooleanPlus.java │ │ │ │ ├── DerivedLongCollectorToDoublePlus.java │ │ │ │ ├── DerivedLongCollectorToIntPlus.java │ │ │ │ ├── DerivedLongCollectorToLongPlus.java │ │ │ │ ├── LongCollected.java │ │ │ │ ├── LongCollectedToBoolean.java │ │ │ │ ├── LongCollectedToDouble.java │ │ │ │ ├── LongCollectedToInt.java │ │ │ │ ├── LongCollectedToLong.java │ │ │ │ ├── LongCollectorPlus.java │ │ │ │ ├── LongCollectorToBooleanPlus.java │ │ │ │ ├── LongCollectorToDoublePlus.java │ │ │ │ ├── LongCollectorToIntPlus.java │ │ │ │ └── LongCollectorToLongPlus.java │ │ └── markers │ │ │ ├── Eager.java │ │ │ ├── Parallel.java │ │ │ ├── Sequential.java │ │ │ └── Terminal.java │ │ ├── supportive │ │ ├── CallerId.java │ │ └── Default.java │ │ ├── task │ │ ├── Task.java │ │ └── Tasks.java │ │ ├── tuple │ │ ├── DoubleDoubleTuple.java │ │ ├── DoubleTuple2.java │ │ ├── ImmutableTuple.java │ │ ├── ImmutableTuple10.java │ │ ├── ImmutableTuple2.java │ │ ├── ImmutableTuple3.java │ │ ├── ImmutableTuple4.java │ │ ├── ImmutableTuple5.java │ │ ├── ImmutableTuple6.java │ │ ├── ImmutableTuple7.java │ │ ├── ImmutableTuple8.java │ │ ├── ImmutableTuple9.java │ │ ├── IntDoubleTuple.java │ │ ├── IntIntTuple.java │ │ ├── IntIntTupleAccess.java │ │ ├── IntIntTupleLens.java │ │ ├── IntLongTuple.java │ │ ├── IntTuple2.java │ │ ├── IntTuple2Access.java │ │ ├── IntTuple2Lens.java │ │ ├── Keep.java │ │ ├── LongDoubleTuple.java │ │ ├── LongLongTuple.java │ │ ├── LongTuple2.java │ │ ├── ObjDoubleTuple.java │ │ ├── ObjIntTuple.java │ │ ├── ObjLongTuple.java │ │ ├── ToMapFunc.java │ │ ├── ToTuple2Func.java │ │ ├── Tuple.java │ │ ├── Tuple10.java │ │ ├── Tuple2.java │ │ ├── Tuple3.java │ │ ├── Tuple4.java │ │ ├── Tuple5.java │ │ ├── Tuple6.java │ │ ├── Tuple7.java │ │ ├── Tuple8.java │ │ └── Tuple9.java │ │ └── validator │ │ ├── AccessValidator.java │ │ ├── SimpleValidator.java │ │ └── Validator.java │ ├── test │ └── java │ │ └── functionalj │ │ ├── ClosureConstantTest.java │ │ ├── FunctionalJTest.java │ │ ├── TestHelper.java │ │ ├── environments │ │ ├── ConsoleTest.java │ │ └── LogTest.java │ │ ├── event │ │ └── PublishTest.java │ │ ├── function │ │ ├── Func0Test.java │ │ ├── Func1Test.java │ │ ├── Func2Test.java │ │ ├── FuncTest.java │ │ ├── LambdaTest.java │ │ ├── NamedTest.java │ │ ├── TracedConstants.java │ │ ├── TracedTest.java │ │ └── aggregator │ │ │ └── AggregationTest.java │ │ ├── functions │ │ ├── MapToTest.java │ │ └── StrFuncsTest.java │ │ ├── lens │ │ ├── AccessOrXXXTest.java │ │ ├── AccessTest.java │ │ ├── LensTest.java │ │ ├── LensTypeTest.java │ │ ├── ListAccessTest.java │ │ ├── ListLensTest.java │ │ ├── MapAccessTest.java │ │ ├── MapLensTest.java │ │ ├── NullableLensTest.java │ │ ├── NumberAccessTest.java │ │ ├── PrimitiveAccessTest.java │ │ ├── ResultAccessTest.java │ │ ├── StringAccessTest.java │ │ └── lenses │ │ │ ├── DoubleAccessTest.java │ │ │ ├── DoubleToDoubleAccessPrimitiveTest.java │ │ │ ├── FuncListLensTest.java │ │ │ ├── IntegerAccessTest.java │ │ │ ├── IntegerToIntegerAccessPrimitiveTest.java │ │ │ └── time │ │ │ └── TimeLensTest.java │ │ ├── list │ │ ├── DoubleFuncListTest.java │ │ ├── FuncListBuilderTest.java │ │ ├── FuncListModeTest.java │ │ ├── FuncListTest.java │ │ ├── ImmutableFuncListTest.java │ │ ├── IntFuncListTest.java │ │ ├── LongFuncListTest.java │ │ ├── StreamBackedFuncListTest.java │ │ ├── ZoomFuncListTest.java │ │ ├── doublelist │ │ │ ├── DoubleStreamPlusTest.java │ │ │ ├── ImmutableDoubleFuncListTest.java │ │ │ └── StreamBackedDoubleFuncListTest.java │ │ ├── intlist │ │ │ ├── ImmutableIntFuncListTest.java │ │ │ └── StreamBackedIntFuncListTest.java │ │ └── longlist │ │ │ ├── ImmutableLongFuncListTest.java │ │ │ └── StreamBackedLongFuncListTest.java │ │ ├── map │ │ ├── FuncMapBuilderTest.java │ │ ├── FuncMapTest.java │ │ └── ImmutableMapTest.java │ │ ├── pipeable │ │ ├── PipeLineTest.java │ │ └── PipeableTest.java │ │ ├── promise │ │ ├── CombineResultTest.java │ │ ├── DeferActionTest.java │ │ ├── DeferValueTest.java │ │ ├── PromiseCancelTest.java │ │ ├── PromiseScopeTest.java │ │ ├── PromiseTest.java │ │ ├── PromiseWaitTest.java │ │ ├── PromisesTest.java │ │ └── StructuredConcurrenctTest.java │ │ ├── ref │ │ ├── RefTest.java │ │ ├── RefToTest.java │ │ ├── RunTest.java │ │ └── SubstituteTest.java │ │ ├── result │ │ ├── AcceptableTest.java │ │ ├── ResultTest.java │ │ └── ValueTest.java │ │ ├── stream │ │ ├── AsStreamPlusTest.java │ │ ├── BlockingQueueIteratorPlusTest.java │ │ ├── DoubleStepTest.java │ │ ├── GrowOnlyIntArrayTest.java │ │ ├── IntIteratorPlusTest.java │ │ ├── IntStepTest.java │ │ ├── IteratorPlusTest.java │ │ ├── LongStepTest.java │ │ ├── StreamPlusHelperTest.java │ │ ├── StreamPlusTest.java │ │ ├── StreamableHelperTest.java │ │ ├── doublestream │ │ │ └── DoubleStepTest.java │ │ └── longstream │ │ │ └── AsLongStreamPlusWithStatisticTest.java │ │ ├── task │ │ └── TaskTest.java │ │ └── tuple │ │ ├── IntTuple2Test.java │ │ └── Tuple2Test.java │ └── tools │ └── java │ └── functionalj │ └── tuple │ └── TupleMapGenMain.java ├── functionalj-elm ├── .factorypath ├── pom.xml └── src │ ├── main │ ├── java │ │ └── functionalj │ │ │ └── types │ │ │ └── elm │ │ │ ├── Elm.java │ │ │ └── processor │ │ │ ├── DummyMessager.java │ │ │ ├── ElmAnnotationProcessor.java │ │ │ ├── ElmChoiceBuilder.java │ │ │ ├── ElmChoiceSpec.java │ │ │ ├── ElmFunctionBuilder.java │ │ │ ├── ElmStructBuilder.java │ │ │ ├── ElmStructSpec.java │ │ │ ├── ElmType.java │ │ │ ├── ElmTypeDef.java │ │ │ ├── UElmType.java │ │ │ └── Utils.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── javax.annotation.processing.Processor │ └── test │ └── java │ └── functionalj │ └── types │ └── elm │ └── processor │ ├── ElmChoiceBuilderTest.java │ ├── ElmChoiceBuilderWithNullableFieldTest.java │ ├── ElmChoiceTest.java │ ├── ElmStructTest.java │ ├── ElmStructWithNullableFieldTest.java │ └── ElmTypeTest.java ├── functionalj-store ├── pom.xml └── src │ ├── main │ └── java │ │ └── functionalj │ │ └── store │ │ ├── ChangeFailException.java │ │ ├── ChangeNotAllowedException.java │ │ ├── ChangeRejectedException.java │ │ ├── ChangeResult.java │ │ ├── ResultStatus.java │ │ ├── Specs.java │ │ └── Store.java │ └── test │ └── java │ └── functionalj │ └── store │ └── StoreTest.java ├── functionalj-tests-17 ├── .classpath ├── .factorypath ├── .gitignore ├── pom.xml └── src │ ├── .gitignore │ └── test │ ├── .gitignore │ └── java │ └── functionalj │ ├── TestHelper.java │ ├── core │ └── promise │ │ └── PromiseCancel17Test.java │ └── typestests │ ├── choice │ ├── ChioceTypeLinkedListTest.java │ ├── ChoiceToMapFromMapTest.java │ ├── ChoiceToMapTest.java │ ├── ChoiceTypeWithGenericMethodTest.java │ ├── GenerateBasicChoiceTypeTest.java │ ├── NamedLensTest.java │ ├── NestedListTest.java │ └── UnitOfMeasureTest.java │ ├── rule │ └── RuleTest.java │ └── struct │ ├── DOConstructorTest.java │ ├── DOFromClassTest.java │ ├── DOWithSameClassName.java │ ├── DefaultFieldValueTest.java │ ├── FromMapTest.java │ ├── FromMethodTest.java │ ├── GenerateStructAsRecordTest.java │ ├── NamedLensTest.java │ ├── NestedListTest.java │ ├── RecordAsSourceTest.java │ ├── SerializationTest.java │ ├── SimpleStructTest.java │ ├── StructToMapFromMapTest.java │ ├── SubDOTest.java │ ├── ToStringTest.java │ ├── WithFuncListTest.java │ ├── WithFuncMapTest.java │ ├── WithListTest.java │ ├── WithMapTest.java │ ├── WithNullableOptionalTest.java │ └── WithPostConstruct.java ├── functionalj-tests-21 ├── .classpath ├── .factorypath ├── .gitignore ├── pom.xml └── src │ └── test │ └── java │ └── functionalj │ ├── TestHelper.java │ ├── core │ └── promise │ │ └── PromiseCancel21Test.java │ └── typestests │ ├── choice │ └── PatternMatchingTest.java │ └── struct │ └── DeconstructuringTest.java ├── functionalj-types-tests ├── .gitignore ├── pom.xml └── src │ ├── .gitignore │ └── test │ ├── .gitignore │ └── java │ └── functionalj │ └── typestests │ ├── TestHelper.java │ ├── choice │ ├── ChioceTypeLinkedListTest.java │ ├── ChoiceToMapFromMapTest.java │ ├── ChoiceToMapTest.java │ ├── ChoiceTypeWithGenericMethodTest.java │ ├── GenerateBasicChoiceTypeTest.java │ ├── NamedLensTest.java │ ├── NestedListTest.java │ └── UnitOfMeasureTest.java │ ├── rule │ └── RuleTest.java │ └── struct │ ├── DOConstructorTest.java │ ├── DOFromClassTest.java │ ├── DOWithSameClassName.java │ ├── DefaultFieldValueTest.java │ ├── FromMapTest.java │ ├── FromMethodTest.java │ ├── MethodsTest.java │ ├── NamedLensTest.java │ ├── NestedListTest.java │ ├── SerializationTest.java │ ├── SimpleStructTest.java │ ├── StructToMapFromMapTest.java │ ├── SubDOTest.java │ ├── ToStringTest.java │ ├── WithFuncListTest.java │ ├── WithFuncMapTest.java │ ├── WithListTest.java │ ├── WithMapTest.java │ ├── WithNullableOptionalTest.java │ └── WithPostConstruct.java ├── functionalj-types ├── .factorypath ├── out │ └── production │ │ └── resources │ │ └── META-INF │ │ └── services │ │ └── javax.annotation.processing.Processor ├── pom.xml └── src │ ├── main │ ├── java │ │ └── functionalj │ │ │ └── types │ │ │ ├── Absent.java │ │ │ ├── Choice.java │ │ │ ├── ChoiceConversionException.java │ │ │ ├── Core.java │ │ │ ├── DataConversionException.java │ │ │ ├── DefaultTo.java │ │ │ ├── DefaultValue.java │ │ │ ├── Generated.java │ │ │ ├── Generic.java │ │ │ ├── IData.java │ │ │ ├── IPostConstruct.java │ │ │ ├── IRequireTypes.java │ │ │ ├── IRule.java │ │ │ ├── IStruct.java │ │ │ ├── JavaVersionInfo.java │ │ │ ├── Nullable.java │ │ │ ├── OptionalBoolean.java │ │ │ ├── Property.java │ │ │ ├── Required.java │ │ │ ├── Rule.java │ │ │ ├── Self.java │ │ │ ├── Self1.java │ │ │ ├── Self2.java │ │ │ ├── Serialize.java │ │ │ ├── Struct.java │ │ │ ├── StructConversionException.java │ │ │ ├── StructField.java │ │ │ ├── StructToString.java │ │ │ ├── Type.java │ │ │ ├── Utils.java │ │ │ ├── VersionUtils.java │ │ │ ├── choice │ │ │ ├── CheckEquals.java │ │ │ ├── ChoiceAnnotationProcessor.java │ │ │ ├── ChoiceSpec.java │ │ │ ├── ChoiceTypeSwitch.java │ │ │ ├── ChoiceTypes.java │ │ │ ├── IChoice.java │ │ │ └── generator │ │ │ │ ├── CaseLensBuilder.java │ │ │ │ ├── ChoiceLensBuilder.java │ │ │ │ ├── FromMapBuilder.java │ │ │ │ ├── Generator.java │ │ │ │ ├── GetSchemaBuilder.java │ │ │ │ ├── Lines.java │ │ │ │ ├── SchemaBuilder.java │ │ │ │ ├── SourceMethod.java │ │ │ │ ├── SubCheckMethod.java │ │ │ │ ├── SubClass.java │ │ │ │ ├── SubClassConstructor.java │ │ │ │ ├── SubClassDefinition.java │ │ │ │ ├── SubFromMapBuilder.java │ │ │ │ ├── SubSchemaBuilder.java │ │ │ │ ├── SwitchClass.java │ │ │ │ ├── TargetClass.java │ │ │ │ ├── TargetTypeGeneral.java │ │ │ │ ├── ToMapBuilder.java │ │ │ │ ├── Utils.java │ │ │ │ ├── helpers │ │ │ │ └── CaseLensBuilderHelper.java │ │ │ │ └── model │ │ │ │ ├── Case.java │ │ │ │ ├── CaseParam.java │ │ │ │ ├── Method.java │ │ │ │ ├── MethodParam.java │ │ │ │ └── SourceSpec.java │ │ │ ├── input │ │ │ ├── Environment.java │ │ │ ├── InputDeclaredType.java │ │ │ ├── InputElement.java │ │ │ ├── InputMethodElement.java │ │ │ ├── InputPrimitiveType.java │ │ │ ├── InputRecordComponentElement.java │ │ │ ├── InputReferenceType.java │ │ │ ├── InputType.java │ │ │ ├── InputTypeArgument.java │ │ │ ├── InputTypeElement.java │ │ │ ├── InputTypeParameterElement.java │ │ │ ├── InputTypeVariable.java │ │ │ └── InputVariableElement.java │ │ │ ├── rule │ │ │ ├── RuleAnnotationProcessor.java │ │ │ └── RuleSpec.java │ │ │ └── struct │ │ │ ├── SourceKind.java │ │ │ ├── SourceSpecBuilder.java │ │ │ ├── StructAnnotationProcessor.java │ │ │ ├── features │ │ │ └── FeatureSerialization.java │ │ │ └── generator │ │ │ ├── BuilderGenerator.java │ │ │ ├── Callable.java │ │ │ ├── Getter.java │ │ │ ├── IGenerateDefinition.java │ │ │ ├── IGenerateTerm.java │ │ │ ├── ILines.java │ │ │ ├── LensClassBuilder.java │ │ │ ├── Parameter.java │ │ │ ├── SourceSpec.java │ │ │ ├── StructClassSpec.java │ │ │ ├── StructClassSpecBuilder.java │ │ │ ├── StructGeneratorHelper.java │ │ │ ├── StructMapGeneratorHelper.java │ │ │ ├── model │ │ │ ├── Accessibility.java │ │ │ ├── Concrecity.java │ │ │ ├── GenClass.java │ │ │ ├── GenConstructor.java │ │ │ ├── GenDefaultRecordConstructor.java │ │ │ ├── GenField.java │ │ │ ├── GenMethod.java │ │ │ ├── GenParam.java │ │ │ ├── GenStruct.java │ │ │ ├── Modifiability.java │ │ │ ├── Scope.java │ │ │ └── utils.java │ │ │ └── utils.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── javax.annotation.processing.Processor │ └── test │ └── java │ └── functionalj │ └── types │ ├── DefaultValueTest.java │ ├── TestHelper.java │ ├── choice │ └── generator │ │ ├── BasicColor.java │ │ ├── CaseLensGeneratorTest.java │ │ ├── ChoiceTypeExampleTest.java │ │ ├── ChoiceWtihOptionalParameterTest.java │ │ ├── ComplexChoiceTypeTest.java │ │ ├── FirstSubWithOnlyParamTest.java │ │ ├── FullGeneratorTest.java │ │ ├── GeneratorSealedClassTest.java │ │ ├── GeneratorTest.java │ │ ├── GenericChoiceTest.java │ │ ├── GenericSupportTest.java │ │ ├── ListLensTest.java │ │ ├── TypeTest.java │ │ ├── UnitOfMeasureGeneratorTest.java │ │ ├── UtilsTest.java │ │ ├── helpers │ │ └── CaseLensBuilderHelperTest.java │ │ └── model │ │ └── TypeTest.java │ ├── input │ ├── InputMethodElementTest.java │ ├── InputTypeElementTest.java │ └── Tests.java │ ├── rule │ └── RuleSpecTest.java │ └── struct │ ├── generator │ ├── BuildFromSpecTest.java │ ├── BuilderGeneratorTest.java │ ├── DateTimeLensTest.java │ ├── GenerateParentChildTest.java │ ├── GenerateParentFuncListChildTest.java │ ├── GenerateParentListChildTest.java │ ├── GenerateParentMapChildTest.java │ ├── GenerateParentNullableChildTest.java │ ├── GenerateParentOptionalChildTest.java │ ├── GenerateRecordTest.java │ ├── GeneratorTest.java │ ├── ListLensTest.java │ ├── NonPublicConstructorTest.java │ ├── NonRequireFieldTest.java │ ├── RequiredConstructorTest.java │ ├── StructGeneratorHelperTest.java │ └── debug │ │ └── BugThreeNullableBuilder.java │ └── withmock │ └── TestWithMock1.java ├── generated └── elm │ └── Example │ └── Functionalj │ └── Elm │ ├── LoginStatus.elm │ └── User.elm ├── key-var-name ├── mvnw ├── mvnw.cmd ├── pom.xml ├── project-publish-site ├── toolchains.xml ├── version └── version-suffix /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | 3 | name: Java CI with Maven 4 | 5 | on: 6 | push: 7 | branches: [ master, development ] 8 | pull_request: 9 | branches: [ master, development ] 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v3 18 | 19 | - name: Set up JDK 8 20 | id: setup-jdk-8 21 | uses: actions/setup-java@v3 22 | with: 23 | java-version: '8' 24 | distribution: 'adopt' 25 | architecture: 'x64' 26 | 27 | - name: Set JAVA_8_HOME 28 | run: echo "JAVA_8_HOME=$JAVA_HOME_8_X64" >> $GITHUB_ENV 29 | 30 | - name: Set up JDK 17 31 | id: setup-jdk-17 32 | uses: actions/setup-java@v3 33 | with: 34 | java-version: '17' 35 | distribution: 'adopt' 36 | architecture: 'x64' 37 | 38 | - name: Set JAVA_17_HOME 39 | run: echo "JAVA_17_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV 40 | 41 | - name: Set up JDK 21 42 | id: setup-jdk-21 43 | uses: actions/setup-java@v3 44 | with: 45 | java-version: '21' 46 | distribution: 'adopt' 47 | architecture: 'x64' 48 | 49 | - name: Set JAVA_21_HOME 50 | run: echo "JAVA_21_HOME=$JAVA_HOME_21_X64" >> $GITHUB_ENV 51 | 52 | - name: Debug Java Homes 53 | run: | 54 | echo "JAVA_HOME_8_X64: $JAVA_HOME_8_X64" 55 | echo "JAVA_HOME_17_X64: $JAVA_HOME_17_X64" 56 | echo "JAVA_HOME_21_X64: $JAVA_HOME_21_X64" 57 | echo "JAVA_8_HOME: $JAVA_8_HOME" 58 | echo "JAVA_17_HOME: $JAVA_17_HOME" 59 | echo "JAVA_21_HOME: $JAVA_21_HOME" 60 | 61 | - name: Build 62 | run: ./build.sh 63 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Java class files 2 | *.class 3 | 4 | # generated files 5 | bin/ 6 | gen/ 7 | **/generated/ 8 | 9 | # Local configuration file (sdk path, etc) 10 | local.properties 11 | 12 | # Windows thumbnail db 13 | Thumbs.db 14 | 15 | # OSX files 16 | .DS_Store 17 | 18 | # Android Studio 19 | *.iml 20 | .idea 21 | #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. 22 | .gradle 23 | build/ 24 | .navigation 25 | captures/ 26 | output.json 27 | 28 | functionalj-all/dependency-reduced-pom.xml 29 | 30 | target/ 31 | 32 | .project 33 | 34 | .settings/ 35 | 36 | **/.classpath 37 | **/.factorypath 38 | **/pom.xml.versionsBackup 39 | **/.apt_tests/ 40 | **/.apt_generated_tests/ 41 | **/target/ 42 | -------------------------------------------------------------------------------- /.java-version: -------------------------------------------------------------------------------- 1 | 1.8 2 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NawaMan/FunctionalJ/a9dbfe2c6c6b93fa10aefa6562a4295c1e57cc13/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 19 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx4G -Xms100m -Xlog:disable" 3 | } -------------------------------------------------------------------------------- /CODESTYLE: -------------------------------------------------------------------------------- 1 | - Unusual at time 2 | - var to align 3 | - type inference 4 | - duplicate for convinient 5 | - expands var for debug 6 | - expands lambda for debug -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2021 Nawa Manusitthipol 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docs/event.md: -------------------------------------------------------------------------------- 1 | # Event 2 | 3 | 4 | 5 | The intention is to provide an abstraction for event response. 6 | This is similar to those of RxJava. 7 | The different is that, here, the response code SHOULD not have to concern how the event flow was prepared or modified. 8 | Similar to the separation between `DeferAction` and `Promise`, 9 | functional code should not have to care about something like debousing or what thread this will be running. 10 | 11 | Another difference is that `Result<...>` is passed along the reactive flow so that both success/failure are handled uniformly. 12 | 13 | The work on this is still in progress so not much of use. 14 | 15 | 16 | 17 | I will write this -- promise. 18 | 19 | Nawa - 2019-01-08 -------------------------------------------------------------------------------- /docs/pipeable_pipeline.md: -------------------------------------------------------------------------------- 1 | # Pipeable and PipeLine 2 | 3 | ## `Pipeable` 4 | `Pipeable` allows (to a level) us to write fluent like code even if the functions are not the method of the data. 5 | 6 | 7 | ## `Pipeline` 8 | `PipeLine` lets us pre-compose functions into a flow without the input. 9 | For those familiar with functional program, it allow point-free style code. 10 | 11 | I will write more of this -- promise. 12 | 13 | Nawa - 2019-01-08 -------------------------------------------------------------------------------- /docs/ref.md: -------------------------------------------------------------------------------- 1 | # Ref 2 | 3 | Ref allow the creation and sharing of implicit context. 4 | If can be used for dependency injection on the function level (not class-base injection like others). 5 | 6 | 7 | 8 | 9 | I will write more of this -- promise. 10 | 11 | Nawa - 2019-01-08 -------------------------------------------------------------------------------- /docs/result.md: -------------------------------------------------------------------------------- 1 | # Result 2 | 3 | Result is a wrapping component similar in concept as Java 8's `Optional` 4 | but it can hold both data (success) and exception (failure). 5 | Result has many useful methods to handle both cases. 6 | 7 | Result also as methods to handle common state of Promise and Iterator. 8 | 9 | Result is also utilized by Rule type. 10 | 11 | 12 | I will write more of this -- promise. 13 | 14 | Nawa - 2019-01-08 -------------------------------------------------------------------------------- /docs/rule_type.md: -------------------------------------------------------------------------------- 1 | # Rule Type 2 | 3 | Rule types are type with constraint build in so that only the valid instance is allowed. 4 | 5 | 6 | 7 | I will write more of this -- promise. 8 | 9 | Nawa - 2019-01-08 -------------------------------------------------------------------------------- /docs/side_effect.md: -------------------------------------------------------------------------------- 1 | # Side Effect 2 | 3 | `DeferAction`, `Promise` and `IO`. 4 | 5 | 6 | 7 | 8 | 9 | 10 | I will write more of this -- promise. 11 | 12 | Nawa - 2019-01-08 -------------------------------------------------------------------------------- /docs/stream_iterator.md: -------------------------------------------------------------------------------- 1 | # Stream and Iterator 2 | 3 | I will write this -- promise. 4 | 5 | Nawa - 2019-01-08 -------------------------------------------------------------------------------- /docs/youtube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NawaMan/FunctionalJ/a9dbfe2c6c6b93fa10aefa6562a4295c1e57cc13/docs/youtube.png -------------------------------------------------------------------------------- /example/TimeGapExample2.java: -------------------------------------------------------------------------------- 1 | Duration threshold = Duration.ofMinutes(30); 2 | 3 | // Sort by timestamp first if not already sorted 4 | FuncList sortedList = list.sortedBy(obj -> obj.getActionTimestamp()); 5 | 6 | // Group actions that are within threshold of each other 7 | FuncList> segments = sortedList.segmentBetween( 8 | // Start new segment when gap is too large 9 | (current, next) -> Duration.between( 10 | current.getActionTimestamp(), 11 | next.getActionTimestamp() 12 | ).compareTo(threshold) > 0 13 | ); 14 | 15 | // Get gaps between segments 16 | FuncList gaps = segments.pairs() 17 | .map(segmentPair -> new TimeGap( 18 | segmentPair.first().last().getActionTimestamp(), 19 | segmentPair.second().first().getActionTimestamp() 20 | )); -------------------------------------------------------------------------------- /functionalj-all/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | io.functionalj 8 | functionalj 9 | 0.0.1-SNAPSHOT 10 | ../pom.xml 11 | 12 | 13 | functionalj-all 14 | functionalj-all 15 | 16 | The module for combining all FunctionalJ modules. 17 | 18 | 19 | 20 | 21 | io.functionalj 22 | functionalj-core 23 | 24 | 25 | io.functionalj 26 | functionalj-types 27 | 28 | 29 | io.functionalj 30 | functionalj-elm 31 | 32 | 33 | io.functionalj 34 | functionalj-store 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-javadoc-plugin 43 | 44 | 45 | attach-javadocs 46 | 47 | jar 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /functionalj-all/src/main/java/functionalj/FunctionalJAll.java: -------------------------------------------------------------------------------- 1 | package functionalj; 2 | 3 | /** 4 | * Dummy class for functionalj-all package. 5 | */ 6 | public class FunctionalJAll { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /functionalj-all/src/test/java/.empty-dir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NawaMan/FunctionalJ/a9dbfe2c6c6b93fa10aefa6562a4295c1e57cc13/functionalj-all/src/test/java/.empty-dir -------------------------------------------------------------------------------- /functionalj-core/TODO: -------------------------------------------------------------------------------- 1 | 2 | - StoreRef, StoreList, StoreMap 3 | - List lens should has similar interface as FunctionalListLens 4 | - MapBasedDataObject 5 | 6 | Need to organize this and prioritize!!! 7 | 8 | - Find a way to specify what lens for a type. 9 | - Reflection 10 | 11 | Need code clean up!!!!! The code is so shitty :-( 12 | 13 | - Env. 14 | 15 | 16 | TODO 17 | - Struct with Generic 18 | - Check why Elm does not work 19 | - Mutable builder 20 | - Int,Long,Double Streamable (char?) 21 | - Int,Long,Double FuncList (char) 22 | - Fix IntAccess to use applyAsIntFirst 23 | 24 | - IntegerAccess's method that return int should have IntegerToIntegerAccess be primitive to primitive 25 | - Fix IntegerLens .... for primitive to primitive 26 | 27 | 28 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/event/Cancellation.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.event; 25 | 26 | public enum Cancellation { 27 | 28 | Continue, Cancel 29 | } 30 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/event/MainTopic.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.event; 25 | 26 | import static java.util.Objects.requireNonNull; 27 | 28 | public class MainTopic extends Topic { 29 | 30 | private final Publisher publisher; 31 | 32 | public MainTopic(Publisher publisher) { 33 | this.publisher = requireNonNull(publisher); 34 | } 35 | 36 | void done() { 37 | super.done(); 38 | publisher.done(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/exception/ExceptionUtils.java: -------------------------------------------------------------------------------- 1 | package functionalj.exception; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.io.StringWriter; 6 | 7 | import lombok.val; 8 | 9 | public class ExceptionUtils { 10 | 11 | public static String toString(Throwable throwable) { 12 | return toString("", throwable); 13 | } 14 | 15 | public static String toString(String prefix, Throwable throwable) { 16 | val buffer = new StringBuffer(); 17 | buffer.append((prefix != null) ? prefix : ""); 18 | 19 | try (val string = new StringWriter(); 20 | val writer = new PrintWriter(string)) { 21 | throwable.printStackTrace(writer); 22 | buffer.append(throwable.toString()); 23 | buffer.append("\n"); 24 | buffer.append(string.getBuffer().toString()); 25 | } catch (IOException e1) { 26 | e1.printStackTrace(); 27 | } 28 | return buffer.toString(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/exception/InterruptedRuntimeException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.exception; 25 | 26 | import static java.util.Objects.requireNonNull; 27 | 28 | public class InterruptedRuntimeException extends RuntimeException { 29 | 30 | private static final long serialVersionUID = 8712024055767106665L; 31 | 32 | public InterruptedRuntimeException(Exception cause) { 33 | super(requireNonNull(cause)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/exception/WrapThrowable.java: -------------------------------------------------------------------------------- 1 | package functionalj.exception; 2 | 3 | public class WrapThrowable extends Exception { 4 | 5 | private static final long serialVersionUID = 1879586611000403483L; 6 | 7 | public static WrapThrowable of(Throwable throwable) { 8 | if (throwable instanceof WrapThrowable) 9 | return (WrapThrowable) throwable; 10 | if (throwable == null) { 11 | return null; 12 | } 13 | return new WrapThrowable(throwable); 14 | } 15 | 16 | public WrapThrowable(Throwable throwable) { 17 | super(throwable); 18 | } 19 | 20 | public Throwable getThrowable() { 21 | return this.getCause(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/CharSupplier.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface CharSupplier { 28 | 29 | /** 30 | * Gets a result. 31 | * 32 | * @return a result 33 | */ 34 | char getAsChar(); 35 | } 36 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/CharToIntFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface CharToIntFunction { 28 | 29 | /** 30 | * Applies this function to the given argument. 31 | * 32 | * @param value the function argument 33 | * @return the function result 34 | */ 35 | int applyAsInt(char value); 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/Drop.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net) 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | /** 27 | * Intance of this class represent an absent of a parameter in functions. 28 | * 29 | * @author NawaMan -- nawa@nawaman.net 30 | */ 31 | public final class Drop { 32 | 33 | /** 34 | * The drop instance indicating that a parameter is drop. 35 | */ 36 | public static final Drop drop = new Drop(); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/FuncUnit.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | public interface FuncUnit { 27 | 28 | public static FuncUnit0 funcUnit(FuncUnit0 runnable) { 29 | return runnable; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/IntIntToDoubleFunctionPrimitive.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface IntIntToDoubleFunctionPrimitive extends ToDoubleBiIntFunction { 28 | 29 | public int applyAsIntAndInt(int data, int doubleValue); 30 | 31 | public default double applyAsDouble(Integer data, int doubleValue) { 32 | return applyAsIntAndInt(data, doubleValue); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/IntIntToLongFunctionPrimitive.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface IntIntToLongFunctionPrimitive extends ToLongBiIntFunction { 28 | 29 | public int applyAsIntAndInt(int data, int intValue); 30 | 31 | public default double applyAsLong(Integer data, int intValue) { 32 | return applyAsIntAndInt(data, intValue); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/IntLongPredicatePrimitive.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | public interface IntLongPredicatePrimitive { 27 | 28 | public boolean testIntLong(int i1, long i2); 29 | } 30 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/IntLongToIntFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net) 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface IntLongToIntFunction extends Func2 { 28 | 29 | public int applyInt(int input1, long input2); 30 | 31 | @Override 32 | public default Integer applyUnsafe(Integer input1, Long input2) throws Exception { 33 | return applyInt(input1, input2); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/IntToByteFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | public interface IntToByteFunction extends ToByteFunction { 27 | 28 | public default byte apply(Integer i) { 29 | int intValue = i.intValue(); 30 | byte byteValue = applyAsByte(intValue); 31 | return byteValue; 32 | } 33 | 34 | public byte applyAsByte(int i); 35 | } 36 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/IntToCharFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface IntToCharFunction { 28 | 29 | /** 30 | * Applies this function to the given argument. 31 | * 32 | * @param value the function argument 33 | * @return the function result 34 | */ 35 | char applyAsChar(int value); 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/LongBiPredicatePrimitive.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | public interface LongBiPredicatePrimitive { 27 | 28 | public boolean testLongLong(long i1, long i2); 29 | } 30 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/LongLongToIntFunctionPrimitive.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface LongLongToIntFunctionPrimitive extends LongComparator { 28 | 29 | public int applyAsLongAndLong(long data, long longValue); 30 | 31 | public default int applyAsInt(Long data, long longValue) { 32 | return applyAsLongAndLong(data, longValue); 33 | } 34 | 35 | public default int compareLong(long o1, long o2) { 36 | return applyAsLongAndLong(o1, o2); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/ToByteFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | public interface ToByteFunction { 27 | 28 | public byte apply(DATA data); 29 | } 30 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/ToCharBiCharFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface ToCharBiCharFunction { 28 | 29 | public char applyAsChar(DATA data, char charValue); 30 | } 31 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/ToCharFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface ToCharFunction { 28 | 29 | /** 30 | * Applies this function to the given argument. 31 | * 32 | * @param value the function argument 33 | * @return the function result 34 | */ 35 | char applyAsChar(T value); 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/ToDoubleBiIntFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface ToDoubleBiIntFunction { 28 | 29 | public double applyAsDouble(DATA data, int intValue); 30 | } 31 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/ToDoubleBiLongFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface ToDoubleBiLongFunction { 28 | 29 | public double applyAsDouble(DATA data, long longValue); 30 | } 31 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/ToIntBiIntFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface ToIntBiIntFunction { 28 | 29 | public int applyAsInt(DATA data, int intValue); 30 | } 31 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/ToIntBiLongFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface ToIntBiLongFunction { 28 | 29 | public int applyAsInt(DATA data, long intValue); 30 | } 31 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/ToIntegerBiDoubleFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface ToIntegerBiDoubleFunction { 28 | 29 | public int applyAsInt(DATA data, double doubleValue); 30 | } 31 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/ToLongBiIntFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface ToLongBiIntFunction { 28 | 29 | public double applyAsLong(DATA data, int intValue); 30 | } 31 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/function/ToLongBiLongFunction.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | @FunctionalInterface 27 | public interface ToLongBiLongFunction { 28 | 29 | public long applyAsLong(DATA data, long intValue); 30 | } 31 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/functions/LongFuncs.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.functions; 25 | 26 | public class LongFuncs { 27 | 28 | public static long factorial(long value) { 29 | if (value <= 0) { 30 | return 1; 31 | } 32 | long factorial = 1; 33 | for (long i = 1; i <= value; i++) { 34 | factorial *= i; 35 | } 36 | return factorial; 37 | } 38 | // TODO - toBinary 39 | // TODO - toHex 40 | // TODO - toBase 41 | } 42 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/functions/TimeFuncs.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.functions; 25 | 26 | import functionalj.environments.Env; 27 | import functionalj.function.FuncUnit0; 28 | 29 | public class TimeFuncs { 30 | 31 | public static FuncUnit0 Sleep(long millisecond) { 32 | return () -> { 33 | Env.time().sleep(millisecond); 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/TheDouble.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.lens; 25 | 26 | import functionalj.lens.lenses.DoubleToDoubleAccessPrimitive; 27 | 28 | public class TheDouble implements DoubleToDoubleAccessPrimitive { 29 | 30 | public static final TheDouble theDouble = new TheDouble(); 31 | 32 | @Override 33 | public double applyToDouble(double host) { 34 | return host; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/core/AccessCreator.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.lens.core; 25 | 26 | import java.util.function.Function; 27 | import functionalj.lens.lenses.AnyAccess; 28 | 29 | @FunctionalInterface 30 | public interface AccessCreator> { 31 | 32 | public TYPEACCESS newAccess(Function accessToValue); 33 | } 34 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/lenses/BooleanAccessPrimitive.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.lens.lenses; 25 | 26 | @FunctionalInterface 27 | public interface BooleanAccessPrimitive extends BooleanAccess { 28 | 29 | public default Boolean applyUnsafe(HOST host) throws Exception { 30 | return test(host); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/lenses/CharacterAccessPrimitive.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.lens.lenses; 25 | 26 | @FunctionalInterface 27 | public interface CharacterAccessPrimitive extends CharacterAccess { 28 | 29 | public default Character applyUnsafe(HOST host) throws Exception { 30 | return applyAsChar(host); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/lenses/DoubleAccessPrimitive.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.lens.lenses; 25 | 26 | @FunctionalInterface 27 | public interface DoubleAccessPrimitive extends DoubleAccess { 28 | 29 | public default Double applyUnsafe(HOST host) throws Exception { 30 | return applyAsDouble(host); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/lenses/IndexedDoubleAccess.java: -------------------------------------------------------------------------------- 1 | package functionalj.lens.lenses; 2 | 3 | import java.util.function.Function; 4 | 5 | import functionalj.stream.doublestream.IndexedDouble; 6 | 7 | 8 | @FunctionalInterface 9 | public interface IndexedDoubleAccess extends ConcreteAccess> { 10 | 11 | @Override 12 | public default IndexedDoubleAccess newAccess(Function accessToValue) { 13 | return accessToValue::apply; 14 | } 15 | 16 | public default IntegerAccessPrimitive index() { 17 | return (HOST host) -> apply(host).index(); 18 | } 19 | 20 | public default DoubleAccessPrimitive item() { 21 | return (HOST host) -> apply(host).item(); 22 | } 23 | 24 | public default IntegerAccessPrimitive _1() { 25 | return index(); 26 | } 27 | 28 | public default DoubleAccessPrimitive _2() { 29 | return item(); 30 | } 31 | 32 | public default IntegerAccessPrimitive first() { 33 | return index(); 34 | } 35 | 36 | public default DoubleAccessPrimitive second() { 37 | return item(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/lenses/IndexedIntAccess.java: -------------------------------------------------------------------------------- 1 | package functionalj.lens.lenses; 2 | 3 | import java.util.function.Function; 4 | 5 | import functionalj.stream.intstream.IndexedInt; 6 | 7 | 8 | @FunctionalInterface 9 | public interface IndexedIntAccess extends ConcreteAccess> { 10 | 11 | @Override 12 | public default IndexedIntAccess newAccess(Function accessToValue) { 13 | return accessToValue::apply; 14 | } 15 | 16 | public default IntegerAccessPrimitive index() { 17 | return (HOST host) -> apply(host).index(); 18 | } 19 | 20 | public default IntegerAccessPrimitive item() { 21 | return (HOST host) -> apply(host).item(); 22 | } 23 | 24 | public default IntegerAccessPrimitive _1() { 25 | return index(); 26 | } 27 | 28 | public default IntegerAccessPrimitive _2() { 29 | return item(); 30 | } 31 | 32 | public default IntegerAccessPrimitive first() { 33 | return index(); 34 | } 35 | 36 | public default IntegerAccessPrimitive second() { 37 | return item(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/lenses/IndexedLongAccess.java: -------------------------------------------------------------------------------- 1 | package functionalj.lens.lenses; 2 | 3 | import java.util.function.Function; 4 | 5 | import functionalj.stream.longstream.IndexedLong; 6 | 7 | 8 | @FunctionalInterface 9 | public interface IndexedLongAccess extends ConcreteAccess> { 10 | 11 | @Override 12 | public default IndexedLongAccess newAccess(Function accessToValue) { 13 | return accessToValue::apply; 14 | } 15 | 16 | public default IntegerAccessPrimitive index() { 17 | return (HOST host) -> apply(host).index(); 18 | } 19 | 20 | public default LongAccessPrimitive item() { 21 | return (HOST host) -> apply(host).item(); 22 | } 23 | 24 | public default IntegerAccessPrimitive _1() { 25 | return index(); 26 | } 27 | 28 | public default LongAccessPrimitive _2() { 29 | return item(); 30 | } 31 | 32 | public default IntegerAccessPrimitive first() { 33 | return index(); 34 | } 35 | 36 | public default LongAccessPrimitive second() { 37 | return item(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/lenses/IntegerAccessPrimitive.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.lens.lenses; 25 | 26 | @FunctionalInterface 27 | public interface IntegerAccessPrimitive extends IntegerAccess { 28 | 29 | public default Integer applyUnsafe(HOST host) throws Exception { 30 | return applyAsInt(host); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/lenses/LongAccessPrimitive.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.lens.lenses; 25 | 26 | @FunctionalInterface 27 | public interface LongAccessPrimitive extends LongAccess { 28 | 29 | public default Long applyUnsafe(HOST host) throws Exception { 30 | return applyAsLong(host); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/lens/lenses/ObjectAccess.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.lens.lenses; 25 | 26 | import java.util.function.Function; 27 | 28 | @FunctionalInterface 29 | public interface ObjectAccess extends AnyAccess { 30 | 31 | // NOTE: This one thought ... might go. 32 | public default Function linkTo(Function sub) { 33 | return host -> sub.apply(this.apply(host)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/pipeable/NullSafeOperator.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.pipeable; 25 | 26 | import functionalj.function.Func1; 27 | 28 | public interface NullSafeOperator extends Func1 { 29 | 30 | public OUTPUT applyUnsafe(INPUT input) throws Exception; 31 | 32 | public static NullSafeOperator of(Func1 func1) { 33 | return func1::applyUnsafe; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/Action.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | public interface Action { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/ActionAsyncRunner.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | import functionalj.ref.ComputeBody; 4 | import functionalj.ref.Ref; 5 | import functionalj.ref.RunBody; 6 | 7 | /** 8 | * AsyncRunner for Action. 9 | **/ 10 | public class ActionAsyncRunner { 11 | 12 | // TODO : Scoping is an experimental feature. Don't use it yet. 13 | 14 | /** Reference for the provider. **/ 15 | public static final Ref asyncScopeProvider 16 | = Ref.of(AsyncRunnerScopeProvider.class) 17 | .whenAbsentReferTo(AsyncRunnerScopeProvider.asyncScopeProvider) 18 | .defaultTo(AsyncRunnerScopeProvider.noScope); 19 | 20 | public static Promise run(RunBody runnable) { 21 | return run(null, runnable); 22 | } 23 | 24 | public static Promise run(ComputeBody body) { 25 | return run(null, body); 26 | } 27 | 28 | public static Promise run(AsyncRunner runner, RunBody runnable) { 29 | return run(runner, () -> { 30 | runnable.run(); 31 | return null; 32 | }); 33 | } 34 | 35 | public static Promise run(AsyncRunner runner, ComputeBody body) { 36 | return AsyncRunner.run(runner, asyncScopeProvider.get(), body); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/AsyncRunnerGlobalScope.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | import lombok.val; 4 | 5 | public class AsyncRunnerGlobalScope extends AsyncRunnerScopeManaged { 6 | 7 | AsyncRunnerGlobalScope() { 8 | Runtime.getRuntime() 9 | .addShutdownHook(new Thread(() -> { 10 | interruptAll(); 11 | })); 12 | } 13 | 14 | @Override 15 | protected void onBeforeSubAction() { 16 | val currentThread = Thread.currentThread(); 17 | scopedThreads.put(currentThread, currentThread); 18 | } 19 | 20 | @Override 21 | protected void onActionCompleted() { 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/AsyncRunnerNestedScope.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | /** 6 | * This class is a {@link AsyncRunnerScope} that actually manage and clean up the sub actions (runnables). 7 | **/ 8 | public class AsyncRunnerNestedScope extends AsyncRunnerScopeManaged { 9 | 10 | private static final AtomicInteger ID = new AtomicInteger(0); 11 | 12 | private final int id = ID.getAndIncrement(); 13 | 14 | @Override 15 | protected void onActionCompleted() { 16 | interruptAll(); 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "Scope:" + id; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/AsyncRunnerScope.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | import functionalj.ref.Ref; 4 | import functionalj.result.Result; 5 | 6 | /** 7 | * This class represents a runner with might manage its sub action (runnable). 8 | **/ 9 | public abstract class AsyncRunnerScope { 10 | 11 | /** This scope do nothing - Sub runner will not be cleanup. */ 12 | public static final AsyncRunnerScope noScope = new AsyncRunnerScopeNoScope(); 13 | 14 | /** A globally usable local scope is a global scope - async runs in this scope will be cleaned up when shutdown. */ 15 | public static final AsyncRunnerScope global = new AsyncRunnerGlobalScope(); 16 | 17 | /** The scope to use. */ 18 | static Ref asyncScope = Ref.of(AsyncRunnerScope.class).defaultTo(AsyncRunnerScope.noScope); 19 | 20 | /** The current scope. **/ 21 | public static Result currentScope() { 22 | return asyncScope.asResult(); 23 | } 24 | 25 | //== Functionality == 26 | 27 | /** This to be run before a sub action. */ 28 | protected abstract void onBeforeSubAction(); 29 | 30 | /** This to be run when a main action finish. */ 31 | protected abstract void onActionCompleted(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/AsyncRunnerScopeManaged.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | import java.util.concurrent.ConcurrentHashMap; 4 | 5 | import functionalj.environments.Env; 6 | import functionalj.exception.ExceptionUtils; 7 | import lombok.val; 8 | 9 | /** 10 | * AsyncRunnder Scope of this kind will manage its sub runner by interrupting them if the current scope ends. 11 | **/ 12 | public abstract class AsyncRunnerScopeManaged extends AsyncRunnerScope { 13 | 14 | protected final ConcurrentHashMap scopedThreads = new ConcurrentHashMap<>(); 15 | 16 | @Override 17 | protected void onBeforeSubAction() { 18 | val currentThread = Thread.currentThread(); 19 | scopedThreads.put(currentThread, currentThread); 20 | } 21 | 22 | protected final void interruptAll() { 23 | scopedThreads.keySet().forEach(thread -> { 24 | try { 25 | thread.interrupt(); 26 | } catch (Throwable throwable) { 27 | /* Do not expect any exception .... Do nothing but printing. */ 28 | val message = ExceptionUtils.toString("Unexpected exception: ", throwable); 29 | Env.console().errPrintln(message); 30 | } 31 | }); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/AsyncRunnerScopeNoScope.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | /** 4 | * This class is a AsyncRunnerScope that do nothing. 5 | **/ 6 | public class AsyncRunnerScopeNoScope extends AsyncRunnerScope { 7 | 8 | @Override 9 | protected void onBeforeSubAction() { 10 | } 11 | 12 | @Override 13 | protected void onActionCompleted() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/AsyncRunnerScopeProvider.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | import functionalj.function.Func0; 4 | import functionalj.ref.Ref; 5 | 6 | @FunctionalInterface 7 | public interface AsyncRunnerScopeProvider extends Func0 { 8 | 9 | /** Provider for a no-op scope. */ 10 | public static final AsyncRunnerScopeProvider noScope = AsyncRunnerScopeProviderNoScope.instance; 11 | 12 | /** Provider for the global scope. */ 13 | public static final AsyncRunnerScopeProvider global = AsyncRunnerScopeProviderGlobal.instance; 14 | 15 | /** Provider for the global scope. */ 16 | public static final AsyncRunnerScopeProvider nested = AsyncRunnerScopeProviderNested.instance; 17 | 18 | /** Reference for the provider. **/ 19 | public static final Ref asyncScopeProvider 20 | = Ref.of(AsyncRunnerScopeProvider.class).defaultTo(AsyncRunnerScopeProvider.noScope); 21 | 22 | /** Provider for specific scope. */ 23 | public static AsyncRunnerScopeProvider forScope(AsyncRunnerScope scope) { 24 | return forScope(scope.toString(), scope); 25 | } 26 | 27 | /** Provider for specific scope. */ 28 | public static AsyncRunnerScopeProvider forScope(String name, AsyncRunnerScope scope) { 29 | return AsyncRunnerScopeProviderFixScope.forScope(name, scope); 30 | } 31 | 32 | 33 | //== Functionality == 34 | 35 | public AsyncRunnerScope applyUnsafe() throws Exception; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/AsyncRunnerScopeProviderFixScope.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | /** 4 | * Default implementation of {@link AsyncRunnerScopeProvider} which return global scope first and then locals. 5 | */ 6 | public class AsyncRunnerScopeProviderFixScope implements AsyncRunnerScopeProvider { 7 | 8 | /** Provider for specific scope. */ 9 | public static AsyncRunnerScopeProvider forScope(String name, AsyncRunnerScope scope) { 10 | return new AsyncRunnerScopeProvider() { 11 | @Override 12 | public AsyncRunnerScope applyUnsafe() throws Exception { 13 | return scope; 14 | } 15 | @Override 16 | public String toString() { 17 | return name; 18 | } 19 | }; 20 | } 21 | 22 | private final String name; 23 | private final AsyncRunnerScope scope; 24 | 25 | AsyncRunnerScopeProviderFixScope(String name, AsyncRunnerScope scope) { 26 | this.name = (name != null) ? name : scope.toString(); 27 | this.scope = scope; 28 | } 29 | 30 | @Override 31 | public AsyncRunnerScope applyUnsafe() throws Exception { 32 | return scope; 33 | } 34 | @Override 35 | public String toString() { 36 | return name; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/AsyncRunnerScopeProviderGlobal.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | /** 4 | * Default implementation of {@link AsyncRunnerScopeProvider} which return global scope first and then locals. 5 | */ 6 | public class AsyncRunnerScopeProviderGlobal extends AsyncRunnerScopeProviderFixScope { 7 | 8 | /** Provider for the Global. */ 9 | public static final AsyncRunnerScopeProvider instance = new AsyncRunnerScopeProviderGlobal(); 10 | 11 | AsyncRunnerScopeProviderGlobal() { 12 | super("Global", AsyncRunnerScope.global); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/AsyncRunnerScopeProviderNested.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | /** 4 | * Default implementation of {@link AsyncRunnerScopeProvider} which return global scope first and then locals. 5 | */ 6 | public class AsyncRunnerScopeProviderNested implements AsyncRunnerScopeProvider { 7 | 8 | /** Provider for the global scope. */ 9 | public static final AsyncRunnerScopeProvider instance = new AsyncRunnerScopeProviderNested(); 10 | 11 | 12 | AsyncRunnerScopeProviderNested() { 13 | } 14 | 15 | @Override 16 | public AsyncRunnerScope applyUnsafe() throws Exception { 17 | return new AsyncRunnerNestedScope(); 18 | } 19 | @Override 20 | public String toString() { 21 | return "Nested"; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/AsyncRunnerScopeProviderNoScope.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | /** 4 | * Provider that will provide a NoScope scope (unmanaged). 5 | */ 6 | public class AsyncRunnerScopeProviderNoScope extends AsyncRunnerScopeProviderFixScope { 7 | 8 | /** Provider for the NoScope. */ 9 | public static final AsyncRunnerScopeProvider instance = new AsyncRunnerScopeProviderNoScope(); 10 | 11 | 12 | AsyncRunnerScopeProviderNoScope() { 13 | super("NoScope", AsyncRunnerScope.noScope); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/NamedDeferValue.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.promise; 25 | 26 | public class NamedDeferValue extends DeferValue { 27 | 28 | private final String name; 29 | 30 | NamedDeferValue(@SuppressWarnings("rawtypes") Promise parent, String name) { 31 | super(parent); 32 | this.name = name; 33 | } 34 | 35 | public String name() { 36 | return name; 37 | } 38 | 39 | public String toString() { 40 | return name; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/NamedPromise.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.promise; 25 | 26 | public class NamedPromise extends Promise { 27 | 28 | private final String name; 29 | 30 | NamedPromise(@SuppressWarnings("rawtypes") Promise parent, String name) { 31 | super(parent); 32 | this.name = name; 33 | } 34 | 35 | public String toString() { 36 | return name; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/OnStart.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.promise; 25 | 26 | import functionalj.function.FuncUnit0; 27 | 28 | // This interface is used to document the second parameter on DeferAction.run and DeferAction.from. 29 | public interface OnStart extends FuncUnit0 { 30 | 31 | public static final OnStart DoNothing = () -> { 32 | }; 33 | 34 | public static OnStart run(FuncUnit0 runnable) { 35 | if (runnable == null) 36 | return null; 37 | return runnable::run; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/RaceFailedException.java: -------------------------------------------------------------------------------- 1 | package functionalj.promise; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | /** 6 | * Exception thrown when a race operation fails to produce any successful result. 7 | * 8 | *

This exception provides access to the {@link RaceResult} that contains the 9 | * details of the race, allowing further inspection of the outcome.

10 | */ 11 | public class RaceFailedException extends RuntimeException { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | private final RaceResult raceResult; 16 | 17 | /** 18 | * Constructs a new {@code RaceFailedException} with the specified {@link RaceResult}. 19 | * 20 | * @param raceResult the result of the race operation, containing details of the failure 21 | * @throws NullPointerException if {@code raceResult} is {@code null} 22 | */ 23 | public RaceFailedException(RaceResult raceResult) { 24 | super("Race failed to produce any successful result."); 25 | this.raceResult = requireNonNull(raceResult, "RaceResult must be null."); 26 | } 27 | 28 | /** 29 | * Returns the {@link RaceResult} associated with this exception. 30 | * 31 | *

The {@link RaceResult} provides information about the unsuccessful race attempt, 32 | * including any intermediate results or errors encountered.

33 | * 34 | * @param the type of data contained within the {@link RaceResult} 35 | * @return the {@link RaceResult} associated with this exception 36 | */ 37 | @SuppressWarnings("unchecked") 38 | public final RaceResult raceResult() { 39 | return (RaceResult) raceResult; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/promise/UncheckedInterruptedException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.promise; 25 | 26 | 27 | // TODO - Rename this to RuntimeInterruptedException 28 | public class UncheckedInterruptedException extends RuntimeException { 29 | 30 | private static final long serialVersionUID = 4126941862149908606L; 31 | 32 | public UncheckedInterruptedException(InterruptedException cause) { 33 | super(cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/ref/DefaultValue.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.ref; 25 | 26 | public class DefaultValue { 27 | 28 | public static D of(Class clzz) { 29 | return RefTo.defaultProvider.value().get(clzz); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/ref/ProcessBody.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.ref; 25 | 26 | @FunctionalInterface 27 | public interface ProcessBody { 28 | 29 | public OUTPUT process(INPUT input) throws EXCEPTION; 30 | } 31 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/ref/RunBody.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.ref; 25 | 26 | @FunctionalInterface 27 | public interface RunBody { 28 | 29 | public static RunBody from(Runnable runnable) { 30 | return () -> runnable.run(); 31 | } 32 | 33 | public void run() throws EXCEPTION; 34 | } 35 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/ref/Utils.java: -------------------------------------------------------------------------------- 1 | package functionalj.ref; 2 | 3 | class Utils { 4 | 5 | static String name(Class clzz) { 6 | // Check if the class is a common class (String, Integer, etc.) 7 | if (clzz.isPrimitive() || clzz == String.class || clzz == Integer.class || clzz == Double.class 8 | || clzz == Boolean.class || clzz == Character.class || clzz == Byte.class 9 | || clzz == Short.class || clzz == Long.class || clzz == Float.class) { 10 | return clzz.getSimpleName(); 11 | } else { 12 | return clzz.getCanonicalName(); 13 | } 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/result/AsResult.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.result; 25 | 26 | @FunctionalInterface 27 | public interface AsResult extends HasResult { 28 | 29 | public Result asResult(); 30 | 31 | public default Result getResult() { 32 | return asResult(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/result/HasResult.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.result; 25 | 26 | import functionalj.promise.HasPromise; 27 | import functionalj.promise.Promise; 28 | 29 | public interface HasResult extends HasPromise { 30 | 31 | public Result getResult(); 32 | 33 | @SuppressWarnings({ "rawtypes", "unchecked" }) 34 | public default Promise getPromise() { 35 | return (this instanceof Promise) 36 | ? (Promise)this 37 | : Promise.ofResult(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/result/NullSafePredicate.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.result; 25 | 26 | import java.util.function.Predicate; 27 | 28 | public interface NullSafePredicate extends Predicate { 29 | 30 | public boolean test(DATA data); 31 | 32 | public static NullSafePredicate of(Predicate predicate) { 33 | return predicate::test; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/result/ResultCancelledException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.result; 25 | 26 | public class ResultCancelledException extends ResultNotAvailableException { 27 | 28 | private static final long serialVersionUID = 1402992361738590955L; 29 | 30 | ResultCancelledException() { 31 | } 32 | 33 | public ResultCancelledException(String message, Throwable cause) { 34 | super(message, cause); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/result/ResultNotAvailableException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.result; 25 | 26 | public class ResultNotAvailableException extends RuntimeException { 27 | 28 | private static final long serialVersionUID = 8558949802999244614L; 29 | 30 | ResultNotAvailableException() { 31 | } 32 | 33 | ResultNotAvailableException(String message, Throwable cause) { 34 | super(message, cause); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/result/ResultNotExistException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.result; 25 | 26 | public class ResultNotExistException extends ResultNotAvailableException { 27 | 28 | private static final long serialVersionUID = -1710800832797536830L; 29 | 30 | public ResultNotExistException() { 31 | super(); 32 | } 33 | 34 | public ResultNotExistException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/result/ResultNotReadyException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.result; 25 | 26 | public class ResultNotReadyException extends ResultNotAvailableException { 27 | 28 | private static final long serialVersionUID = 7838693114260918473L; 29 | 30 | public ResultNotReadyException() { 31 | super(); 32 | } 33 | 34 | public ResultNotReadyException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/result/UnacceptableForUnknownReasonException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.result; 25 | 26 | public class UnacceptableForUnknownReasonException extends Exception { 27 | 28 | private static final long serialVersionUID = 1361955593036029932L; 29 | 30 | public UnacceptableForUnknownReasonException() { 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/result/ValueException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.result; 25 | 26 | public class ValueException extends RuntimeException { 27 | 28 | private static final long serialVersionUID = -3889275875120914601L; 29 | 30 | private final Object errorValue; 31 | 32 | ValueException(Object errorValue) { 33 | super("Value: " + errorValue); 34 | this.errorValue = errorValue; 35 | } 36 | 37 | public Object getErrorValue() { 38 | return errorValue; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/stream/AsStreamProcessor.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.stream; 25 | 26 | // @FunctionalInterface 27 | // public interface AsStreamProcessor { 28 | // 29 | // public StreamProcessor asStreamProcessor(); 30 | // 31 | // } 32 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/stream/IncompletedSegment.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.stream; 25 | 26 | public enum IncompletedSegment { 27 | 28 | included, excluded 29 | } 30 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/stream/IndexedItem.java: -------------------------------------------------------------------------------- 1 | package functionalj.stream; 2 | 3 | import functionalj.tuple.IntTuple2; 4 | 5 | /** 6 | * An item with index attached to it. 7 | * 8 | * @param the type of the item. 9 | */ 10 | public class IndexedItem extends IntTuple2 { 11 | 12 | public IndexedItem(int index, T data) { 13 | super(index, data); 14 | } 15 | 16 | /** @return the index. */ 17 | public final int index() { 18 | return _1(); 19 | } 20 | 21 | /** @return the item value. */ 22 | public final T item() { 23 | return _2(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/stream/ZipWithOption.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.stream; 25 | 26 | public enum ZipWithOption { 27 | 28 | RequireBoth, AllowUnpaired; 29 | 30 | public boolean isRequireBoth() { 31 | return this == ZipWithOption.RequireBoth; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/stream/doublestream/IndexedDouble.java: -------------------------------------------------------------------------------- 1 | package functionalj.stream.doublestream; 2 | 3 | import functionalj.tuple.IntDoubleTuple; 4 | 5 | /** 6 | * An double item with index attached to it. 7 | */ 8 | public class IndexedDouble extends IntDoubleTuple { 9 | 10 | public IndexedDouble(int index, double data) { 11 | super(index, data); 12 | } 13 | 14 | /** @return the index. */ 15 | public final int index() { 16 | return _1(); 17 | } 18 | 19 | /** @return the item value. */ 20 | public final double item() { 21 | return _2(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/stream/intstream/IndexedInt.java: -------------------------------------------------------------------------------- 1 | package functionalj.stream.intstream; 2 | 3 | import functionalj.tuple.IntIntTuple; 4 | 5 | /** 6 | * An integer item with index attached to it. 7 | */ 8 | public class IndexedInt extends IntIntTuple { 9 | 10 | public IndexedInt(int index, int data) { 11 | super(index, data); 12 | } 13 | 14 | /** @return the index. */ 15 | public final int index() { 16 | return _1(); 17 | } 18 | 19 | /** @return the item value. */ 20 | public final int item() { 21 | return _2(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/stream/longstream/IndexedLong.java: -------------------------------------------------------------------------------- 1 | package functionalj.stream.longstream; 2 | 3 | import functionalj.tuple.IntLongTuple; 4 | 5 | /** 6 | * An long item with index attached to it. 7 | */ 8 | public class IndexedLong extends IntLongTuple { 9 | 10 | public IndexedLong(int index, long data) { 11 | super(index, data); 12 | } 13 | 14 | /** @return the index. */ 15 | public final int index() { 16 | return _1(); 17 | } 18 | 19 | /** @return the item value. */ 20 | public final long item() { 21 | return _2(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/supportive/Default.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.supportive; 25 | 26 | import java.lang.annotation.Retention; 27 | import java.lang.annotation.RetentionPolicy; 28 | 29 | @Retention(RetentionPolicy.RUNTIME) 30 | public @interface Default { 31 | } 32 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/tuple/Keep.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.tuple; 25 | 26 | public final class Keep { 27 | 28 | /** 29 | * The keep instance indicating that a parameter is to be keep as is. 30 | */ 31 | public static final Keep keep = new Keep(); 32 | } 33 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/tuple/ToMapFunc.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.tuple; 25 | 26 | import java.util.Map; 27 | import functionalj.function.Func1; 28 | 29 | @FunctionalInterface 30 | public interface ToMapFunc extends Func1> { 31 | } 32 | -------------------------------------------------------------------------------- /functionalj-core/src/main/java/functionalj/tuple/ToTuple2Func.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.tuple; 25 | 26 | import functionalj.function.Func1; 27 | import functionalj.function.Func2; 28 | 29 | @FunctionalInterface 30 | public interface ToTuple2Func extends Func1> { 31 | 32 | public default Func1 thenReduce(Func2 reducer) { 33 | return this.then(reducer::applyTo); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-core/src/test/java/functionalj/function/NamedTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.function; 25 | 26 | import static org.junit.Assert.assertEquals; 27 | import org.junit.Test; 28 | import lombok.val; 29 | 30 | public class NamedTest { 31 | 32 | @Test 33 | public void test() { 34 | val namedSupplier = Named.Supplier("GetWord", () -> "Hello"); 35 | assertEquals("Supplier::GetWord", namedSupplier.toString()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /functionalj-core/src/test/java/functionalj/function/aggregator/AggregationTest.java: -------------------------------------------------------------------------------- 1 | package functionalj.function.aggregator; 2 | 3 | import static functionalj.TestHelper.assertAsString; 4 | import static functionalj.function.Operators.concat; 5 | import static functionalj.function.Operators.joinWithSpace; 6 | import static functionalj.lens.Access.theString; 7 | 8 | import java.util.stream.Collectors; 9 | 10 | import org.junit.Test; 11 | 12 | import functionalj.function.aggregator.aggregations.Product; 13 | import functionalj.function.aggregator.aggregations.Sum; 14 | import functionalj.list.FuncList; 15 | import lombok.val; 16 | 17 | public class AggregationTest { 18 | 19 | @Test 20 | public void testSumOfStringLength() { 21 | val list = FuncList.of("Hello", "World"); 22 | assertAsString( 23 | "(10,10,10.0,25,HelloWorld,Hello World,[Hello, World])", 24 | list.calculate( 25 | Sum .of(theString.length()), 26 | Sum .of(theString.length().asLong()), 27 | Sum .of(theString.length().asDouble()), 28 | Product .of(theString.length()), 29 | concat .of(theString), 30 | joinWithSpace.of(theString), 31 | Aggregation.from(Collectors.toList()) 32 | ) 33 | ); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-core/src/test/java/functionalj/stream/longstream/AsLongStreamPlusWithStatisticTest.java: -------------------------------------------------------------------------------- 1 | package functionalj.stream.longstream; 2 | 3 | import static functionalj.TestHelper.assertAsString; 4 | import static functionalj.stream.longstream.LongStreamPlus.longs; 5 | 6 | import org.junit.Test; 7 | 8 | public class AsLongStreamPlusWithStatisticTest { 9 | 10 | @Test 11 | public void testMinBy() { 12 | assertAsString("OptionalLong[5]", longs(5L, 40L, 300L, 2000L, 100L).minBy(l -> l)); 13 | assertAsString("OptionalLong[100]", longs(5L, 40L, 300L, 2000L, 100L).minBy(l -> "" + l)); 14 | assertAsString("OptionalLong[2000]", longs(5L, 40L, 300L, 2000L, 100L).minBy(l -> 10 - ("" + l).length())); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /functionalj-elm/.factorypath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /functionalj-elm/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | functionalj.types.elm.processor.ElmAnnotationProcessor 2 | -------------------------------------------------------------------------------- /functionalj-store/src/main/java/functionalj/store/ChangeFailException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.store; 25 | 26 | public class ChangeFailException extends RuntimeException { 27 | 28 | private static final long serialVersionUID = -1774773688354042392L; 29 | 30 | public ChangeFailException(Throwable cause) { 31 | super(cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /functionalj-store/src/main/java/functionalj/store/ChangeNotAllowedException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.store; 25 | 26 | public class ChangeNotAllowedException extends RuntimeException { 27 | 28 | private static final long serialVersionUID = -7003321828486317393L; 29 | } 30 | -------------------------------------------------------------------------------- /functionalj-tests-17/.factorypath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /functionalj-tests-17/.gitignore: -------------------------------------------------------------------------------- 1 | /.apt_generated/ 2 | /.apt_generated_tests/ 3 | -------------------------------------------------------------------------------- /functionalj-tests-17/src/.gitignore: -------------------------------------------------------------------------------- 1 | /main/ 2 | -------------------------------------------------------------------------------- /functionalj-tests-17/src/test/.gitignore: -------------------------------------------------------------------------------- 1 | /generated/ 2 | -------------------------------------------------------------------------------- /functionalj-tests-17/src/test/java/functionalj/typestests/struct/GenerateStructAsRecordTest.java: -------------------------------------------------------------------------------- 1 | package functionalj.typestests.struct; 2 | 3 | import static functionalj.types.DefaultValue.NULL; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import org.junit.Test; 7 | 8 | import functionalj.types.DefaultTo; 9 | import functionalj.types.Nullable; 10 | import functionalj.types.Struct; 11 | 12 | /** 13 | * This test aims to specifically test the generation of struct into record. 14 | * It might repeat with other tests but that is ok. 15 | **/ 16 | public class GenerateStructAsRecordTest { 17 | 18 | @Struct 19 | static boolean CarAsRecordFromMethodSpec(String make, int year, @Nullable @DefaultTo(NULL) String color) { 20 | return true; 21 | } 22 | 23 | @Struct 24 | static interface CarAsRecordFromIntefaceSpec { 25 | String make(); 26 | int year(); 27 | @Nullable @DefaultTo(NULL) String color(); 28 | } 29 | 30 | @Struct(coupleWithDefinition = false) 31 | static abstract class CarAsRecordFromClassSpec { 32 | public abstract String make(); 33 | public abstract int year(); 34 | public abstract @Nullable @DefaultTo(NULL) String color(); 35 | } 36 | 37 | @Struct 38 | static record CarAsRecordFromRecordSpec(String make, int year, @Nullable @DefaultTo(NULL) String color) { 39 | } 40 | 41 | @Test 42 | public void testRecrod() { 43 | assertTrue(CarAsRecordFromMethod.class.isRecord()); 44 | assertTrue(CarAsRecordFromInteface.class.isRecord()); 45 | assertTrue(CarAsRecordFromClass.class.isRecord()); 46 | assertTrue(CarAsRecordFromRecord.class.isRecord()); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /functionalj-tests-17/src/test/java/functionalj/typestests/struct/SerializationTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.typestests.struct; 25 | 26 | public class SerializationTest { 27 | // 28 | // @Struct(serialize = To.MAP) 29 | // static interface DroneSpec { 30 | // int blade(); 31 | // double weight(); 32 | // String color(); 33 | // 34 | // default Map serialize() { 35 | // return null; 36 | // } 37 | // } 38 | // 39 | } 40 | -------------------------------------------------------------------------------- /functionalj-tests-17/src/test/java/functionalj/typestests/struct/WithFuncMapTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.typestests.struct; 25 | 26 | import functionalj.map.FuncMap; 27 | import functionalj.types.Struct; 28 | 29 | public class WithFuncMapTest { 30 | 31 | @Struct(name = "ParentWithFuncMap") 32 | public static interface IParent4 { 33 | 34 | public FuncMap children(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-tests-17/src/test/java/functionalj/typestests/struct/WithListTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.typestests.struct; 25 | 26 | import java.util.List; 27 | import functionalj.types.Struct; 28 | 29 | public class WithListTest { 30 | 31 | @Struct(name = "ParentWithList") 32 | public static interface IParent2 { 33 | 34 | public List names(); 35 | 36 | public List children(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /functionalj-tests-17/src/test/java/functionalj/typestests/struct/WithMapTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.typestests.struct; 25 | 26 | import java.util.Map; 27 | import functionalj.types.Struct; 28 | 29 | public class WithMapTest { 30 | 31 | @Struct(name = "ParentWithMap") 32 | public static interface IParent4 { 33 | 34 | public Map children(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-tests-17/src/test/java/functionalj/typestests/struct/WithNullableOptionalTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.typestests.struct; 25 | 26 | import java.util.Optional; 27 | import functionalj.types.Struct; 28 | import nullablej.nullable.Nullable; 29 | 30 | public class WithNullableOptionalTest { 31 | 32 | @Struct(name = "ParentWithNullableOptional") 33 | public static interface IParent3 { 34 | 35 | public Nullable nullableName(); 36 | 37 | public Optional optionalName(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /functionalj-tests-21/.factorypath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /functionalj-tests-21/.gitignore: -------------------------------------------------------------------------------- 1 | /.apt_generated/ 2 | -------------------------------------------------------------------------------- /functionalj-tests-21/src/test/java/functionalj/typestests/choice/PatternMatchingTest.java: -------------------------------------------------------------------------------- 1 | package functionalj.typestests.choice; 2 | 3 | import static functionalj.TestHelper.assertAsString; 4 | import static functionalj.typestests.choice.MyCommand.Commands; 5 | import static functionalj.typestests.choice.MyCommand.Move; 6 | import static functionalj.typestests.choice.MyCommand.Rotate; 7 | import static java.util.Arrays.asList; 8 | 9 | import java.util.List; 10 | 11 | import org.junit.Test; 12 | 13 | import functionalj.types.Choice; 14 | 15 | public class PatternMatchingTest { 16 | 17 | @Choice 18 | interface MyCommandModel { 19 | 20 | void Rotate(int degree); 21 | 22 | void Move(int distance); 23 | 24 | void Commands(List commands); 25 | } 26 | 27 | @Test 28 | public void testPatternMatching() { 29 | assertAsString("Rotate 45", convertToString(Rotate(45))); 30 | assertAsString("Move 10", convertToString(Move(10))); 31 | assertAsString("Commands [Rotate(45), Move(10)]", convertToString(Commands(asList(Rotate(45), Move(10))))); 32 | } 33 | 34 | private String convertToString(MyCommand myCommand) { 35 | var str = switch (myCommand) { 36 | case Rotate r -> "Rotate " + r.degree(); 37 | case Move m -> "Move " + m.distance(); 38 | case Commands c -> "Commands " + c.commands(); 39 | default -> throw new IllegalArgumentException("Unexpected value: " + myCommand); 40 | }; 41 | return str; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /functionalj-tests-21/src/test/java/functionalj/typestests/struct/DeconstructuringTest.java: -------------------------------------------------------------------------------- 1 | package functionalj.typestests.struct; 2 | 3 | import static functionalj.TestHelper.assertAsString; 4 | import static functionalj.types.DefaultValue.NULL; 5 | 6 | import org.junit.Test; 7 | 8 | import functionalj.types.DefaultTo; 9 | import functionalj.types.Nullable; 10 | import functionalj.types.Struct; 11 | 12 | public class DeconstructuringTest { 13 | 14 | @Struct 15 | static boolean TruckSpec(String make, int year, @Nullable @DefaultTo(NULL) String color) { 16 | return true; 17 | } 18 | 19 | @Test 20 | public void testDeconstructuring() { 21 | var truck = new Truck("Toyota", 2025); 22 | if (truck instanceof Truck(String make, int year, String color)) { 23 | assertAsString("Toyota", make); 24 | assertAsString("2025", year); 25 | assertAsString(null, color); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /functionalj-types-tests/.gitignore: -------------------------------------------------------------------------------- 1 | /.apt_generated/ 2 | /.apt_generated_tests/ 3 | -------------------------------------------------------------------------------- /functionalj-types-tests/src/.gitignore: -------------------------------------------------------------------------------- 1 | /main/ 2 | -------------------------------------------------------------------------------- /functionalj-types-tests/src/test/.gitignore: -------------------------------------------------------------------------------- 1 | /generated/ 2 | -------------------------------------------------------------------------------- /functionalj-types-tests/src/test/java/functionalj/typestests/struct/SerializationTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.typestests.struct; 25 | 26 | public class SerializationTest { 27 | // 28 | // @Struct(serialize = To.MAP) 29 | // static interface DroneSpec { 30 | // int blade(); 31 | // double weight(); 32 | // String color(); 33 | // 34 | // default Map serialize() { 35 | // return null; 36 | // } 37 | // } 38 | // 39 | } 40 | -------------------------------------------------------------------------------- /functionalj-types-tests/src/test/java/functionalj/typestests/struct/WithFuncMapTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.typestests.struct; 25 | 26 | import functionalj.map.FuncMap; 27 | import functionalj.types.Struct; 28 | 29 | public class WithFuncMapTest { 30 | 31 | @Struct(name = "ParentWithFuncMap") 32 | public static interface IParent4 { 33 | 34 | public FuncMap children(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-types-tests/src/test/java/functionalj/typestests/struct/WithListTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.typestests.struct; 25 | 26 | import java.util.List; 27 | import functionalj.types.Struct; 28 | 29 | public class WithListTest { 30 | 31 | @Struct(name = "ParentWithList") 32 | public static interface IParent2 { 33 | 34 | public List names(); 35 | 36 | public List children(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /functionalj-types-tests/src/test/java/functionalj/typestests/struct/WithMapTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.typestests.struct; 25 | 26 | import java.util.Map; 27 | import functionalj.types.Struct; 28 | 29 | public class WithMapTest { 30 | 31 | @Struct(name = "ParentWithMap") 32 | public static interface IParent4 { 33 | 34 | public Map children(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-types-tests/src/test/java/functionalj/typestests/struct/WithNullableOptionalTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.typestests.struct; 25 | 26 | import java.util.Optional; 27 | import functionalj.types.Struct; 28 | import nullablej.nullable.Nullable; 29 | 30 | public class WithNullableOptionalTest { 31 | 32 | @Struct(name = "ParentWithNullableOptional") 33 | public static interface IParent3 { 34 | 35 | public Nullable nullableName(); 36 | 37 | public Optional optionalName(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /functionalj-types/.factorypath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /functionalj-types/out/production/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | functionalj.types.choice.ChoiceAnnotationProcessor 2 | functionalj.types.rule.RuleAnnotationProcessor 3 | functionalj.types.struct.StructAnnotationProcessor -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/ChoiceConversionException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | public class ChoiceConversionException extends RuntimeException { 27 | 28 | private static final long serialVersionUID = -1438488960840238751L; 29 | 30 | public ChoiceConversionException(Throwable cause) { 31 | super(cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/DataConversionException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | public class DataConversionException extends RuntimeException { 27 | 28 | private static final long serialVersionUID = -1438488960840238751L; 29 | 30 | public DataConversionException(@SuppressWarnings("rawtypes") Class clzz) { 31 | super("Non data class: " + clzz); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/DefaultTo.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | import java.lang.annotation.ElementType; 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.lang.annotation.Target; 30 | 31 | @Target({ ElementType.METHOD, ElementType.PARAMETER }) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface DefaultTo { 34 | 35 | public DefaultValue value() default DefaultValue.UNSPECIFIED; 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/IPostConstruct.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net) 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | /** 27 | * Classes implements this interface requires post construct processing. 28 | * 29 | * @author NawaMan -- nawa@nawaman.net 30 | */ 31 | public interface IPostConstruct { 32 | 33 | /** 34 | * This method should be called after a construction. 35 | */ 36 | public void postConstruct(); 37 | } 38 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/IRequireTypes.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net) 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | import java.util.stream.Stream; 27 | 28 | /** 29 | * Classes implementing this interface require other types when generated into code. 30 | * 31 | * @author NawaMan -- nawa@nawaman.net 32 | */ 33 | public interface IRequireTypes { 34 | 35 | /** 36 | * Returns the stream of types that is required. 37 | * 38 | * @return the return types. 39 | */ 40 | public Stream requiredTypes(); 41 | } 42 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/JavaVersionInfo.java: -------------------------------------------------------------------------------- 1 | package functionalj.types; 2 | 3 | public class JavaVersionInfo { 4 | 5 | private final int sourceVersion; 6 | private final int targetVersion; 7 | 8 | public JavaVersionInfo(int sourceVersion, int targetVersion) { 9 | this.sourceVersion = sourceVersion; 10 | this.targetVersion = targetVersion; 11 | } 12 | 13 | public int sourceVersion() { 14 | return sourceVersion; 15 | } 16 | 17 | public int targetVersion() { 18 | return targetVersion; 19 | } 20 | 21 | public int minVersion() { 22 | return Math.min(targetVersion, sourceVersion); 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "Source Version: " + sourceVersion + ", Target Version: " + targetVersion; 28 | } 29 | 30 | public String toCode() { 31 | return "new functionalj.types.JavaVersionInfo(" + sourceVersion + ", " + targetVersion + ")"; 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/Nullable.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | import java.lang.annotation.ElementType; 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.lang.annotation.Target; 30 | 31 | @Target({ ElementType.METHOD, ElementType.PARAMETER }) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface Nullable { 34 | } 35 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/OptionalBoolean.java: -------------------------------------------------------------------------------- 1 | package functionalj.types; 2 | 3 | public enum OptionalBoolean { 4 | 5 | TRUE, 6 | FALSE, 7 | WHATEVER; 8 | 9 | @Override 10 | public String toString() { 11 | return this.getClass().getCanonicalName() + "." + this.name(); 12 | } 13 | 14 | public Boolean toBoolean() { 15 | return (this == WHATEVER) ? null : (this == TRUE); 16 | } 17 | 18 | public static Boolean toBoolean(OptionalBoolean optBoolean) { 19 | return (optBoolean == null) ? null : optBoolean.toBoolean(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/Required.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | import java.lang.annotation.ElementType; 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.lang.annotation.Target; 30 | 31 | @Target({ ElementType.METHOD, ElementType.PARAMETER }) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface Required { 34 | } 35 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/Serialize.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net) 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | public interface Serialize { 27 | 28 | public static enum To { 29 | NOTHING, 30 | BOOLEAN, 31 | INT, 32 | LONG, 33 | DOUBLE, 34 | STRING, 35 | LIST, 36 | MAP 37 | } 38 | 39 | public T serialize(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/StructConversionException.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | public class StructConversionException extends RuntimeException { 27 | 28 | private static final long serialVersionUID = -2967836785655525439L; 29 | 30 | public StructConversionException(Throwable cause) { 31 | super(cause); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/StructField.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | public class StructField { 27 | 28 | public final String name; 29 | 30 | public final Type type; 31 | 32 | public final DefaultValue defaultValue; 33 | 34 | public StructField(String name, Type type, DefaultValue defaultValue) { 35 | this.name = name; 36 | this.type = type; 37 | this.defaultValue = defaultValue; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/StructToString.java: -------------------------------------------------------------------------------- 1 | package functionalj.types; 2 | 3 | /** 4 | * Configuration about the toString() method. 5 | **/ 6 | public enum StructToString { 7 | 8 | /** Do not generate toString method. */ 9 | None, 10 | 11 | /** 12 | * Let FunctionaJ choose. That is Custom if toStringTemplate given, Legacy for JDK older than 17 and Record for 17 and newer. 13 | */ 14 | Default, 15 | 16 | /** Use Java record toString format Point[x=3. y=4] */ 17 | Record, 18 | 19 | /** Use Legacy FunctionaJ Struct toString format Point[x: 3. y: 4] */ 20 | Legacy, 21 | 22 | /** Use Custom template format */ 23 | Template 24 | 25 | } 26 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/Utils.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types; 25 | 26 | public class Utils { 27 | 28 | public static String blankToNull(String sourceSpec) { 29 | return ((sourceSpec == null) || sourceSpec.trim().isEmpty()) ? null : sourceSpec; 30 | } 31 | 32 | public static String emptyToNull(String sourceSpec) { 33 | return ((sourceSpec == null) || sourceSpec.isEmpty()) ? null : sourceSpec; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/VersionUtils.java: -------------------------------------------------------------------------------- 1 | package functionalj.types; 2 | 3 | import java.util.Optional; 4 | 5 | import javax.annotation.processing.ProcessingEnvironment; 6 | 7 | public class VersionUtils { 8 | 9 | public static JavaVersionInfo getJavaVersionInfo(ProcessingEnvironment processingEnv) { 10 | // 1. Try to get custom options (e.g., -Asource=17 -Atarget=17) 11 | String sourceOption = processingEnv.getOptions().get("source"); 12 | String targetOption = processingEnv.getOptions().get("target"); 13 | 14 | // 2. Extract the source version from options or fall back to the ProcessingEnvironment 15 | int sourceVersion = parseVersion(Optional.ofNullable(sourceOption) 16 | .orElse(processingEnv.getSourceVersion().name().replace("RELEASE_", ""))); 17 | 18 | // 3. Extract the target version from options or fall back to the system JDK version 19 | int targetVersion = parseVersion( 20 | Optional.ofNullable(targetOption).orElse(System.getProperty("java.specification.version"))); 21 | 22 | return new JavaVersionInfo(sourceVersion, targetVersion); 23 | } 24 | 25 | private static int parseVersion(String version) { 26 | try { 27 | return "1.8".equals(version) ? 8 : Integer.parseInt(version); 28 | } catch (NumberFormatException e) { 29 | System.err.println("Failed to parse version: " + version); 30 | return -1; 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/choice/ChoiceTypes.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types.choice; 25 | 26 | public class ChoiceTypes { 27 | 28 | private ChoiceTypes() { 29 | } 30 | 31 | public static S Match(IChoice choiceType) { 32 | return choiceType.match(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /functionalj-types/src/main/java/functionalj/types/struct/SourceKind.java: -------------------------------------------------------------------------------- 1 | package functionalj.types.struct; 2 | 3 | public enum SourceKind { 4 | METHOD, 5 | INTERFACE, 6 | CLASS, 7 | RECORD; 8 | 9 | @Override 10 | public String toString() { 11 | return SourceKind.class.getCanonicalName() + "." + this.name(); 12 | } 13 | 14 | public boolean isClass() { 15 | return this == CLASS; 16 | } 17 | 18 | public boolean isInterface() { 19 | return this == INTERFACE; 20 | } 21 | 22 | public boolean isRecord() { 23 | return this == RECORD; 24 | } 25 | 26 | public boolean isMethod() { 27 | return this == METHOD; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /functionalj-types/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | functionalj.types.choice.ChoiceAnnotationProcessor 2 | functionalj.types.rule.RuleAnnotationProcessor 3 | functionalj.types.struct.StructAnnotationProcessor -------------------------------------------------------------------------------- /functionalj-types/src/test/java/functionalj/types/choice/generator/model/TypeTest.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types.choice.generator.model; 25 | 26 | import static org.junit.Assert.assertEquals; 27 | import org.junit.Test; 28 | import functionalj.types.Type; 29 | 30 | public class TypeTest { 31 | 32 | @Test 33 | public void testPredicateType() { 34 | assertEquals("java.lang.Integer", Type.INTEGER.toString()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /functionalj-types/src/test/java/functionalj/types/struct/generator/StructGeneratorHelperTest.java: -------------------------------------------------------------------------------- 1 | package functionalj.types.struct.generator; 2 | 3 | import static functionalj.types.struct.generator.StructGeneratorHelper.reqOnlyConstBody; 4 | import static java.util.stream.Collectors.joining; 5 | import static org.junit.Assert.assertEquals; 6 | 7 | import java.util.Arrays; 8 | import java.util.List; 9 | import java.util.stream.Stream; 10 | 11 | import org.junit.Test; 12 | 13 | import functionalj.types.DefaultValue; 14 | import functionalj.types.Type; 15 | 16 | public class StructGeneratorHelperTest { 17 | 18 | @Test 19 | public void testReqOnlyConstBody() { 20 | Getter getter1 = new Getter("field1", Type.STRING); 21 | Getter getter2 = new Getter("field2", Type.BIGDECIMAL, false, DefaultValue.ZERO); 22 | Getter getter3 = new Getter("field3", Type.INT); 23 | 24 | List getters = Arrays.asList(getter1, getter2, getter3); 25 | Stream validate = Stream.empty(); 26 | String body = reqOnlyConstBody(getters, validate).stream().collect(joining("\n")); 27 | assertEquals( 28 | "this($utils.notNull(field1), java.math.BigDecimal.ZERO, $utils.notNull(field3));\n" 29 | + "if (IPostConstruct.class.isInstance(this)) IPostConstruct.class.cast(this).postConstruct();", 30 | body); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /functionalj-types/src/test/java/functionalj/types/struct/withmock/TestWithMock1.java: -------------------------------------------------------------------------------- 1 | // ============================================================================ 2 | // Copyright (c) 2017-2025 Nawapunth Manusitthipol (NawaMan - http://nawaman.net). 3 | // ---------------------------------------------------------------------------- 4 | // MIT License 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | // SOFTWARE. 23 | // ============================================================================ 24 | package functionalj.types.struct.withmock; 25 | 26 | public class TestWithMock1 { 27 | } 28 | -------------------------------------------------------------------------------- /generated/elm/Example/Functionalj/Elm/User.elm: -------------------------------------------------------------------------------- 1 | module Example.Functionalj.Elm.User exposing 2 | ( User 3 | , userEncoder 4 | , userDecoder 5 | , encodeUser 6 | , decodeUser 7 | , userListEncoder 8 | , userListDecoder 9 | , encodeUserList 10 | , decodeUserList 11 | ) 12 | 13 | import Json.Decode 14 | import Json.Decode.Pipeline 15 | import Json.Encode 16 | 17 | 18 | -- elm install elm/json 19 | -- elm install NoRedInk/elm-json-decode-pipeline 20 | 21 | type alias User = 22 | { firstName : String 23 | , lastName : String 24 | } 25 | 26 | 27 | userEncoder : User -> Json.Encode.Value 28 | userEncoder user = 29 | Json.Encode.object 30 | [ ( "firstName", Json.Encode.string user.firstName ) 31 | , ( "lastName", Json.Encode.string user.lastName ) 32 | ] 33 | 34 | 35 | userDecoder : Json.Decode.Decoder User 36 | userDecoder = 37 | Json.Decode.succeed User 38 | |> Json.Decode.Pipeline.required "firstName" Json.Decode.string 39 | |> Json.Decode.Pipeline.required "lastName" Json.Decode.string 40 | 41 | 42 | encodeUser : User -> Int -> String 43 | encodeUser user indent = 44 | userEncoder user |> Json.Encode.encode indent 45 | 46 | 47 | decodeUser : String -> Result Json.Decode.Error User 48 | decodeUser = 49 | Json.Decode.decodeString userDecoder 50 | 51 | 52 | userListEncoder : List User -> Json.Encode.Value 53 | userListEncoder userList = 54 | Json.Encode.list userEncoder userList 55 | 56 | 57 | userListDecoder : Json.Decode.Decoder (List User) 58 | userListDecoder = 59 | Json.Decode.list userDecoder 60 | 61 | 62 | encodeUserList : List User -> Int -> String 63 | encodeUserList userList indent = 64 | userListEncoder userList |> Json.Encode.encode indent 65 | 66 | 67 | decodeUserList : String -> Result Json.Decode.Error (List User) 68 | decodeUserList = 69 | Json.Decode.decodeString userListDecoder 70 | -------------------------------------------------------------------------------- /key-var-name: -------------------------------------------------------------------------------- 1 | FUNCTIONALJ_KEYNAME -------------------------------------------------------------------------------- /project-publish-site: -------------------------------------------------------------------------------- 1 | https://oss.sonatype.org/ -------------------------------------------------------------------------------- /toolchains.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | jdk 4 | 5 | 1.8 6 | oracle 7 | 8 | 9 | ${env.JAVA_8_HOME} 10 | 11 | 12 | 13 | jdk 14 | 15 | 17 16 | oracle 17 | 18 | 19 | ${env.JAVA_17_HOME} 20 | 21 | 22 | 23 | jdk 24 | 25 | 21 26 | oracle 27 | 28 | 29 | ${env.JAVA_21_HOME} 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- 1 | 1.0.25 -------------------------------------------------------------------------------- /version-suffix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NawaMan/FunctionalJ/a9dbfe2c6c6b93fa10aefa6562a4295c1e57cc13/version-suffix --------------------------------------------------------------------------------