From 1dd8dcc6c9e72f64cb66662c5fa43ba749ec0bfd Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 15 Apr 2020 09:39:00 +0200 Subject: [PATCH] Polish "Polish JarFile to extra anonymous inner class" See gh-20882 --- .../boot/loader/jar/JarFile.java | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java index 2bd4816c69..ecdb31ef6f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -191,8 +191,7 @@ public class JarFile extends java.util.jar.JarFile { @Override public Enumeration entries() { - final Iterator iterator = this.entries.iterator(); - return new EnumerationJarEntry(iterator); + return new JarEntryEnumeration(this.entries.iterator()); } public JarEntry getJarEntry(CharSequence name) { @@ -410,21 +409,13 @@ public class JarFile extends java.util.jar.JarFile { } /** - * The type Enumeration jar entry. + * An {@link Enumeration} on {@linkplain java.util.jar.JarEntry jar entries}. */ - static class EnumerationJarEntry implements Enumeration { + private static class JarEntryEnumeration implements Enumeration { - /** - * The Iterator. - */ - Iterator iterator; + private final Iterator iterator; - /** - * Instantiates a new Enumeration jar entry. - * - * @param iterator the iterator - */ - EnumerationJarEntry(Iterator iterator) { + JarEntryEnumeration(Iterator iterator) { this.iterator = iterator; } @@ -437,5 +428,7 @@ public class JarFile extends java.util.jar.JarFile { public java.util.jar.JarEntry nextElement() { return this.iterator.next(); } + } + }