001/*
002 * SPDX-FileCopyrightText: none
003 * SPDX-License-Identifier: CC0-1.0
004 */
005
006package gov.nist.secauto.metaschema.databind.io;
007
008import gov.nist.secauto.metaschema.core.configuration.AbstractConfigurationFeature;
009import gov.nist.secauto.metaschema.core.model.IAssemblyDefinition;
010
011import edu.umd.cs.findbugs.annotations.NonNull;
012
013@SuppressWarnings("PMD.DataClass") // not a data class
014public final class DeserializationFeature<V>
015    extends AbstractConfigurationFeature<V> {
016  public static final int YAML_CODEPOINT_LIMIT_DEFAULT = Integer.MAX_VALUE - 1; // 2 GB
017  public static final int FORMAT_DETECTION_LOOKAHEAD = 32_768; // 2 GB
018
019  /**
020   * If enabled, perform constraint validation on the deserialized bound objects.
021   */
022  @NonNull
023  public static final DeserializationFeature<Boolean> DESERIALIZE_VALIDATE_CONSTRAINTS
024      = new DeserializationFeature<>("validate", Boolean.class, false);
025
026  /**
027   * If enabled, allow inline XML entities to be automatically replaced.
028   */
029  @NonNull
030  public static final DeserializationFeature<Boolean> DESERIALIZE_XML_ALLOW_ENTITY_RESOLUTION
031      = new DeserializationFeature<>("allow-entity-resolution", Boolean.class, false);
032
033  /**
034   * If enabled, process the next JSON node as a field, whose name must match the
035   * {@link IAssemblyDefinition#getRootJsonName()}. If not enabled, the next JSON
036   * node is expected to be an object containing the data of the
037   * {@link IAssemblyDefinition}.
038   */
039  @NonNull
040  public static final DeserializationFeature<Boolean> DESERIALIZE_JSON_ROOT_PROPERTY
041      = new DeserializationFeature<>("deserialize-root-property", Boolean.class, true);
042
043  /**
044   * Determines the max YAML codepoints that can be read.
045   */
046  @NonNull
047  public static final DeserializationFeature<Integer> YAML_CODEPOINT_LIMIT
048      = new DeserializationFeature<>("yaml-codepoint-limit", Integer.class, YAML_CODEPOINT_LIMIT_DEFAULT);
049
050  /**
051   * Determines how many bytes can be looked at to identify the format of a
052   * document.
053   */
054  @NonNull
055  public static final DeserializationFeature<Integer> FORMAT_DETECTION_LOOKAHEAD_LIMIT
056      = new DeserializationFeature<>("format-detection-lookahead-limit", Integer.class, FORMAT_DETECTION_LOOKAHEAD);
057
058  private DeserializationFeature(
059      @NonNull String name,
060      @NonNull Class<V> valueClass,
061      @NonNull V defaultValue) {
062    super(name, valueClass, defaultValue);
063  }
064}