Skip to content

Commit

Permalink
Incrementing version.
Browse files Browse the repository at this point in the history
  • Loading branch information
nomemory authored and Ciobanu, Andrei-Nicolin (UK - EDC) committed May 11, 2017
1 parent 7a83b1e commit e83a252
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions src/main/java/net/andreinc/mockneat/interfaces/MockUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ public interface MockUnit<T> {
// Functional Method
Supplier<T> supplier();

/**
* It's a 'closing' method that returns an arbitrary value of type 'T'.
*
* @return the exact value mocked by the MockUnit<T> . The value is of type <T>.
*/
default T val() { return supplier().get(); }


Expand All @@ -62,13 +57,6 @@ default T valOrElse(T alternateVal) {
return result;
}

/**
* Serialize an arbitary object generated by the MockUnit<T> to the disk.
* T should implement Serializable.
*
* @param strPath The path where the file is written to disk.
*
*/
// TODO Document
default void serialize(String strPath) {
T object = supplier().get();
Expand All @@ -80,47 +68,20 @@ default void serialize(String strPath) {
catch (FileNotFoundException e) { throw new UncheckedIOException(e); }
}

/**
* It's a closing method that returns an arbitray value of type <T>
*
* @param function The function that is applied to the final value before being returned.
* @param <R> The Returning type of the the applied Function<T, R>.
* @return
*/
default <R> R val(Function<T, R> function) {
notNull(function, "function");
return function.apply(supplier().get());
}

/**
* Consumes the returning value (of type <T>).
* So instead of returning the arbitrary value generated by the MockUnit<T>,
* this is getting consumed.
*
* @param consumer The consumer method.
*/
default void consume(Consumer<T> consumer) {
notNull(consumer, "consumer");
consumer.accept(val());
}

/**
* Returns the toString() representation of the arbitrary data generated by the MockUnit<T>.
* If the generated value is NULL, the default "" - empty string is generated.
*
* @return the toString() representation value of the data generated by the MockUnit<T>.
*/
default String valStr() {
return valStr("");
}

/**
* Retuns the toString() representation of the arbitrary genrated by the MockUnit<T>.
* If the generated value is NULL it's replaced with a default String value.
*
* @param valueIfNull The default value that is returned if the generated value is null.
* @return the toString() representation value of the data generated by the MockUnit<T>.
*/
default String valStr(String valueIfNull) {
Object val = supplier().get();
if (null == val) {
Expand All @@ -129,13 +90,6 @@ default String valStr(String valueIfNull) {
return val.toString();
}

/**
* This method is used to transform the existing MockUnit<T> mock unit into
* an MockUnit<R> through the function received as parameter (Function<T,R>).
*
* @param function The transforming function.
* @return
*/
default <R> MockUnit<R> map(Function<T, R> function) {
notNull(function, "function");
Supplier<R> supp = () -> function.apply(supplier().get());
Expand Down

0 comments on commit e83a252

Please sign in to comment.