001package votorola.s.gwt.scene.feed.ss; // Copyright 2011, Michael Allan. 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 com.google.gson.stream.JsonWriter; 004import java.io.IOException; 005 006 007/** A mutable and serializeable residence. 008 */ 009public final class ResidenceJig implements votorola.s.gwt.scene.feed.Residence, SerialJig 010{ 011 012 // adding fields? ensure they are cleared in serialize() 013 014 015 // - R e s i d e n c e ---------------------------------------------------------------- 016 017 018 public float lat() { return lat; } 019 020 021 private float lat; 022 023 024 private void lat( final JsonWriter out ) throws IOException 025 { 026 if( !latSet ) return; 027 028 out.name( "lat" ).value( lat ); 029 latSet = false; 030 } 031 032 033 private boolean latSet; 034 035 036 /** Sets the latitude. 037 */ 038 public void setLat( float f ) 039 { 040 lat = f; 041 latSet = true; 042 } 043 044 045 046 public float lon() { return lon; } 047 048 049 private float lon; 050 051 052 private void lon( final JsonWriter out ) throws IOException 053 { 054 if( !lonSet ) return; 055 056 out.name( "lon" ).value( lon ); 057 lonSet = false; 058 } 059 060 061 private boolean lonSet; 062 063 064 /** Sets the longitude. 065 */ 066 public void setLon( float f ) 067 { 068 lon = f; 069 lonSet = true; 070 } 071 072 073 074 // - S e r i a l - J i g -------------------------------------------------------------- 075 076 077 public void serialize( final JsonWriter out ) throws IOException 078 { 079 out.beginObject(); 080 lat( out ); 081 lon( out ); 082 out.endObject(); 083 } 084 085 086 087}