com.kolibrifx.plovercrest.server.internal.folds.PeekableInputStreamUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plovercrest-server Show documentation
Show all versions of plovercrest-server Show documentation
Plovercrest server library.
The newest version!
/*
* Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
*/
package com.kolibrifx.plovercrest.server.internal.folds;
import java.nio.ByteBuffer;
import com.kolibrifx.plovercrest.server.streams.Stream;
public final class PeekableInputStreamUtils {
private PeekableInputStreamUtils() {
}
@SuppressWarnings("unchecked")
public static PeekableInputStream create(final Stream stream, final long fromTimestamp) {
if (stream.getElementClass() == ByteBuffer.class) {
return (PeekableInputStream) new ByteArrayPeekableInputStream((Stream) stream, fromTimestamp);
} else {
return new DefaultPeekableInputStream<>(stream, fromTimestamp);
}
}
}