001package votorola.s.gwt.stage.talk; // Copyright 2012, Christian Weilbach.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE.
002
003import java.util.Date;
004
005import votorola.g.lang.Equator;
006import votorola.g.web.gwt.JavaScriptObjectX;
007import votorola.a.diff.DiffLookJS;
008import votorola.s.gwt.stage.Message;
009import votorola.s.gwt.stage.MessageJS;
010
011/**
012 * JavaScriptObject from JSON output of {@linkplain votorola.s.wap.HarvestWAP}
013 * representing a serialized
014 * {@linkplain votorola.a.diff.harvest.cache.DiffMessage}.
015 * 
016 */
017public final class DiffMessageJS extends JavaScriptObjectX {
018    protected DiffMessageJS() {
019    } // precisely one constructor, protected, empty and no arguments
020
021    public Message message() {
022        return _get("message");
023    }
024
025    public DiffLookJS difference() {
026        return _get("difference");
027    }
028        
029    public String sender() {
030        return _get("sender");
031    }
032 
033    public String addressee() {
034        return _get("addressee");
035    }
036    
037    public native double sentDate() /*-{
038        return this.sentDate;
039    }-*/;
040
041    public static Equator<DiffMessageJS> EQUATOR = new Equator<DiffMessageJS>() {
042        public boolean equals(final DiffMessageJS d1,
043                final DiffMessageJS d2) {
044            if(d1 == d2){
045                return true;
046            }
047            
048            return d1 instanceof DiffMessageJS && d2 instanceof DiffMessageJS
049                    && MessageJS.EQUATOR.equals(d1.message(), d2.message())
050                    && DiffLookJS.EQUATOR.equals(d1.difference(), d2.difference());
051        }
052    };
053
054    /**
055     * id in the DB. This allows to query for newly fetched messages, having a
056     * higher id than this message.
057     * 
058     * @return id
059     */
060    public native int id() /*-{ return this.id; }-*/;
061}