com.kolibrifx.plovercrest.server.internal.ReaderPositionUtils 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;
import com.kolibrifx.plovercrest.client.internal.remote.ReaderPositionType;
import com.kolibrifx.plovercrest.server.streams.ReaderPosition.PositionType;
public final class ReaderPositionUtils {
private ReaderPositionUtils() {
}
public static int getTag(final PositionType positionType) {
switch (positionType) {
case INDEX:
return ReaderPositionType.INDEX.getTag();
case TIMESTAMP:
return ReaderPositionType.TIMESTAMP.getTag();
default:
throw new IllegalStateException("Unknown position type " + positionType);
}
}
public static PositionType typeFromTag(final int tag) {
final ReaderPositionType clientPositionType = ReaderPositionType.fromTag(tag);
switch (clientPositionType) {
case INDEX:
return PositionType.INDEX;
case TIMESTAMP:
return PositionType.TIMESTAMP;
default:
throw new IllegalStateException("Unknown position type " + clientPositionType);
}
}
}