001package com.nimbusds.infinispan.persistence.common;
002
003
004import net.jcip.annotations.Immutable;
005import org.infinispan.metadata.InternalMetadata;
006
007
008/**
009 * Encapsulates an Infinispan entry consisting of a key / value pair and
010 * associated optional metadata.
011 */
012@Immutable
013public final class InfinispanEntry<K,V> {
014        
015
016        /**
017         * The entry key.
018         */
019        private final K key;
020
021
022        /**
023         * The entry value.
024         */
025        private final V value;
026
027
028        /**
029         * The optional entry metadata.
030         */
031        private final InternalMetadata metadata;
032
033
034        /**
035         * Creates a new Infinispan entry.
036         *
037         * @param key      The entry key. Must not be {@code null}.
038         * @param value    The entry value. {@code null} if none.
039         * @param metadata Optional entry metadata, {@code null} if not
040         *                 specified.
041         */
042        public InfinispanEntry(K key, V value, InternalMetadata metadata) {
043                assert key != null;
044                this.key = key;
045                this.value = value;
046                this.metadata = metadata;
047        }
048
049
050        /**
051         * Returns the entry key.
052         *
053         * @return The key.
054         */
055        public K getKey() {
056                return key;
057        }
058
059
060        /**
061         * Returns the entry value.
062         *
063         * @return The value, {@code null} if none.
064         */
065        public V getValue() {
066                return value;
067        }
068
069
070        /**
071         * Returns the optional entry metadata.
072         *
073         * @return The entry metadata, {@code null} if not specified.
074         */
075        public InternalMetadata getMetadata() {
076                return metadata;
077        }
078}