@Override public Void visit(KVDocument value, TranslatorConsumer arg) { SubDocType type = collectedTypes.get(value); DocStructure.Builder structureBuilder = new DocStructure.Builder(); SubDocument.Builder subDocBuilder = SubDocument.Builder.withKnownType(type); int index = consumeIndex(type); structureBuilder.setIndex(index); structureBuilder.setType(type); subDocBuilder.setIndex(index); subDocBuilder.setDocumentId(docId); ObjectTranslatorConsumer consumer = new ObjectTranslatorConsumer( subDocBuilder, structureBuilder); for (DocEntry<?> entry : value) { consumer.setAttributeName(entry.getKey()); entry.getValue().accept(this, consumer); } splitDocBuilder.add(subDocBuilder.build()); arg.consume(structureBuilder.built()); return null; }
/** * Two entries are equals if their keys and values are equal. * @param obj * @return */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj == null) { return false; } if (!(obj instanceof DocEntry)) { return false; } DocEntry<?> other = (DocEntry) obj; return this.getKey().equals(other.getKey()) && this.getValue().equals(other.getValue()); }
@Override public Void visit(KVDocument value, LinkedList<AttributeReference.Key> arg) { for (DocEntry<?> entry : value) { arg.addLast(new AttributeReference.ObjectKey(entry.getKey())); entry.getValue().accept(this, arg); arg.removeLast(); } ContainsAttributesQueryCriteria caqc = new ContainsAttributesQueryCriteria( basicAttRef.append(arg), value.getKeys(), true); conjunctionBuilder.add(caqc); return null; }
/** * The hashCode of a entry is the hash of its key. * @return */ @Override public int hashCode() { return getKey().hashCode(); }
@Override public String apply(@Nonnull DocEntry<?> input) { return input.getKey(); } }
private SubDocType getSubDocType(KVDocument value) { SubDocType.Builder builder = subDocTypeBuilderProvider.get(); for (DocEntry<?> entry : value) { if (!(entry.getValue() instanceof KVDocument)) { ScalarType type = ScalarType.fromDocType(entry.getValue().getType()); SubDocAttribute att = new SubDocAttribute(entry.getKey(), type); builder.add(att); } } return builder.build(); }
@Override public Void visit(KVDocument value, Arg arg) { preKVValue(value, arg); preDoc(value, arg); for (DocEntry<?> entry : value) { entry.getValue().accept(this, arg); } postDoc(value, arg); postKVValue(value, arg); return null; }