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

org.eclipse.ditto.internal.models.streaming.EntityIdWithRevision Maven / Gradle / Ivy

There is a newer version: 3.6.2
Show newest version
/*
 * Copyright (c) 2017 Contributors to the Eclipse Foundation
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package org.eclipse.ditto.internal.models.streaming;

import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonFieldDefinition;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.base.model.entity.id.EntityId;
import org.eclipse.ditto.base.model.json.Jsonifiable;

/**
 * Represents the ID of an entity with a revision of the entity.
 */
public interface EntityIdWithRevision extends Jsonifiable,
        IdentifiableStreamingMessage {

    /**
     * Returns the Entity ID of the modified entity.
     *
     * @return the ID of the modified entity.
     */
    I getEntityId();

    /**
     * Returns the revision of the modified entity.
     *
     * @return the revision of the modified entity.
     */
    long getRevision();

    /**
     * Returns this tag as an identifier in the format {@code :}.
     *
     * @return the tag as an identifier
     */
    default String asIdentifierString() {
        return getEntityId() + ":" + getRevision();
    }

    /**
     * An enumeration of the known {@link org.eclipse.ditto.json.JsonField}s of a EntityIdWithRevision.
     */
    @Immutable
    final class JsonFields {

        /**
         * JSON field containing the message's entity type.
         */
        public static final JsonFieldDefinition ENTITY_TYPE = JsonFactory.newStringFieldDefinition("type");

        /**
         * JSON field containing the message's ID.
         */
        public static final JsonFieldDefinition ENTITY_ID = JsonFactory.newStringFieldDefinition("id");

        /**
         * JSON field containing the message's revision.
         */
        public static final JsonFieldDefinition REVISION = JsonFactory.newLongFieldDefinition("revision");


        private JsonFields() {
            throw new AssertionError();
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy