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";
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;
- }
-
}
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
return this;
}
+
/**
* Cut given amount of characters from the left of the string.
*
return this;
}
- public String2 trimPrefixIfExists(String prefix){
+ public String2 trimPrefixIfExists(String prefix) {
if (prefix == null)
return this;
return this;
}
- public String2 trimSuffixIfExists(String suffix){
+ public String2 trimSuffixIfExists(String suffix) {
if (hasSuffix(suffix))
trimSuffix(suffix.length());
public String2 trimSuffix(int charsToTrim) {
- if (charsToTrim > chars.size()){
+ if (charsToTrim > chars.size()) {
chars.clear();
return this;
}
- for (int i = 0; i<charsToTrim; i++)
- chars.remove(chars.size()-1);
+ for (int i = 0; i < charsToTrim; i++)
+ chars.remove(chars.size() - 1);
return this;
}
return contains(suffix, getLength() - suffix.length());
}
- public boolean hasPrefix(String prefix){
+ public boolean hasPrefix(String prefix) {
return contains(prefix, 0);
}
- public boolean contains(String fragment, int index){
+ public boolean contains(String fragment, int index) {
if (index + fragment.length() > chars.size())
return false;
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
Parser parser;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
parser = new Parser();
}
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
/*
* 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.
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
+ <output url="file://$MODULE_DIR$/target/classes" />
+ <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.8.1" level="project" />
+ <orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
+ </component>
+</module>
\ No newline at end of file