001    // Copyright 2009 Waterken Inc. under the terms of the MIT X license
002    // found at http://www.opensource.org/licenses/mit-license.html
003    package org.waterken.serial;
004    
005    import java.io.Serializable;
006    
007    import org.joe_e.Struct;
008    import org.ref_send.Record;
009    import org.ref_send.deserializer;
010    import org.ref_send.name;
011    import org.ref_send.promise.Promise;
012    
013    /**
014     * A resolved element of a series.
015     * @param <T> {@link #value} type
016     */
017    public class
018    Link<T> extends Struct implements Element<T>, Record, Serializable {
019        static private final long serialVersionUID = 1L;
020    
021        /**
022         * element value
023         */
024        public final Promise<T> value;
025        
026        /**
027         * next element
028         */
029        public final Element<T> next;
030        
031        /**
032         * Constructs an instance.
033         * @param value {@link #value}
034         * @param next  {@link #next}
035         */
036        public @deserializer
037        Link(@name("value") final Promise<T> value,
038             @name("next") final Element<T> next) {
039            this.value = value;
040            this.next = next;
041        }
042        
043        /**
044         * Constructs an instance.
045         * @param <T>   {@link #value} type
046         * @param value {@link #value}
047         * @param next  {@link #next}
048         */
049        static public <T> Element<T>
050        link(final Promise<T> value, final Element<T> next) {
051            return new Link<T>(value, next);
052        }
053        
054        public Promise<T>
055        getValue() { return value; }
056    
057        public Element<T>
058        getNext() { return next; }
059    }