All Downloads are FREE. Search and download functionalities are using the official Maven repository.

shade.com.alibaba.fastjson2.schema.UnresolvedReference Maven / Gradle / Ivy

There is a newer version: 1.3.7
Show newest version
package com.alibaba.fastjson2.schema;

import java.util.Map;

public class UnresolvedReference
        extends JSONSchema {
    final String refName;
    UnresolvedReference(String refName) {
        super(null, null);
        this.refName = refName;
    }

    @Override
    public Type getType() {
        return Type.UnresolvedReference;
    }

    @Override
    public ValidateResult validate(Object value) {
        return JSONSchema.SUCCESS;
    }

    abstract static class ResolveTask {
        abstract void resolve(JSONSchema root);
    }

    static class PropertyResolveTask
            extends ResolveTask {
        final Map properties;
        final String entryKey;
        final String refName;

        PropertyResolveTask(Map properties, String entryKey, String refName) {
            this.properties = properties;
            this.entryKey = entryKey;
            this.refName = refName;
        }

        @Override
        void resolve(JSONSchema root) {
            Map defs = null;
            if (root instanceof ObjectSchema) {
                defs = ((ObjectSchema) root).defs;
            } else if (root instanceof ArraySchema) {
                defs = ((ArraySchema) root).defs;
            }

            if (defs == null) {
                return;
            }

            JSONSchema refSchema = defs.get(refName);
            if (refSchema != null) {
                properties.put(entryKey, refSchema);
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy