com.networknt.schema.resource.PrefixSchemaMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-schema-validator Show documentation
Show all versions of json-schema-validator Show documentation
A json schema validator that supports draft v4, v6, v7, v2019-09 and v2020-12
The newest version!
package com.networknt.schema.resource;
import com.networknt.schema.AbsoluteIri;
/**
* Prefix implementation of {@link SchemaMapper}.
*/
public class PrefixSchemaMapper implements SchemaMapper {
private final String source;
private final String replacement;
public PrefixSchemaMapper(String source, String replacement) {
this.source = source;
this.replacement = replacement;
}
@Override
public AbsoluteIri map(AbsoluteIri absoluteIRI) {
String absoluteIRIString = absoluteIRI != null ? absoluteIRI.toString() : null;
if (absoluteIRIString != null && absoluteIRIString.startsWith(source)) {
return AbsoluteIri.of(replacement + absoluteIRIString.substring(source.length()));
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy