001 package com.croftsoft.core.util.mail; 002 003 import com.croftsoft.core.lang.NullException; 004 import com.croftsoft.core.util.seq.Seq; 005 import com.croftsoft.core.util.slot.Slot; 006 007 /********************************************************************** 008 * A Mail implementation backed by a Seq and a Slot. 009 * 010 * @version 011 * $Id: MailImp.java,v 1.3 2008/09/20 05:01:27 croft Exp $ 012 * @since 013 * 2008-01-27 014 * @author 015 * <a href="https://www.croftsoft.com/">David Wallace Croft</a> 016 **********************************************************************/ 017 018 public final class MailImp<Message> 019 implements Mail<Message> 020 /////////////////////////////////////////////////////////////////////// 021 /////////////////////////////////////////////////////////////////////// 022 { 023 024 private final Seq<Message> incomingSeq; 025 026 private final Slot<Message> outgoingSlot; 027 028 /////////////////////////////////////////////////////////////////////// 029 /////////////////////////////////////////////////////////////////////// 030 031 public MailImp ( 032 final Seq<Message> incomingSeq, 033 final Slot<Message> outgoingSlot ) 034 /////////////////////////////////////////////////////////////////////// 035 { 036 NullException.check ( 037 this.incomingSeq = incomingSeq, 038 this.outgoingSlot = outgoingSlot ); 039 } 040 041 /////////////////////////////////////////////////////////////////////// 042 /////////////////////////////////////////////////////////////////////// 043 044 public Message get ( final int index ) 045 /////////////////////////////////////////////////////////////////////// 046 { 047 return incomingSeq.get ( index ); 048 } 049 050 public int size ( ) 051 /////////////////////////////////////////////////////////////////////// 052 { 053 return incomingSeq.size ( ); 054 } 055 056 public boolean offer ( Message message ) 057 /////////////////////////////////////////////////////////////////////// 058 { 059 return outgoingSlot.offer ( message ); 060 } 061 062 /////////////////////////////////////////////////////////////////////// 063 /////////////////////////////////////////////////////////////////////// 064 }