public boolean inherits(StructDataType type) { if (equals(type)) return true; if (superType != null && superType.inherits(type)) return true; return false; }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof StructDataType)) return false; if (!super.equals(o)) return false; StructDataType that = (StructDataType) o; if (superType != null ? !superType.equals(that.superType) : that.superType != null) return false; return true; }
public boolean equals(Object o) { if (!(o instanceof DocumentType)) return false; DocumentType other = (DocumentType) o; // Ignore whether one of them have added inheritance to super Document.0 type if (super.equals(o) && headerType.equals(other.headerType) && bodyType.equals(other.bodyType)) { if ((inherits.size() > 1 || other.inherits.size() > 1) || (inherits.size() == 1 && other.inherits.size() == 1)) { return inherits.equals(other.inherits); } return !(((inherits.size() == 1) && !inherits.get(0).getDataTypeName().equals(new DataTypeName("document"))) || ((other.inherits.size() == 1) && !other.inherits.get(0).getDataTypeName().equals(new DataTypeName("document")))); } return false; }
@Override public void assign(Object o) { if ((o instanceof Struct) && ((Struct) o).getDataType().equals(getDataType())) { clear(); Iterator<Map.Entry<Field,FieldValue>> otherValues = ((Struct) o).iterator(); while (otherValues.hasNext()) { Map.Entry<Field, FieldValue> otherEntry = otherValues.next(); setFieldValue(otherEntry.getKey(), otherEntry.getValue()); } } else { throw new IllegalArgumentException("Type " + o.getClass() + " can not specify a " + getClass() + " instance"); } }
@Override public void printXml(XmlStream xml) { if (getDataType().equals(PositionDataType.INSTANCE)) { try { PositionDataType.renderXml(this, xml); return; } catch (RuntimeException e) { // fallthrough to handling below } } XmlSerializationHelper.printStructXml(this, xml); }
private void derive(Search search, DocumentSummary documentSummary) { if (documentSummary==null) return; for (SummaryField summaryField : documentSummary.getSummaryFields()) { List<String> from = toStringList(summaryField.sourceIterator()); if (doMapField(search, summaryField)) { SDField sdField = search.getConcreteField(summaryField.getName()); if (sdField != null && PositionDataType.INSTANCE.equals(sdField.getDataType())) { summaryMap.put(summaryField, Collections.singletonList(summaryField.getName())); } else { summaryMap.put(summaryField, from); } } } }