@Override public int compareTo(Path other) { return delegate.compareTo(other); }
public void save(String newFilename) throws IOException, NotSupportedException { if (path.toAbsolutePath().compareTo(Paths.get(newFilename).toAbsolutePath()) == 0) { throw new IllegalArgumentException("Save filename same as source filename"); } try (SeekableByteChannel saveFile = Files.newByteChannel(Paths.get(newFilename), EnumSet.of(StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE))) { if (hasId3v2Tag()) { ByteBuffer byteBuffer = ByteBuffer.wrap(id3v2Tag.toBytes()); byteBuffer.rewind(); saveFile.write(byteBuffer); } saveMpegFrames(saveFile); if (hasCustomTag()) { ByteBuffer byteBuffer = ByteBuffer.wrap(customTag); byteBuffer.rewind(); saveFile.write(byteBuffer); } if (hasId3v1Tag()) { ByteBuffer byteBuffer = ByteBuffer.wrap(id3v1Tag.toBytes()); byteBuffer.rewind(); saveFile.write(byteBuffer); } saveFile.close(); } }
compare = 1; } else { compare = children[child].file.compareTo(files[file]);
@Override public int compareTo(Path other) { return delegate.compareTo(other); }
@Override public int compare(Path f1, Path f2) { return -f1.getFileName().compareTo(f2.getFileName()); } }
/** * returns true if the Path is a Windows Junction */ private static boolean isJunction(Path p) { boolean isJunction = false; try { isJunction = (p.compareTo(p.toRealPath()) != 0); } catch (IOException e) { e.printStackTrace(); // TODO: handleMeProperly } return isJunction; }
@Override public int compareTo(Node o) { int nameCount = Integer.compare(delegate.getNameCount(), o.delegate.getNameCount()); if (nameCount != 0) { return nameCount; } return delegate.compareTo(o.delegate); }
@Override public int compareTo(Node o) { int nameCount = Integer.compare(delegate.getNameCount(), o.delegate.getNameCount()); if (nameCount != 0) { return nameCount; } return delegate.compareTo(o.delegate); }
@Override public int compareTo(Node o) { int nameCount = Integer.compare(delegate.getNameCount(), o.delegate.getNameCount()); if (nameCount != 0) { return nameCount; } return delegate.compareTo(o.delegate); }
Map<Path, List<String>> readFiles = new TreeMap<>(new Comparator<Path>() { @Override public int compare(Path o1, Path o2) { Matcher o1Matcher = NUMBER_PATTERN.matcher(o1.getFileName().toString()); Matcher o2Matcher = NUMBER_PATTERN.matcher(o2.getFileName().toString()); if (o1Matcher.find() && o2Matcher.find()) { return Integer.compare(Integer.parseInt(o1Matcher.group()), Integer.parseInt(o2Matcher.group())); } else { return o1.compareTo(o2); } } });
@Override public int compare(PathPieces p1, PathPieces p2) { int scoring = searchFor.score(p1) - searchFor.score(p2); if (scoring != 0) { return scoring; // prefer matches to region and language } int pathLength = p1.path.getNameCount() - p2.path.getNameCount(); if (pathLength != 0) { return -pathLength; // shorter is better } return -p1.path.compareTo(p2.path); // early in alphabet is better }
@Test @Category( NotDefaultFileSystem.class ) public void testCompareToDifferentProviderThrows() throws Exception { assertThatThrownBy( () -> relABC().compareTo( FileSystems.getDefault().getPath( nameA() ) ) ).isInstanceOf( ClassCastException.class ); }
@Override public int compareTo(MediaFile mf2) { return this.getFileAsPath().compareTo(mf2.getFileAsPath()); }
@Test public void testCompareToOfEqualPathsIs0() throws Exception { assertThat( relABC().compareTo( relABC() ) ).isEqualTo( 0 ); }
@Test @Category( { SecondFileSystem.class } ) public void testCompareToDifferentFSPathSameToStringButDifferent() throws IOException { assertThat( absAB().toString().compareTo( otherFSAbsAB().toString() ) ).isEqualTo( 0 ); assertThat( absAB().compareTo( otherFSAbsAB() )).isNotEqualTo( 0 ); }
@Test @Category( { Unix.class } ) public void testDefaultPathIsSmallerThanAbsolute() { assertThat( pathDefault().compareTo( absAB() ) ).isLessThan( 0 ); }
@Test @Category( { Unix.class } ) public void testDefaultPathIsSmallerThanRelative() { assertThat( pathDefault().compareTo( relAB() ) ).isLessThan( 0 ); }
@Override default int compareTo(final @Nullable CatalogVerificationReportItemType o) { return this.getPath().compareTo(NullCheck.notNull(o).getPath()); } }
@Test @Category( Windows.class ) public void testCaseIgnorantPathKeepCompareSaneSmaller() throws IOException { assertThat( absAB().compareTo( mixCase( absABC()))).isLessThan( 0 ); }
@Test public void compareToGreaterValue() { final Path path = fileSystem.getPath("/toplevel/a"); final String otherName = "/toplevel/b"; final Path other = fileSystem.getPath(otherName); final int compare = path.compareTo(other); Assert.assertEquals(-1, compare); }