@SuppressWarnings("unchecked")
  protected Set<PathSpec> getFields()
  {
    Object fields = _queryParams.get(RestConstants.FIELDS_PARAM);
    if (fields == null) {
      return Collections.emptySet();
    }

    if (fields instanceof Set)
    {
      return (Set<PathSpec>) fields;
    }
    else if (fields instanceof String)
    {
      try
      {
        MaskTree tree = URIMaskUtil.decodeMaskUriFormat((String) fields);
        return tree.getOperations().keySet();
      }
      catch (IllegalMaskException e)
      {
        throw new IllegalArgumentException("Field param was a string and it did not represent a serialized mask tree", e);
      }
    }
    else if (fields instanceof DataMap)
    {
      MaskTree tree = new MaskTree((DataMap) fields);
      return tree.getOperations().keySet();
    }

    throw new IllegalArgumentException("Fields param is of unrecognized type: " + fields.getClass());
  }
@Test
  public void testMaskTreeFieldsParam()
  {
    DataMap fields = new DataMap();
    fields.put("id", MaskMap.POSITIVE_MASK);
    GetRequest<TestRecord> getRequest =
        generateDummyRequestBuilder().setParam(RestConstants.FIELDS_PARAM, fields).build();
    assertEquals(getRequest.getFields(), Collections.singleton(new PathSpec("id")));
  }