com.networknt.oas.jsonoverlay.OverlayFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-parser Show documentation
Show all versions of openapi-parser Show documentation
A light-weight, fast OpenAPI 3.0 parser and validator
/*******************************************************************************
* Copyright (c) 2017 ModelSolv, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* ModelSolv, Inc. - initial API and implementation and/or initial documentation
*******************************************************************************/
package com.networknt.oas.jsonoverlay;
import com.fasterxml.jackson.databind.JsonNode;
public abstract class OverlayFactory> {
private final Class super OV> overlayClass = getOverlayClass();
public OV create(V value, JsonOverlay> parent, ReferenceRegistry refReg) {
return _create(value, parent, refReg);
}
public OV create(JsonNode json, JsonOverlay> parent, ReferenceRegistry refReg) {
return create(json, parent, false, refReg);
}
public OV create(JsonNode json, JsonOverlay> parent, boolean partial, ReferenceRegistry refReg) {
if (!partial && refReg.hasOverlay(json)) {
@SuppressWarnings("unchecked")
OV overlay = (OV) refReg.getOverlay(json);
if (parent != null) {
overlay.setParent(parent);
}
return overlay;
} else {
OV overlay = _create(json, parent, refReg);
if (!partial) {
refReg.setOverlay(json, overlay);
}
return overlay;
}
}
public boolean isCompatible(JsonOverlay> overlay) {
return overlayClass.isAssignableFrom(overlay.getClass());
}
protected abstract Class super OV> getOverlayClass();
public abstract OV _create(V value, JsonOverlay> parent, ReferenceRegistry refReg);
public abstract OV _create(JsonNode json, JsonOverlay> parent, ReferenceRegistry refReg);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy