/** * Note: this method gets called iff <code>otherChildren</code> * is non-empty */ private boolean _sameChildren(ArrayList<JsonNode> otherChildren) { int len = otherChildren.size(); if (this.size() != len) { // important: call size() to handle case of null list... return false; } for (int i = 0; i < len; ++i) { if (!_children.get(i).equals(otherChildren.get(i))) { return false; } } return true; } }
/** * Adds a property with the given name <tt>name</tt> and * value <tt>value</tt>. Neither <tt>name</tt> nor <tt>value</tt> can be * <tt>null</tt>. It is illegal to add a property if another with * the same name but different value already exists in this schema. * * @param name The name of the property to add * @param value The value for the property to add * @deprecated use {@link #addProp(String, Object)} */ @Deprecated public synchronized void addProp(String name, JsonNode value) { if (reserved.contains(name)) throw new AvroRuntimeException("Can't set reserved property: " + name); if (value == null) throw new AvroRuntimeException("Can't set a property to null: " + name); JsonNode old = props.get(name); if (old == null) props.put(name, value); else if (!old.equals(value)) throw new AvroRuntimeException("Can't overwrite property: " + name); }
private boolean defaultValueEquals(JsonNode thatDefaultValue) { if (defaultValue == null) return thatDefaultValue == null; if (Double.isNaN(defaultValue.getDoubleValue())) return Double.isNaN(thatDefaultValue.getDoubleValue()); return defaultValue.equals(thatDefaultValue); }
@Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() != getClass()) { return false; } ObjectNode other = (ObjectNode) o; if (other.size() != size()) { return false; } if (_children != null) { for (Map.Entry<String, JsonNode> en : _children.entrySet()) { String key = en.getKey(); JsonNode value = en.getValue(); JsonNode otherValue = other.get(key); if (otherValue == null || !otherValue.equals(value)) { return false; } } } return true; }
+ ". The new default is: " + newField.defaultValue())); } else if(!newField.defaultValue().equals(oldField.defaultValue())) { messages.add(new Message(Level.INFO, "Changed the default value for existing field "
/** * Note: this method gets called iff <code>otherChildren</code> * is non-empty */ private boolean _sameChildren(ArrayList<JsonNode> otherChildren) { int len = otherChildren.size(); if (this.size() != len) { // important: call size() to handle case of null list... return false; } for (int i = 0; i < len; ++i) { if (!_children.get(i).equals(otherChildren.get(i))) { return false; } } return true; } }
@Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() != getClass()) { return false; } ObjectNode other = (ObjectNode) o; if (other.size() != size()) { return false; } if (_children != null) { for (Map.Entry<String, JsonNode> en : _children.entrySet()) { String key = en.getKey(); JsonNode value = en.getValue(); JsonNode otherValue = other.get(key); if (otherValue == null || !otherValue.equals(value)) { return false; } } } return true; }
@Override public boolean equals(final Object o) { return o instanceof ReadOnlyJsonNode && delegate.equals(((ReadOnlyJsonNode)o).delegate); }
@Override public boolean equals(Object obj) { return node.equals(obj); }
@Override public boolean equals(Object obj) { return wrapped.equals(obj); }
@Override public boolean equals(Object obj) { return wrapped.equals(obj); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CustomObject that = (CustomObject) o; if (!container.equals(that.container)) return false; if (!key.equals(that.key)) return false; if (value != null ? !value.equals(that.value) : that.value != null) return false; return true; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; JsonRepresentation other = (JsonRepresentation) obj; if (jsonNode == null) { if (other.jsonNode != null) return false; } else if (!jsonNode.equals(other.jsonNode)) return false; return true; }
public boolean equals(Object other) { if (other == this) return true; if (!(other instanceof Field)) return false; Field that = (Field) other; return (position == that.position) && (schema.equals(that.schema)) && (defaultValue == null ? that.defaultValue == null : (defaultValue.equals(that.defaultValue))); } public int hashCode() { return schema.hashCode(); }
/** * Note: this method gets called iff <code>otherChildren</code> * is non-empty */ private boolean _sameChildren(ArrayList<JsonNode> otherChildren) { int len = otherChildren.size(); if (this.size() != len) { // important: call size() to handle case of null list... return false; } for (int i = 0; i < len; ++i) { if (!_children.get(i).equals(otherChildren.get(i))) { return false; } } return true; } }
private boolean defaultValueEquals(JsonNode thatDefaultValue) { if (defaultValue == null) return thatDefaultValue == null; if (Double.isNaN(defaultValue.getDoubleValue())) return Double.isNaN(thatDefaultValue.getDoubleValue()); return defaultValue.equals(thatDefaultValue); }
/** * Note: this method gets called iff <code>otherChildren</code> * is non-empty */ private boolean _sameChildren(ArrayList<JsonNode> otherChildren) { int len = otherChildren.size(); if (this.size() != len) { // important: call size() to handle case of null list... return false; } for (int i = 0; i < len; ++i) { if (!_children.get(i).equals(otherChildren.get(i))) { return false; } } return true; } }
public boolean validate(String value) { try { if (value == null || !validJson()) return false; String expectedInput = getValue(); logger.debug("Expected JSON Input: {},\nActual JSON Input: {}", expectedInput, value); if (value.isEmpty() || expectedInput.isEmpty()) return value.isEmpty() && expectedInput.isEmpty(); ObjectMapper mapper = new ObjectMapper(); JsonNode expectedJson = mapper.readTree(expectedInput); JsonNode inputJson = mapper.readTree(value); boolean equal = expectedJson.equals(inputJson); if (!equal) logger.warn("Differences exist between the expected JSON value and the encountered value"); return equal; } catch (Exception e) { throw new RuntimeException(e); } }
@Override public boolean matches(Object argument) { try { ObjectMapper objectMapper = new ObjectMapper(); String actual = (String) argument; JsonNode expectedTree = objectMapper.readTree(expected); JsonNode actualTree = objectMapper.readTree(actual); return expectedTree.equals(actualTree); } catch (IOException e) { throw new MotechException("Json parsing failure", e); } }
public boolean equals(Object other) { if (other == this) return true; if (!(other instanceof Field)) return false; Field that = (Field) other; return (name.equals(that.name)) && (schema.equals(that.schema)) && (defaultValue == null ? that.defaultValue == null : (defaultValue.equals(that.defaultValue))) && (order.equals(that.order)) && props.equals(that.props); } public int hashCode() { return name.hashCode() + schema.hashCode(); }