use of com.fasterxml.jackson.core.JsonPointer in project torodb by torodb.
the class DescriptionFactoryWrapper method expectArrayFormat.
@Override
public JsonArrayFormatVisitor expectArrayFormat(JavaType convertedType) {
final JsonPointer jsonPointer = getJsonPointer();
return new JsonArrayFormatVisitor.Base(getProvider()) {
@Override
public void itemsFormat(JsonFormatVisitable handler, JavaType elementType) throws JsonMappingException {
SerializerProvider p = getProvider();
JsonSerializer<Object> s = p.findValueSerializer(elementType);
s.acceptJsonFormatVisitor(new DescriptionFactoryWrapper(DescriptionFactoryWrapper.this, jsonPointer.append(JsonPointer.valueOf("/<index>")), p), elementType);
}
};
}
use of com.fasterxml.jackson.core.JsonPointer in project torodb by torodb.
the class DescriptionFactoryWrapper method expectObjectFormat.
@Override
public JsonObjectFormatVisitor expectObjectFormat(JavaType convertedType) {
final JsonPointer jsonPointer = getJsonPointer();
return new JsonObjectFormatVisitor.Base(getProvider()) {
@Override
public void property(BeanProperty prop) throws JsonMappingException {
visitProperty(prop, false);
}
@Override
public void optionalProperty(BeanProperty prop) throws JsonMappingException {
visitProperty(prop, true);
}
private void visitProperty(BeanProperty prop, boolean optional) throws JsonMappingException {
JsonPointer propPointer = jsonPointer.append(JsonPointer.valueOf("/" + prop.getName()));
document(propPointer, prop);
SerializerProvider p = getProvider();
JsonSerializer<Object> s = p.findValueSerializer(prop.getType(), prop);
s.acceptJsonFormatVisitor(new DescriptionFactoryWrapper(DescriptionFactoryWrapper.this, propPointer, p), prop.getType());
}
};
}
use of com.fasterxml.jackson.core.JsonPointer in project torodb by torodb.
the class ConfigUtils method transformConstraintsValidation.
private static <T> IllegalArgumentException transformConstraintsValidation(Set<ConstraintViolation<T>> constraintViolations) {
ConstraintViolation<T> constraintViolation = constraintViolations.iterator().next();
Path path = constraintViolation.getPropertyPath();
JsonPointer jsonPointer = toJsonPointer(path);
return new IllegalArgumentException("Constraint validation errors at " + jsonPointer.toString() + ": " + constraintViolation.getMessage());
}
use of com.fasterxml.jackson.core.JsonPointer in project KaiZen-OpenAPI-Editor by RepreZen.
the class AbstractJsonHyperlinkDetector method detectHyperlinks.
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
JsonDocument document = (JsonDocument) textViewer.getDocument();
JsonPointer basePath = document.getPath(region);
if (!canDetect(basePath)) {
return null;
}
HyperlinkInfo info = getHyperlinkInfo(textViewer, region);
if (info == null) {
return null;
}
return doDetect(document, textViewer, info, basePath);
}
use of com.fasterxml.jackson.core.JsonPointer in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonReferenceFactory method doCreate.
public JsonReference doCreate(String value, Object source) {
String notNull = Strings.nullToEmpty(value);
URI uri;
try {
uri = URI.create(notNull);
} catch (NullPointerException | IllegalArgumentException e) {
// try to encode illegal characters, e.g. curly braces
try {
uri = URI.create(URLUtils.encodeURL(notNull));
} catch (NullPointerException | IllegalArgumentException e2) {
return new JsonReference(null, null, false, false, false, source);
}
}
String fragment = uri.getFragment();
JsonPointer pointer = null;
try {
pointer = JsonPointer.compile(Strings.emptyToNull(fragment));
} catch (IllegalArgumentException e) {
// let the pointer be null
}
uri = uri.normalize();
boolean absolute = uri.isAbsolute();
boolean local = !absolute && uri.getPath().isEmpty();
// should warn when using curly braces
boolean warnings = notNull.contains("{") || uri.toString().contains("}");
return new JsonReference(uri, pointer, absolute, local, warnings, source);
}
Aggregations