Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.factual.driver;
 
General representation of a Shape, for the purpose of geo filters.

Author(s):
aaron
 
public abstract class Shape {

  
The driver relies on calling toString() to get the representation of Shapes.
  public String toString() {
    return toJsonStr();
  }

  

Returns:
the full JSON representation of this Shape.
  private String toJsonStr() {
    return JsonUtil.toJsonStr(withinStruct());
  }

  
Can be used by Shape implementations to get the full 'within' structure for a query.

Returns:
the 'within' structure for a query.
  @SuppressWarnings({ "unchecked""rawtypes""serial" })
  private Object withinStruct() {
    return new HashMap(){{
      put("$within"toJsonObject());
    }};
  }

  
All Shapes must implement this to return a structure that represents the shape with data that can be JSON-ized.

Returns:
a structure that represents the shape
  public abstract Object toJsonObject();
New to GrepCode? Check out our FAQ X