Skip to content

Commit 4c05924

Browse files
committed
Merge pull request #20882 from Konrado85
* pr/20882: Polish "Polish JarFile to extra anonymous inner class" Polish JarFile to extra anonymous inner class Closes gh-20882
2 parents 947594a + 1dd8dcc commit 4c05924

File tree

1 file changed

+25
-15
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar

1 file changed

+25
-15
lines changed

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -191,20 +191,7 @@ public Manifest getManifest() throws IOException {
191191

192192
@Override
193193
public Enumeration<java.util.jar.JarEntry> entries() {
194-
final Iterator<JarEntry> iterator = this.entries.iterator();
195-
return new Enumeration<java.util.jar.JarEntry>() {
196-
197-
@Override
198-
public boolean hasMoreElements() {
199-
return iterator.hasNext();
200-
}
201-
202-
@Override
203-
public java.util.jar.JarEntry nextElement() {
204-
return iterator.next();
205-
}
206-
207-
};
194+
return new JarEntryEnumeration(this.entries.iterator());
208195
}
209196

210197
public JarEntry getJarEntry(CharSequence name) {
@@ -421,4 +408,27 @@ enum JarFileType {
421408

422409
}
423410

411+
/**
412+
* An {@link Enumeration} on {@linkplain java.util.jar.JarEntry jar entries}.
413+
*/
414+
private static class JarEntryEnumeration implements Enumeration<java.util.jar.JarEntry> {
415+
416+
private final Iterator<JarEntry> iterator;
417+
418+
JarEntryEnumeration(Iterator<JarEntry> iterator) {
419+
this.iterator = iterator;
420+
}
421+
422+
@Override
423+
public boolean hasMoreElements() {
424+
return this.iterator.hasNext();
425+
}
426+
427+
@Override
428+
public java.util.jar.JarEntry nextElement() {
429+
return this.iterator.next();
430+
}
431+
432+
}
433+
424434
}

0 commit comments

Comments
 (0)