#1021 enforce Checkstyle rules in the build
This commit is contained in:
@ -22,8 +22,6 @@
|
||||
*/
|
||||
|
||||
package com.iluwatar.promise;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -32,10 +30,12 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* The Promise object is used for asynchronous computations. A Promise represents an operation
|
||||
* that hasn't completed yet, but is expected in the future.
|
||||
* The Promise object is used for asynchronous computations. A Promise represents an operation
|
||||
* that hasn't completed yet, but is expected in the future.
|
||||
*
|
||||
* <p>A Promise represents a proxy for a value not necessarily known when the promise is created. It
|
||||
* allows you to associate dependent promises to an asynchronous action's eventual success value or
|
||||
@ -49,15 +49,14 @@ import java.util.concurrent.Executors;
|
||||
* <li> Prevents callback hell and provides callback aggregation
|
||||
* </ul>
|
||||
*
|
||||
* <p>
|
||||
* In this application the usage of promise is demonstrated with two examples:
|
||||
* <p>In this application the usage of promise is demonstrated with two examples:
|
||||
* <ul>
|
||||
* <li>Count Lines: In this example a file is downloaded and its line count is calculated.
|
||||
* The calculated line count is then consumed and printed on console.
|
||||
* <li>Lowest Character Frequency: In this example a file is downloaded and its lowest frequency
|
||||
* character is found and printed on console. This happens via a chain of promises, we start with
|
||||
* a file download promise, then a promise of character frequency, then a promise of lowest frequency
|
||||
* character which is finally consumed and result is printed on console.
|
||||
* a file download promise, then a promise of character frequency, then a promise of lowest
|
||||
* frequency character which is finally consumed and result is printed on console.
|
||||
* </ul>
|
||||
*
|
||||
* @see CompletableFuture
|
||||
@ -76,7 +75,7 @@ public class App {
|
||||
}
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* Program entry point.
|
||||
* @param args arguments
|
||||
* @throws InterruptedException if main thread is interrupted.
|
||||
* @throws ExecutionException if an execution error occurs.
|
||||
|
@ -23,9 +23,6 @@
|
||||
|
||||
package com.iluwatar.promise;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
@ -39,8 +36,11 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Utility to perform various operations
|
||||
* Utility to perform various operations.
|
||||
*/
|
||||
public class Utility {
|
||||
|
||||
@ -71,7 +71,8 @@ public class Utility {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the character with lowest frequency if it exists, {@code Optional.empty()} otherwise.
|
||||
* Return the character with the lowest frequency, if exists.
|
||||
* @return the character, {@code Optional.empty()} otherwise.
|
||||
*/
|
||||
public static Character lowestFrequencyChar(Map<Character, Integer> charFrequency) {
|
||||
Character lowestFrequencyChar = null;
|
||||
@ -92,7 +93,8 @@ public class Utility {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of lines in the file at provided location. 0 if file does not exist.
|
||||
* Count the number of lines in a file.
|
||||
* @return number of lines, 0 if file does not exist.
|
||||
*/
|
||||
public static Integer countLines(String fileLocation) {
|
||||
int lineCount = 0;
|
||||
|
Reference in New Issue
Block a user