HHH-13876 Remove unused code from StandardStack

This commit is contained in:
Sanne Grinovero 2020-02-26 09:45:55 +00:00
parent e65ef1354c
commit b856d534cb
2 changed files with 3 additions and 34 deletions

View File

@ -6,9 +6,6 @@
*/ */
package org.hibernate.internal.util.collections; package org.hibernate.internal.util.collections;
import java.util.function.Consumer;
import java.util.function.Function;
/** /**
* Stack implementation exposing useful methods for Hibernate needs. * Stack implementation exposing useful methods for Hibernate needs.
* *
@ -47,14 +44,4 @@ public interface Stack<T> {
*/ */
void clear(); void clear();
/**
* Visit all elements in the stack, starting with the current and working back
*/
void visitCurrentFirst(Consumer<T> action);
/**
* Find an element on the stack and return a value. The first non-null element
* returned from `action` stops the iteration and is returned from here
*/
<X> X findCurrentFirst(Function<T, X> action);
} }

View File

@ -17,16 +17,13 @@ import java.util.function.Function;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class StandardStack<T> implements Stack<T> { public final class StandardStack<T> implements Stack<T> {
private LinkedList<T> internalStack = new LinkedList<>();
private final LinkedList<T> internalStack = new LinkedList<>();
public StandardStack() { public StandardStack() {
} }
public StandardStack(T initial) {
internalStack.add( initial );
}
@Override @Override
public void push(T newCurrent) { public void push(T newCurrent) {
internalStack.addFirst( newCurrent ); internalStack.addFirst( newCurrent );
@ -57,19 +54,4 @@ public class StandardStack<T> implements Stack<T> {
internalStack.clear(); internalStack.clear();
} }
@Override
public void visitCurrentFirst(Consumer<T> action) {
internalStack.forEach( action );
}
@Override
public <X> X findCurrentFirst(Function<T, X> function) {
for ( T t : internalStack ) {
final X result = function.apply( t );
if ( result != null ) {
return result;
}
}
return null;
}
} }