Skip to content

Commit

Permalink
docs: add java docs
Browse files Browse the repository at this point in the history
  • Loading branch information
stawirej committed Dec 22, 2023
1 parent 07d6690 commit 19601ad
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
package pl.amazingcode.threadscollider.exceptions;

/**
* Exception thrown when {@link pl.amazingcode.threadscollider.single.ThreadsCollider} or {@link
* pl.amazingcode.threadscollider.multi.MultiThreadsCollider} fails.
*/
public final class ThreadsColliderFailure extends RuntimeException {

private ThreadsColliderFailure(Throwable cause) {

super(cause);
}

/**
* Creates new instance of {@link ThreadsColliderFailure}.
*
* @param cause cause of failure
* @return new instance of {@link ThreadsColliderFailure}
*/
public static ThreadsColliderFailure from(Throwable cause) {

return new ThreadsColliderFailure(cause);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package pl.amazingcode.threadscollider.multi;

/** Builder for mandatory action. */
/** Intermediary builder for {@link MultiThreadsCollider}. */
public interface MandatoryActionBuilder {

/**
* Set action to be executed.
*
* @param action action to be executed
* @return builder
* @return {@link TimesBuilder}
*/
TimesBuilder withAction(Runnable action);
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package pl.amazingcode.threadscollider.multi;

import java.util.function.Consumer;
import pl.amazingcode.threadscollider.single.OptionalBuilder;
import pl.amazingcode.threadscollider.single.ThreadsCollider;
import pl.amazingcode.threadscollider.single.TimeUnitBuilder;

/** Intermediary builder for {@link ThreadsCollider}. */
/** Intermediary builder for {@link MultiThreadsCollider}. */
public interface MultiOptionalBuilder {

/**
* Sets exception consumer for threads. This consumer will be called for each exception thrown by
* threads. Consumer will be called in thread safe manner.
*
* @param threadsExceptionsConsumer - exception consumer for threads.
* @return {@link OptionalBuilder}
* @return {@link MultiOptionalBuilder}
*/
MultiOptionalBuilder withThreadsExceptionsConsumer(Consumer<Exception> threadsExceptionsConsumer);

Expand All @@ -22,14 +20,14 @@ public interface MultiOptionalBuilder {
*
* @param timeout - await termination timeout for executor service used by {@link
* ThreadsCollider}.
* @return {@link TimeUnitBuilder}
* @return {@link MultiTimeUnitBuilder}
*/
MultiTimeUnitBuilder withAwaitTerminationTimeout(long timeout);

/**
* Builds {@link ThreadsCollider}.
* Builds {@link MultiThreadsCollider}.
*
* @return {@link ThreadsCollider}
* @return {@link MultiThreadsCollider}
*/
MultiThreadsCollider build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ private MultiThreadsColliderBuilder() {
this.times = new ArrayList<>();
}

/**
* Creates new instance of {@link MultiThreadsColliderBuilder}.
*
* @return {@link MultiThreadsColliderBuilder}
*/
public static MandatoryActionBuilder multiThreadsCollider() {

return new MultiThreadsColliderBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,39 @@

import java.util.function.Consumer;

/** Intermediary builder for {@link MultiThreadsCollider}. */
public interface OptionalActionBuilder {

/**
* Sets action to be executed by {@link MultiThreadsCollider}.
*
* @param action action to be executed by {@link MultiThreadsCollider}
* @return {@link TimesBuilder}
*/
TimesBuilder withAction(Runnable action);

/**
* Sets await termination timeout for executor service used by {@link MultiThreadsCollider}.
*
* @param timeout await termination timeout for executor service used by {@link
* MultiThreadsCollider}
* @return {@link MultiOptionalBuilder}
*/
MultiTimeUnitBuilder withAwaitTerminationTimeout(long timeout);

/**
* Sets exception consumer for threads. This consumer will be called for each exception thrown by
* threads. Consumer will be called in thread safe manner.
*
* @param threadsExceptionsConsumer - exception consumer for threads.
* @return {@link MultiOptionalBuilder}
*/
MultiOptionalBuilder withThreadsExceptionsConsumer(Consumer<Exception> threadsExceptionsConsumer);

/**
* Builds {@link MultiThreadsCollider}.
*
* @return {@link MultiThreadsCollider}
*/
MultiThreadsCollider build();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package pl.amazingcode.threadscollider.multi;

/** Intermediary builder for {@link MultiThreadsCollider}. */
public interface TimesBuilder {

/**
* Sets number of times to repeat action.
*
* @param times number of times to repeat action
* @return {@link OptionalActionBuilder}
*/
OptionalActionBuilder times(int times);
}

0 comments on commit 19601ad

Please sign in to comment.