<commit_before>/**
 * Copyright 2021 interactive instruments GmbH
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package de.ii.ldproxy.ogcapi.features.geojson.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.google.common.hash.Funnel;
import de.ii.ldproxy.ogcapi.domain.PageRepresentation;

import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Optional;
import org.immutables.value.Value;

@JsonTypeInfo(
        use = JsonTypeInfo.Id.NONE)
@JsonSubTypes({
        @JsonSubTypes.Type(value = JsonSchemaString.class, name = "string"),
        @JsonSubTypes.Type(value = JsonSchemaNumber.class, name = "number"),
        @JsonSubTypes.Type(value = JsonSchemaInteger.class, name = "integer"),
        @JsonSubTypes.Type(value = JsonSchemaBoolean.class, name = "boolean"),
        @JsonSubTypes.Type(value = JsonSchemaObject.class, name = "object"),
        @JsonSubTypes.Type(value = JsonSchemaArray.class, name = "array"),
        @JsonSubTypes.Type(value = JsonSchemaNull.class, name = "null"),
        @JsonSubTypes.Type(value = JsonSchemaRef.class, name = "$ref"),
        @JsonSubTypes.Type(value = JsonSchemaOneOf.class, name = "oneOf")
})
public abstract class JsonSchema extends PageRepresentation {

    @SuppressWarnings("UnstableApiUsage")
    public static final Funnel<JsonSchema> FUNNEL = (from, into) -> {
        PageRepresentation.FUNNEL.funnel(from, into);
        if (from instanceof JsonSchemaString)
            JsonSchemaString.FUNNEL.funnel((JsonSchemaString) from, into);
        else if (from instanceof JsonSchemaNumber)
            JsonSchemaNumber.FUNNEL.funnel((JsonSchemaNumber) from, into);
        else if (from instanceof JsonSchemaInteger)
            JsonSchemaInteger.FUNNEL.funnel((JsonSchemaInteger) from, into);
        else if (from instanceof JsonSchemaBoolean)
            JsonSchemaBoolean.FUNNEL.funnel((JsonSchemaBoolean) from, into);
        else if (from instanceof JsonSchemaObject)<commit_msg>de-serialization of JSON schemas (#554)<commit_after>/**
 * Copyright 2021 interactive instruments GmbH
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package de.ii.ldproxy.ogcapi.features.geojson.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.google.common.hash.Funnel;
import de.ii.ldproxy.ogcapi.domain.PageRepresentation;

import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Optional;
import org.immutables.value.Value;

@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.EXISTING_PROPERTY,
    property = "type")
@JsonSubTypes({
        @JsonSubTypes.Type(value = JsonSchemaString.class, name = "string"),
        @JsonSubTypes.Type(value = JsonSchemaNumber.class, name = "number"),
        @JsonSubTypes.Type(value = JsonSchemaInteger.class, name = "integer"),
        @JsonSubTypes.Type(value = JsonSchemaBoolean.class, name = "boolean"),
        @JsonSubTypes.Type(value = JsonSchemaObject.class, name = "object"),
        @JsonSubTypes.Type(value = JsonSchemaArray.class, name = "array"),
        @JsonSubTypes.Type(value = JsonSchemaNull.class, name = "null"),
        @JsonSubTypes.Type(value = JsonSchemaRef.class, name = "$ref"),
        @JsonSubTypes.Type(value = JsonSchemaOneOf.class, name = "oneOf")
})
public abstract class JsonSchema extends PageRepresentation {

    @SuppressWarnings("UnstableApiUsage")
    public static final Funnel<JsonSchema> FUNNEL = (from, into) -> {
        PageRepresentation.FUNNEL.funnel(from, into);
        if (from instanceof JsonSchemaString)
            JsonSchemaString.FUNNEL.funnel((JsonSchemaString) from, into);
        else if (from instanceof JsonSchemaNumber)
            JsonSchemaNumber.FUNNEL.funnel((JsonSchemaNumber) from, into);
        else if (from instanceof JsonSchemaInteger)
            JsonSchemaInteger.FUNNEL.funnel((JsonSchemaInteger) from, into);
        else if (from instanceof JsonSchemaBoolean)
            JsonSchemaBoolean.FUNNEL.funnel((JsonSchemaBoolean) from, into);
        else if (from instanceof JsonSchemaObject)
{'fraction_non_alphanumeric': 0.10966623320329433, 'fraction_numerical': 0.00411790203727785, 'mean_word_length': 3.9623655913978495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3962827', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1314, 'n_words': 311}