539 *
540 * <p>If this {@code JarFile} is a multi-release jar file and is configured to
541 * be processed as such, then an entry in the stream is the latest versioned entry
542 * associated with the corresponding base entry name. The maximum version of the
543 * latest versioned entry is the version returned by {@link #getVersion()}.
544 * The returned stream may include an entry that only exists as a versioned entry.
545 *
546 * If the jar file is not a multi-release jar file or the {@code JarFile} is not
547 * configured for processing a multi-release jar file, this method returns the
548 * same stream that {@link #stream()} returns.
549 *
550 * @return stream of versioned entries
551 * @since 10
552 */
553 public Stream<JarEntry> versionedStream() {
554
555 if (isMultiRelease()) {
556 return JUZFA.entryNameStream(this).map(this::getBasename)
557 .filter(Objects::nonNull)
558 .distinct()
559 .map(this::getJarEntry);
560 }
561 return stream();
562 }
563
564 /*
565 * Invokes {@ZipFile}'s getEntry to Return a {@code JarFileEntry} for the
566 * given entry name or {@code null} if not found.
567 */
568 private JarFileEntry getEntry0(String name) {
569 // Not using a lambda/method reference here to optimize startup time
570 Function<String, JarEntry> newJarFileEntryFn = new Function<>() {
571 @Override
572 public JarEntry apply(String name) {
573 return new JarFileEntry(name);
574 }
575 };
576 return (JarFileEntry)JUZFA.getEntry(this, name, newJarFileEntryFn);
577 }
578
579 private String getBasename(String name) {
|
539 *
540 * <p>If this {@code JarFile} is a multi-release jar file and is configured to
541 * be processed as such, then an entry in the stream is the latest versioned entry
542 * associated with the corresponding base entry name. The maximum version of the
543 * latest versioned entry is the version returned by {@link #getVersion()}.
544 * The returned stream may include an entry that only exists as a versioned entry.
545 *
546 * If the jar file is not a multi-release jar file or the {@code JarFile} is not
547 * configured for processing a multi-release jar file, this method returns the
548 * same stream that {@link #stream()} returns.
549 *
550 * @return stream of versioned entries
551 * @since 10
552 */
553 public Stream<JarEntry> versionedStream() {
554
555 if (isMultiRelease()) {
556 return JUZFA.entryNameStream(this).map(this::getBasename)
557 .filter(Objects::nonNull)
558 .distinct()
559 .map(this::getJarEntry)
560 .filter(Objects::nonNull);
561 }
562 return stream();
563 }
564
565 /*
566 * Invokes {@ZipFile}'s getEntry to Return a {@code JarFileEntry} for the
567 * given entry name or {@code null} if not found.
568 */
569 private JarFileEntry getEntry0(String name) {
570 // Not using a lambda/method reference here to optimize startup time
571 Function<String, JarEntry> newJarFileEntryFn = new Function<>() {
572 @Override
573 public JarEntry apply(String name) {
574 return new JarFileEntry(name);
575 }
576 };
577 return (JarFileEntry)JUZFA.getEntry(this, name, newJarFileEntryFn);
578 }
579
580 private String getBasename(String name) {
|