@Override
  public Filter deserialize (JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException {
    ObjectMapper mapper = (ObjectMapper) parser.getCodec();
    ObjectNode root = mapper.readTree(parser);
    Class<? extends Filter> filterClass = null;
    List<String> invalidAttributes = new ArrayList<>();
    for (String fieldName: ImmutableList.copyOf(root.fieldNames())) {
      switch(fieldName) {
        case LinkAttributeFilter.LINK_ATTRIBUTE:
          if (null != filterClass) {
            throw new JsonParseException(parser, PARSE_ERROR_MESSAGE_AMBIGUOUS_FILTER, parser.getCurrentLocation());
          }
          filterClass = LinkAttributeFilter.class;
          break;
        case LinkNameFilter.LINK_NAME:
        case LinkNameFilter.LINK_URL:
          if (null != filterClass && !filterClass.equals(LinkNameFilter.class)) {
            throw new JsonParseException(parser, PARSE_ERROR_MESSAGE_AMBIGUOUS_FILTER, parser.getCurrentLocation());
          }
          filterClass = LinkNameFilter.class;
          break;
        case Filter.VISIBLE:
          // silently ignore here, will be parsed later in mapper.readValue
          break;
        default:
          invalidAttributes.add(fieldName);
      }
    }
    if (!invalidAttributes.isEmpty()) {
      throw new JsonParseException(parser, PARSE_ERROR_MESSAGE_INVALID_JSON_TAG + invalidAttributes,
          parser.getCurrentLocation());
    }
    if (null == filterClass) {
      filterClass = AcceptAllFilter.class;
    }
    return mapper.readValue(root.traverse(), filterClass);
  }
Filter polymorphism is handled here. If a filter object in the JSON document has:
<ul>
  <li>a {@code link_attribute} field, it will parsed as {@link LinkAttributeFilter}</li>
  <li>a {@code link_name} field, it will be parsed as {@link LinkNameFilter}</li>
  <li>both {@code link_attribute} and {@code link_name}, it will throw a {@link JsonParseException}</li>
  <li>neither of the above fields, it will be parsed as {@link AcceptAllFilter}</li>
</ul>

@throws JsonParseException if ambiguous filter definitions are found, or any JSON syntax error.
ambari-server/src/main/java/org/apache/ambari/server/state/quicklinksprofile/QuickLinksProfileParser.java