org.hyperledger.fabric.client.MappingCloseableIterator Maven / Gradle / Ivy
/*
* Copyright 2022 IBM All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.client;
import java.util.function.Function;
final class MappingCloseableIterator implements CloseableIterator {
private final CloseableIterator iterator;
private final Function mapper;
MappingCloseableIterator(final CloseableIterator iterator, final Function mapper) {
this.iterator = iterator;
this.mapper = mapper;
}
@Override
public void close() {
iterator.close();
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public R next() {
T value = iterator.next();
return mapper.apply(value);
}
}