class FacetParserHelper extends FacetHelper {

    public static final Facet terms(final JsonNode facet, VarNameAdapter adapter)
        throws InvalidCreateOperationException, InvalidParseOperationException {
        final String name = facet.get(FACETARGS.NAME.exactToken()).asText();
        JsonNode terms = facet.get(FACET.TERMS.exactToken());

        if (!terms.has(FACETARGS.ORDER.exactToken())) {
            throw new InvalidCreateOperationException(
                String.format("facet must contain a %s parameter", FACETARGS.ORDER.exactToken()));
        }
        if (!terms.has(FACETARGS.SIZE.exactToken())) {
            throw new InvalidCreateOperationException(
                String.format("facet must contain a %s parameter", FACETARGS.SIZE.exactToken()));
        }

        String translatedNestedPath = null;
        if(terms.get(FACETARGS.SUBOBJECT.exactToken()) != null) {
            String nestedPath = terms.get(FACETARGS.SUBOBJECT.exactToken()).asText();
            translatedNestedPath = adapter.getVariableName(nestedPath);
            if(translatedNestedPath == null) {
                translatedNestedPath = nestedPath;
            }
        }

        String fieldName = terms.get(FACETARGS.FIELD.exactToken()).asText();
        String translatedFieldName = adapter.getVariableName(fieldName);
        if(translatedFieldName == null) {
            translatedFieldName = fieldName;
        }

        Integer size = terms.get(FACETARGS.SIZE.exactToken()).asInt();
        FacetOrder order = FacetOrder.valueOf(terms.get(FACETARGS.ORDER.exactToken()).asText());


        return FacetHelper.terms(name, translatedFieldName, translatedNestedPath, size, order);
    }

    protected  FacetParserHelper();

}