All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kolibrifx.plovercrest.server.internal.ReaderPositionUtils Maven / Gradle / Ivy

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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy