Skip to content

Commit cd43caf

Browse files
javaqueryVicky Thakor
authored andcommitted
fix: code format
1 parent 94a0aef commit cd43caf

File tree

3 files changed

+31
-29
lines changed

3 files changed

+31
-29
lines changed

src/main/java/com/javaquery/util/io/Files.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public static <T extends File> boolean createNewFile(T file) {
5959
* successfully created; <code>false</code> if the named file
6060
* already exists
6161
*/
62-
public static <T extends File> boolean deleteAndCreateNewFile(T file){
62+
public static <T extends File> boolean deleteAndCreateNewFile(T file) {
6363
Assert.nonNull(file, NullPointerException::new);
64-
if(file.exists()){
64+
if (file.exists()) {
6565
file.delete();
6666
}
6767
return createNewFile(file);
@@ -77,10 +77,10 @@ public static <T extends File> boolean deleteAndCreateNewFile(T file){
7777
* @param data data to write to file
7878
* @param <T>
7979
*/
80-
public static <T extends File> void writeToFile(T file, String data){
80+
public static <T extends File> void writeToFile(T file, String data) {
8181
Assert.nonNull(file, NullPointerException::new);
8282
Assert.nonNull(data, NullPointerException::new);
83-
if(!file.exists()){
83+
if (!file.exists()) {
8484
createNewFile(file);
8585
}
8686
try {
@@ -96,16 +96,16 @@ public static <T extends File> void writeToFile(T file, String data){
9696
* Note: This method will also creates new <code>file</code> if not exist.
9797
* Exception is logged not thrown.
9898
*
99-
* @param file file to write
100-
* @param data data to append to file
99+
* @param file file to write
100+
* @param data data to append to file
101101
* @param appendNewLine <code>true</code> to append new line at the end of data
102102
* otherwise <code>false</code>.
103103
* @param <T>
104104
*/
105-
public static <T extends File> void appendToFile(T file, String data, boolean appendNewLine){
105+
public static <T extends File> void appendToFile(T file, String data, boolean appendNewLine) {
106106
Assert.nonNull(file, NullPointerException::new);
107107
Assert.nonNull(data, NullPointerException::new);
108-
if(!file.exists()){
108+
if (!file.exists()) {
109109
createNewFile(file);
110110
}
111111
data = appendNewLine ? (data + "\n") : data;
@@ -125,9 +125,9 @@ public static <T extends File> void appendToFile(T file, String data, boolean ap
125125
* @param <T>
126126
* @return String data of file if exists otherwise <code>null</code>
127127
*/
128-
public static <T extends File> String readFromFile(T file){
128+
public static <T extends File> String readFromFile(T file) {
129129
Assert.nonNull(file, NullPointerException::new);
130-
if(file.exists()){
130+
if (file.exists()) {
131131
try {
132132
return new String(java.nio.file.Files.readAllBytes(getPath(file)));
133133
} catch (IOException | InvalidPathException e) {
@@ -137,24 +137,35 @@ public static <T extends File> String readFromFile(T file){
137137
return null;
138138
}
139139

140+
/**
141+
* Path of file provided
142+
*
143+
* @param file file to get {@link Path}.
144+
* @param <T>
145+
* @return {@link Path} of file
146+
*/
147+
private static <T extends File> Path getPath(T file) {
148+
return Paths.get(file.getAbsolutePath());
149+
}
150+
140151
/**
141152
* Read any file from resources folder of project.
142153
* For example, read demo.json from provided path `resources folder` <code>/sample/demo.json</code>
143154
*
144155
* @param path path to resource
145156
* @return String data of file if exists otherwise <code>null</code>
146157
*/
147-
public String loadResource(String path){
158+
public String loadResource(String path) {
148159
Assert.nonNull(path, NullPointerException::new);
149-
if(!path.trim().isEmpty()){
150-
try(
151-
InputStream inputStream = getClass().getResourceAsStream(path);
152-
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))
153-
){
160+
if (!path.trim().isEmpty()) {
161+
try (
162+
InputStream inputStream = getClass().getResourceAsStream(path);
163+
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))
164+
) {
154165
String fileLine;
155166
StringBuilder stringBuilder = new StringBuilder();
156167

157-
while((fileLine = bufferedReader.readLine())!= null){
168+
while ((fileLine = bufferedReader.readLine()) != null) {
158169
stringBuilder.append(fileLine);
159170
}
160171
return stringBuilder.toString();
@@ -164,15 +175,4 @@ public String loadResource(String path){
164175
}
165176
return null;
166177
}
167-
168-
/**
169-
* Path of file provided
170-
*
171-
* @param file file to get {@link Path}.
172-
* @param <T>
173-
* @return {@link Path} of file
174-
*/
175-
private static <T extends File> Path getPath(T file){
176-
return Paths.get(file.getAbsolutePath());
177-
}
178178
}

src/main/java/com/javaquery/util/string/Strings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public final class Strings {
1414

1515
private final static String UNSUPPORTED_ASCII_PATTERN = "[^\\x20-\\x7e]";
1616
private final static String UNSUPPORTED_UNICODE_PATTERN = "[\\uD83C-\\uDBFF\\uDC00-\\uDFFF]+";
17+
1718
private Strings() {
1819
}
1920

src/main/java/com/javaquery/util/time/Dates.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public final class Dates {
1616

1717
public static final TimeZone SYSTEM_TIMEZONE = TimeZone.getDefault();
1818
private static final Calendar CALENDAR = Calendar.getInstance();
19+
1920
private Dates() {
2021
}
2122

@@ -222,8 +223,8 @@ public enum Month {
222223
JANUARY(1), FEBRUARY(2), MARCH(3), APRIL(4), MAY(5), JUNE(6), JULY(7), AUGUST(8), SEPTEMBER(9), OCTOBER(10), NOVEMBER(
223224
11), DECEMBER(12);
224225

225-
private int value;
226226
private final static Calendar calendar = Calendar.getInstance();
227+
private int value;
227228

228229
Month(int value) {
229230
this.value = value;

0 commit comments

Comments
 (0)