@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof JsonReference)) { return false; } JsonReference other = (JsonReference) obj; if (pointer == null) { if (other.pointer != null) { return false; } } else if (!pointer.equals(other.pointer)) { return false; } if (uri == null) { if (other.uri != null) { return false; } } else if (!uri.equals(other.uri)) { return false; } return true; }
@Override public boolean canProvideContentAssist(TypeDefinition type) { return type != null && pointer.equals(type.getPointer()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PropertyLocator other = (PropertyLocator) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (pointer == null) { if (other.pointer != null) return false; } else if (!pointer.equals(other.pointer)) return false; if (vector == null) { if (other.vector != null) return false; } else if (!vector.equals(other.vector)) return false; return true; }
/** * Returns all the nodes whose type match the given pointer. * * @param typePointer * pointer of a type present in the schema * @return list of nodes being instance of the type */ public List<AbstractNode> findByType(JsonPointer typePointer) { List<AbstractNode> instances = new ArrayList<>(); for (AbstractNode node : allNodes()) { if (node.getType() != null && typePointer.equals(node.getType().getPointer())) { instances.add(node); } } return instances; }
/** * Returns the type of a node. * * <br/> * * Note: this method should be used only during initialization of a model. * * @param node * @return node's type */ public TypeDefinition getType(AbstractNode node) { JsonPointer pointer = node.getPointer(); if (JsonPointer.compile("").equals(pointer)) { return swaggerType.getType(); } String[] paths = pointer.toString().substring(1).split("/"); TypeDefinition current = swaggerType.getType(); if (current != null) { for (String property : paths) { TypeDefinition next = current.getPropertyType(property); // not found, we stop here if (next == null) { break; } current = next; } } return current; }
@Override JsonNode apply(final JsonNode node) { if (from.equals(path)) { return node; } if (node.at(from).isMissingNode()) { throw new JsonPatchException("non-existent source path: " + from); } final JsonNode sourceParent = ensureSourceParent(node, from); // Remove final String raw = from.last().getMatchingProperty(); final JsonNode source; if (sourceParent.isObject()) { source = ((ObjectNode) sourceParent).remove(raw); } else { source = ((ArrayNode) sourceParent).remove(Integer.parseInt(raw)); } // Add if (path.toString().isEmpty()) { return source; } final JsonNode targetParent = ensureTargetParent(node, path); return targetParent.isArray() ? AddOperation.addToArray(path, node, source) : AddOperation.addToObject(path, node, source); } }
@Override JsonNode apply(final JsonNode node) { if (from.equals(path)) { return node; } if (node.at(from).isMissingNode()) { throw new JsonPatchException("non-existent source path: " + from); } final JsonNode sourceParent = ensureSourceParent(node, from); // Remove final String raw = from.last().getMatchingProperty(); final JsonNode source; if (sourceParent.isObject()) { source = ((ObjectNode) sourceParent).remove(raw); } else { source = ((ArrayNode) sourceParent).remove(Integer.parseInt(raw)); } // Add if (path.toString().isEmpty()) { return source; } final JsonNode targetParent = ensureTargetParent(node, path); return targetParent.isArray() ? AddOperation.addToArray(path, node, source) : AddOperation.addToObject(path, node, source); } }
@Override JsonNode apply(final JsonNode node) { if (from.equals(path)) { return node; } if (node.at(from).isMissingNode()) { throw new JsonPatchException("non-existent source path: " + from); } final JsonNode sourceParent = ensureSourceParent(node, from); // Remove final String raw = from.last().getMatchingProperty(); final JsonNode source; if (sourceParent.isObject()) { source = ((ObjectNode) sourceParent).remove(raw); } else { source = ((ArrayNode) sourceParent).remove(Integer.parseInt(raw)); } // Add if (path.toString().isEmpty()) { return source; } final JsonNode targetParent = ensureTargetParent(node, path); return targetParent.isArray() ? AddOperation.addToArray(path, node, source) : AddOperation.addToObject(path, node, source); } }