From b8bd1e820265fc15c39c1ee8c06289ea8b8e2c1c Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Tue, 26 Dec 2017 17:01:42 +0200 Subject: [PATCH] Code formatting. --- .../parameter/FileParameter.java | 44 +++++++++---------- .../commons/data/EnhancedDataInputStream.java | 2 +- .../data/EnhancedDataOutputStream.java | 2 +- .../svjatoslav/commons/data/HexConverter.java | 2 +- .../commons/file/FilePathParser.java | 2 +- .../eu/svjatoslav/commons/string/String2.java | 15 ++++--- .../tokenizer/InvalidSyntaxException.java | 2 +- .../commons/string/tokenizer/Terminator.java | 2 +- .../commons/string/tokenizer/Tokenizer.java | 2 +- .../string/tokenizer/TokenizerMatch.java | 2 +- .../parameterparser/ParserTest.java | 2 +- .../commons/data/HexConverterTest.java | 2 +- .../commons/file/CommonPathResolverTest.java | 2 +- .../svjatoslav/commons/file/IOHelperTest.java | 2 +- .../commons/string/String2Test.java | 2 +- .../commons/string/WildCardMatcherTest.java | 2 +- svjatoslavcommons.iml | 16 +++++++ 17 files changed, 60 insertions(+), 43 deletions(-) create mode 100644 svjatoslavcommons.iml diff --git a/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/parameter/FileParameter.java b/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/parameter/FileParameter.java index 21a84ff..b827fee 100755 --- a/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/parameter/FileParameter.java +++ b/src/main/java/eu/svjatoslav/commons/commandline/parameterparser/parameter/FileParameter.java @@ -22,6 +22,28 @@ public class FileParameter extends Parameter { super(description, ArgumentCount.SINGLE); } + protected static boolean validateFile(ExistenceType existenceType, String value) { + final File file = new File(value); + + if (existenceType == ExistenceType.MUST_EXIST) { + return file.exists() && file.isFile(); + } + + if (existenceType == ExistenceType.MUST_NOT_EXIST) { + return !file.exists(); + } + + if (existenceType == ExistenceType.DOES_NOT_MATTER) { + if (file.exists()) + if (file.isDirectory()) + return false; + + return true; + } + + return false; + } + @Override public java.lang.String describeFormat() { return existenceType.description + " file"; @@ -52,26 +74,4 @@ public class FileParameter extends Parameter { return validateFile(existenceType, value); } - protected static boolean validateFile(ExistenceType existenceType, String value) { - final File file = new File(value); - - if (existenceType == ExistenceType.MUST_EXIST) { - return file.exists() && file.isFile(); - } - - if (existenceType == ExistenceType.MUST_NOT_EXIST) { - return !file.exists(); - } - - if (existenceType == ExistenceType.DOES_NOT_MATTER) { - if (file.exists()) - if (file.isDirectory()) - return false; - - return true; - } - - return false; - } - } diff --git a/src/main/java/eu/svjatoslav/commons/data/EnhancedDataInputStream.java b/src/main/java/eu/svjatoslav/commons/data/EnhancedDataInputStream.java index 77cd97e..04ec9ff 100755 --- a/src/main/java/eu/svjatoslav/commons/data/EnhancedDataInputStream.java +++ b/src/main/java/eu/svjatoslav/commons/data/EnhancedDataInputStream.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/main/java/eu/svjatoslav/commons/data/EnhancedDataOutputStream.java b/src/main/java/eu/svjatoslav/commons/data/EnhancedDataOutputStream.java index a74c522..c84d2da 100755 --- a/src/main/java/eu/svjatoslav/commons/data/EnhancedDataOutputStream.java +++ b/src/main/java/eu/svjatoslav/commons/data/EnhancedDataOutputStream.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/main/java/eu/svjatoslav/commons/data/HexConverter.java b/src/main/java/eu/svjatoslav/commons/data/HexConverter.java index d4aaec1..9ff9ef7 100755 --- a/src/main/java/eu/svjatoslav/commons/data/HexConverter.java +++ b/src/main/java/eu/svjatoslav/commons/data/HexConverter.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/main/java/eu/svjatoslav/commons/file/FilePathParser.java b/src/main/java/eu/svjatoslav/commons/file/FilePathParser.java index caf0d29..296db74 100755 --- a/src/main/java/eu/svjatoslav/commons/file/FilePathParser.java +++ b/src/main/java/eu/svjatoslav/commons/file/FilePathParser.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/main/java/eu/svjatoslav/commons/string/String2.java b/src/main/java/eu/svjatoslav/commons/string/String2.java index b6083ed..9fb7baf 100755 --- a/src/main/java/eu/svjatoslav/commons/string/String2.java +++ b/src/main/java/eu/svjatoslav/commons/string/String2.java @@ -49,6 +49,7 @@ public class String2 { return this; } + /** * Cut given amount of characters from the left of the string. * @@ -67,7 +68,7 @@ public class String2 { return this; } - public String2 trimPrefixIfExists(String prefix){ + public String2 trimPrefixIfExists(String prefix) { if (prefix == null) return this; @@ -77,7 +78,7 @@ public class String2 { return this; } - public String2 trimSuffixIfExists(String suffix){ + public String2 trimSuffixIfExists(String suffix) { if (hasSuffix(suffix)) trimSuffix(suffix.length()); @@ -86,13 +87,13 @@ public class String2 { public String2 trimSuffix(int charsToTrim) { - if (charsToTrim > chars.size()){ + if (charsToTrim > chars.size()) { chars.clear(); return this; } - for (int i = 0; i chars.size()) return false; diff --git a/src/main/java/eu/svjatoslav/commons/string/tokenizer/InvalidSyntaxException.java b/src/main/java/eu/svjatoslav/commons/string/tokenizer/InvalidSyntaxException.java index e63c035..2a62a33 100755 --- a/src/main/java/eu/svjatoslav/commons/string/tokenizer/InvalidSyntaxException.java +++ b/src/main/java/eu/svjatoslav/commons/string/tokenizer/InvalidSyntaxException.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/main/java/eu/svjatoslav/commons/string/tokenizer/Terminator.java b/src/main/java/eu/svjatoslav/commons/string/tokenizer/Terminator.java index 8dc20ac..0c42a74 100755 --- a/src/main/java/eu/svjatoslav/commons/string/tokenizer/Terminator.java +++ b/src/main/java/eu/svjatoslav/commons/string/tokenizer/Terminator.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/main/java/eu/svjatoslav/commons/string/tokenizer/Tokenizer.java b/src/main/java/eu/svjatoslav/commons/string/tokenizer/Tokenizer.java index c80aeb1..1407732 100755 --- a/src/main/java/eu/svjatoslav/commons/string/tokenizer/Tokenizer.java +++ b/src/main/java/eu/svjatoslav/commons/string/tokenizer/Tokenizer.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/main/java/eu/svjatoslav/commons/string/tokenizer/TokenizerMatch.java b/src/main/java/eu/svjatoslav/commons/string/tokenizer/TokenizerMatch.java index f005bc1..5dc5a89 100755 --- a/src/main/java/eu/svjatoslav/commons/string/tokenizer/TokenizerMatch.java +++ b/src/main/java/eu/svjatoslav/commons/string/tokenizer/TokenizerMatch.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/test/java/eu/svjatoslav/commons/commandline/parameterparser/ParserTest.java b/src/test/java/eu/svjatoslav/commons/commandline/parameterparser/ParserTest.java index f792e10..ff5452b 100755 --- a/src/test/java/eu/svjatoslav/commons/commandline/parameterparser/ParserTest.java +++ b/src/test/java/eu/svjatoslav/commons/commandline/parameterparser/ParserTest.java @@ -25,7 +25,7 @@ public class ParserTest { Parser parser; @Before - public void setUp() throws Exception { + public void setUp() { parser = new Parser(); } diff --git a/src/test/java/eu/svjatoslav/commons/data/HexConverterTest.java b/src/test/java/eu/svjatoslav/commons/data/HexConverterTest.java index 50b802b..a7a2025 100755 --- a/src/test/java/eu/svjatoslav/commons/data/HexConverterTest.java +++ b/src/test/java/eu/svjatoslav/commons/data/HexConverterTest.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/test/java/eu/svjatoslav/commons/file/CommonPathResolverTest.java b/src/test/java/eu/svjatoslav/commons/file/CommonPathResolverTest.java index 84eee59..4b5e4a1 100755 --- a/src/test/java/eu/svjatoslav/commons/file/CommonPathResolverTest.java +++ b/src/test/java/eu/svjatoslav/commons/file/CommonPathResolverTest.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/test/java/eu/svjatoslav/commons/file/IOHelperTest.java b/src/test/java/eu/svjatoslav/commons/file/IOHelperTest.java index d23943f..b03a3e5 100755 --- a/src/test/java/eu/svjatoslav/commons/file/IOHelperTest.java +++ b/src/test/java/eu/svjatoslav/commons/file/IOHelperTest.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/test/java/eu/svjatoslav/commons/string/String2Test.java b/src/test/java/eu/svjatoslav/commons/string/String2Test.java index adc14a8..0e31c82 100755 --- a/src/test/java/eu/svjatoslav/commons/string/String2Test.java +++ b/src/test/java/eu/svjatoslav/commons/string/String2Test.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/src/test/java/eu/svjatoslav/commons/string/WildCardMatcherTest.java b/src/test/java/eu/svjatoslav/commons/string/WildCardMatcherTest.java index 6537fbc..ce2f2f6 100755 --- a/src/test/java/eu/svjatoslav/commons/string/WildCardMatcherTest.java +++ b/src/test/java/eu/svjatoslav/commons/string/WildCardMatcherTest.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. diff --git a/svjatoslavcommons.iml b/svjatoslavcommons.iml new file mode 100644 index 0000000..526b60f --- /dev/null +++ b/svjatoslavcommons.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.20.1