Skip to content

Commit e0d1cf0

Browse files
Konrado85snicoll
authored andcommitted
Polish JarFile to extra anonymous inner class
See gh-20882
1 parent 947594a commit e0d1cf0

File tree

1 file changed

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

1 file changed

+30
-13
lines changed

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

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,7 @@ public Manifest getManifest() throws IOException {
192192
@Override
193193
public Enumeration<java.util.jar.JarEntry> entries() {
194194
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-
};
195+
return new EnumerationJarEntry(iterator);
208196
}
209197

210198
public JarEntry getJarEntry(CharSequence name) {
@@ -421,4 +409,33 @@ enum JarFileType {
421409

422410
}
423411

412+
/**
413+
* The type Enumeration jar entry.
414+
*/
415+
static class EnumerationJarEntry implements Enumeration<java.util.jar.JarEntry> {
416+
417+
/**
418+
* The Iterator.
419+
*/
420+
Iterator<JarEntry> iterator;
421+
422+
/**
423+
* Instantiates a new Enumeration jar entry.
424+
*
425+
* @param iterator the iterator
426+
*/
427+
EnumerationJarEntry(Iterator<JarEntry> iterator) {
428+
this.iterator = iterator;
429+
}
430+
431+
@Override
432+
public boolean hasMoreElements() {
433+
return this.iterator.hasNext();
434+
}
435+
436+
@Override
437+
public java.util.jar.JarEntry nextElement() {
438+
return this.iterator.next();
439+
}
440+
}
424441
}

0 commit comments

Comments
 (0)