Skip to content

Commit

Permalink
[WIP] Update dependencies, small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
andrebrait committed May 18, 2024
1 parent 957f2db commit e0a4a11
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -447,7 +448,7 @@ private static Stream<FileCopier.Spec> simpleCopyOrExtractionStream(
.from(m.getResult().getArchivePath())
.to(baseDir.resolve(m.getRom().getName()))
.build())
.collect(ImmutableSet.toImmutableSet()))
.collect(ImmutableMap.toImmutableMap(FileCopier.ExtractionSpec.InternalSpec::getFrom, Function.identity(), (a, b) -> a)))
.build());
}
});
Expand Down Expand Up @@ -489,7 +490,7 @@ private static Stream<FileCopier.CompressionSpec> buildCompressionSpecs(
List<ScanResultMatcher.RomMatch> forCompression = matches
.stream()
.filter(m -> m.getResult().getArchiveType() == null)
.collect(Collectors.toList());
.toList();
Stream<FileCopier.CompressionSpec> compressions;
if (forCompression.isEmpty()) {
compressions = Stream.empty();
Expand Down Expand Up @@ -537,7 +538,7 @@ private static FileCopier.ArchiveCopySpec buildArchiveCopySpec(
.from(m.getResult().getArchivePath())
.to(m.getRom().getName())
.build())
.collect(ImmutableSet.toImmutableSet()))
.collect(ImmutableMap.toImmutableMap(FileCopier.ArchiveCopySpec.InternalSpec::getFrom, Function.identity(), (a, b) -> a)))
.build();
}

Expand Down
20 changes: 11 additions & 9 deletions core/src/main/java/io/github/datromtool/io/ArchiveType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import java.util.function.Predicate;
import java.util.regex.Pattern;

import static java.util.regex.Pattern.*;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static java.util.regex.Pattern.compile;
import static java.util.regex.Pattern.quote;

@AllArgsConstructor
public enum ArchiveType {
Expand Down Expand Up @@ -50,13 +52,13 @@ private static boolean isTar(String s) {
}

private static boolean isBzip2(String s) {
return BZip2Utils.isCompressedFilename(s)
&& Constants.TAR_PATTERN.matcher(BZip2Utils.getUncompressedFilename(s)).find();
return BZip2Utils.isCompressedFileName(s)
&& Constants.TAR_PATTERN.matcher(BZip2Utils.getUncompressedFileName(s)).find();
}

private static boolean isGzip(String s) {
return GzipUtils.isCompressedFilename(s)
&& Constants.TAR_PATTERN.matcher(GzipUtils.getUncompressedFilename(s)).find();
return GzipUtils.isCompressedFileName(s)
&& Constants.TAR_PATTERN.matcher(GzipUtils.getUncompressedFileName(s)).find();
}

private static boolean isLz4(String s) {
Expand All @@ -65,14 +67,14 @@ private static boolean isLz4(String s) {

private static boolean isTarLzma(String s) {
return LZMAUtils.isLZMACompressionAvailable()
&& LZMAUtils.isCompressedFilename(s)
&& Constants.TAR_PATTERN.matcher(LZMAUtils.getUncompressedFilename(s)).find();
&& LZMAUtils.isCompressedFileName(s)
&& Constants.TAR_PATTERN.matcher(LZMAUtils.getUncompressedFileName(s)).find();
}

private static boolean isTarXz(String s) {
return XZUtils.isXZCompressionAvailable()
&& XZUtils.isCompressedFilename(s)
&& Constants.TAR_PATTERN.matcher(XZUtils.getUncompressedFilename(s)).find();
&& XZUtils.isCompressedFileName(s)
&& Constants.TAR_PATTERN.matcher(XZUtils.getUncompressedFileName(s)).find();
}

@Getter(onMethod_ = {@JsonValue})
Expand Down
Loading

0 comments on commit e0a4a11

Please sign in to comment.