Resolves checkstyle errors for trampoline twin typeobjectpattern unit-of-work value-object (#1074)
* Reduces checkstyle errors in trampoline * Reduces checkstyle errors in twin * Reduces checkstyle errors in typeobjectpattern * Reduces checkstyle errors in unit-of-work * Reduces checkstyle errors in value-object
This commit is contained in:
committed by
Ilkka Seppälä
parent
b92eb5229d
commit
f0f0143d48
@ -26,12 +26,14 @@ package com.iluwatar.trampoline;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* <p>Trampoline pattern allows to define recursive algorithms by iterative loop </p>
|
||||
* Trampoline pattern allows to define recursive algorithms by iterative loop.
|
||||
*
|
||||
* <p>When get is called on the returned Trampoline, internally it will iterate calling ‘jump’
|
||||
* on the returned Trampoline as long as the concrete instance returned is {@link #more(Trampoline)},
|
||||
* stopping once the returned instance is {@link #done(Object)}.</p>
|
||||
* on the returned Trampoline as long as the concrete instance returned is {@link
|
||||
* #more(Trampoline)}, stopping once the returned instance is {@link #done(Object)}.
|
||||
*
|
||||
* <p>Essential we convert looping via recursion into iteration,
|
||||
* the key enabling mechanism is the fact that {@link #more(Trampoline)} is a lazy operation.</p>
|
||||
* the key enabling mechanism is the fact that {@link #more(Trampoline)} is a lazy operation.
|
||||
*
|
||||
* @param <T> is type for returning result.
|
||||
*/
|
||||
@ -40,6 +42,8 @@ public interface Trampoline<T> {
|
||||
|
||||
|
||||
/**
|
||||
* Jump to next stage.
|
||||
*
|
||||
* @return next stage
|
||||
*/
|
||||
default Trampoline<T> jump() {
|
||||
@ -52,6 +56,8 @@ public interface Trampoline<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if complete.
|
||||
*
|
||||
* @return true if complete
|
||||
*/
|
||||
default boolean complete() {
|
||||
@ -59,7 +65,7 @@ public interface Trampoline<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Created a completed Trampoline
|
||||
* Created a completed Trampoline.
|
||||
*
|
||||
* @param result Completed result
|
||||
* @return Completed Trampoline
|
||||
@ -70,7 +76,7 @@ public interface Trampoline<T> {
|
||||
|
||||
|
||||
/**
|
||||
* Create a Trampoline that has more work to do
|
||||
* Create a Trampoline that has more work to do.
|
||||
*
|
||||
* @param trampoline Next stage in Trampoline
|
||||
* @return Trampoline with more work
|
||||
|
@ -23,20 +23,21 @@
|
||||
|
||||
package com.iluwatar.trampoline;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* <p>Trampoline pattern allows to define recursive algorithms by iterative loop </p>
|
||||
* <p>it is possible to implement algorithms recursively in Java without blowing the stack
|
||||
* and to interleave the execution of functions without hard coding them together or even using threads.</p>
|
||||
* Trampoline pattern allows to define recursive algorithms by iterative loop.
|
||||
*
|
||||
* <p>It is possible to implement algorithms recursively in Java without blowing the stack
|
||||
* and to interleave the execution of functions without hard coding them together or even using
|
||||
* threads.
|
||||
*/
|
||||
@Slf4j
|
||||
public class TrampolineApp {
|
||||
|
||||
/**
|
||||
* Main program for showing pattern. It does loop with factorial function.
|
||||
* */
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
log.info("start pattern");
|
||||
Integer result = loop(10, 1).result();
|
||||
|
Reference in New Issue
Block a user