package de.accso.flexinale.common.shared_kernel;

import java.io.Serializable;

public interface Versionable {
    record Version(Integer version) implements Serializable, RawWrapper<Integer> {
        public static Version of(Integer version) {
            return new Version(version);
        }

        public Version inc() {
            return new Version(this.version()+1);
        }

        @Override
        public Integer raw() {
            return version;
        }
    }

    Version version();

    static Version unknownVersion() {
        Integer UNKNOWN = -1;
        return Version.of(UNKNOWN);
    }

    static Version initialVersion() {
        Integer INITIAL =  0;
        return Version.of(INITIAL);
    }
}
