-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Stapler's Guava dependency #213
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d7a07ee
Migrate from Guava's cache to ConcurrentHashMap in JellyClassLoaderTe…
basil c592c38
Migrate from Guava's cache to Caffeine in AbstractTearOff, CachingScr…
basil ddff181
Inline Guava's Iterators#limit
basil 1d773ac
Drop Guava dependency
basil e1191cc
Shade Caffeine
basil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
core/src/main/java/org/kohsuke/stapler/export/Iterators.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (C) 2007 The Guava Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.kohsuke.stapler.export; | ||
|
||
import java.util.Iterator; | ||
import java.util.NoSuchElementException; | ||
|
||
/** | ||
* This class contains static utility methods that operate on or return objects of type {@link | ||
* Iterator}. | ||
* | ||
* <p><i>Performance notes:</i> Unless otherwise noted, all of the iterators produced in this class | ||
* are <i>lazy</i>, which means that they only advance the backing iteration when absolutely | ||
* necessary. | ||
* | ||
* <p>See the Guava User Guide section on <a href= | ||
* "https://github.com/google/guava/wiki/CollectionUtilitiesExplained#iterables"> {@code | ||
* Iterators}</a>. | ||
* | ||
* @author Kevin Bourrillion | ||
* @author Jared Levy | ||
*/ | ||
final class Iterators { | ||
private Iterators() {} | ||
|
||
/** | ||
* Returns a view containing the first {@code limitSize} elements of {@code iterator}. If {@code | ||
* iterator} contains fewer than {@code limitSize} elements, the returned view contains all of its | ||
* elements. The returned iterator supports {@code remove()} if {@code iterator} does. | ||
* | ||
* @param iterator the iterator to limit | ||
* @param limitSize the maximum number of elements in the returned iterator | ||
* @throws IllegalArgumentException if {@code limitSize} is negative | ||
*/ | ||
static <T> Iterator<T> limit(final Iterator<T> iterator, final int limitSize) { | ||
if (iterator == null) { | ||
throw new NullPointerException(); | ||
} | ||
if (limitSize < 0) { | ||
throw new IllegalArgumentException("limit is negative"); | ||
} | ||
return new Iterator<T>() { | ||
private int count; | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return count < limitSize && iterator.hasNext(); | ||
} | ||
|
||
@Override | ||
public T next() { | ||
if (!hasNext()) { | ||
throw new NoSuchElementException(); | ||
} | ||
count++; | ||
return iterator.next(); | ||
} | ||
|
||
@Override | ||
public void remove() { | ||
iterator.remove(); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt this ever worked to begin with. See https://github.com/jglick/biweak-class-map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not have worked in the case of a class with a
fromStapler
method, because then the value would be aMethodFunction
whoseMethod m
has aClass<?> clazz
that refers to the key of the map.But it would have worked in the case of a class without a
fromStapler
method, because then the value would be aStaticFunction
whoseMethod m
has aClass<?> clazz
that refers toorg.kohsuke.stapler.Function
rather than the key of the map.