import static com.google.common.base.Preconditions.checkState;
import com.google.common.io.CharStreams;
-import com.google.common.io.Files;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import net.sourceforge.argparse4j.annotation.Arg;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
+import org.opendaylight.yangtools.yang.common.YangConstants;
@SuppressFBWarnings({"DM_EXIT", "DM_DEFAULT_ENCODING"})
public class TesttoolParameters {
try {
final String correctName = correctedName(file);
if (correctName != null) {
- Files.move(file, new File(correctName));
+ Files.move(file.toPath(), Paths.get(correctName), StandardCopyOption.ATOMIC_MOVE);
}
} catch (final IOException e) {
// print error to console (test tool is running from console)
}
if (line != null) {
final Matcher m = REVISION_DATE_PATTERN.matcher(line);
- checkState(m.find());
+ checkState(m.find(), "Revision pattern %s did not match line %s", REVISION_DATE_PATTERN, line);
String moduleName = file.getAbsolutePath();
- if (file.getName().endsWith(".yang")) {
+ if (file.getName().endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION)) {
moduleName = moduleName.substring(0, moduleName.length() - 5);
}
- final String revision = m.group(1);
- return moduleName + "@" + revision + ".yang";
+
+ return moduleName + "@" + m.group(1) + YangConstants.RFC6020_YANG_FILE_EXTENSION;
}
}
return null;
final String editContentString;
try {
if (stream == null) {
- editContentString = Files.asCharSource(editContent, StandardCharsets.UTF_8).read();
+ editContentString = Files.readString(editContent.toPath());
} else {
editContentString = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
}