Extract lambda to class

This commit is contained in:
filoghost 2021-12-25 12:13:48 +01:00
parent 90e26af19b
commit aade3ddbfe
2 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) filoghost and contributors
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package me.filoghost.holographicdisplays.plugin.hologram.tracking;
import java.util.Collection;
import java.util.function.Consumer;
public class DelegateViewers<T extends Viewer> implements Viewers<T> {
private final Collection<T> viewers;
public DelegateViewers(Collection<T> viewers) {
this.viewers = viewers;
}
@Override
public void forEach(Consumer<? super T> action) {
viewers.forEach(action);
}
}

View File

@ -25,7 +25,7 @@ public abstract class LineTracker<T extends Viewer> {
protected LineTracker() {
this.viewers = new HashMap<>();
this.iterableViewers = action -> viewers.values().forEach(action);
this.iterableViewers = new DelegateViewers<>(viewers.values());
}
protected abstract BaseHologramLine getLine();