Skip to content

Instantly share code, notes, and snippets.

@jlindenbaum
Created January 26, 2012 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlindenbaum/1683280 to your computer and use it in GitHub Desktop.
Save jlindenbaum/1683280 to your computer and use it in GitHub Desktop.
"Caching" in Object fields
/**
* Creates a new GeoPoint only if
* a GeoPoint object does not exist
* within the object already
*/
public GeoPoint getGeoPoint() {
if (this.geoPoint == null) {
this.geoPoint = new GeoPoint(this.lat, this.lng);
}
return this.geoPoint;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment