public String getObjectType() { if(objectType != null) return objectType; return dataAccess.getSchema().getName(); }
@Override public HollowSchema getSchema(String name) { return getTypeDataAccess(name).getSchema(); }
@Override public HollowSchema getSchema() { return dataAccess.getSchema(); }
private HollowTypeDataAccess getChildDataAccess(HollowTypeDataAccess typeDataAccess, String childName) { if(typeDataAccess instanceof HollowObjectTypeDataAccess) { HollowObjectSchema schema = (HollowObjectSchema) typeDataAccess.getSchema(); int fieldIdx = schema.getPosition(childName); String childType = schema.getReferencedType(fieldIdx); return dataAccess.getTypeDataAccess(childType); } else if(typeDataAccess instanceof HollowCollectionTypeDataAccess) { HollowCollectionSchema schema = (HollowCollectionSchema) typeDataAccess.getSchema(); return dataAccess.getTypeDataAccess(schema.getElementType()); } else if(typeDataAccess instanceof HollowMapTypeDataAccess) { HollowMapSchema schema = (HollowMapSchema) typeDataAccess.getSchema(); String childType = "key".equals(childName) ? schema.getKeyType() : schema.getValueType(); return dataAccess.getTypeDataAccess(childType); } throw new IllegalArgumentException("I can't create a child node for a " + typeDataAccess.getClass()); }
List<Field> createFields(HollowEffigy effigy) { switch(effigy.dataAccess.getSchema().getSchemaType()) { case OBJECT: return createObjectFields(effigy); case LIST: case SET: return createCollectionFields(effigy); case MAP: return createMapFields(effigy); } throw new IllegalArgumentException(); }
@Override public boolean isExactMatch(HollowTypeDataAccess fromType, int fromOrdinal, HollowTypeDataAccess toType, int toOrdinal) { if(fromType == null || toType == null) return false; DiffEqualOrdinalMap typeMap = equalityMapping.getEqualOrdinalMap(fromType.getSchema().getName()); if(typeMap != null) { MatchIterator matchingToOrdinals = typeMap.getEqualOrdinals(fromOrdinal); while(matchingToOrdinals.hasNext()) { if(toOrdinal == matchingToOrdinals.next()) return true; } } return false; }
private HollowIndexerTraversalNode createChildNode(HollowTypeDataAccess typeDataAccess, String childName) { if(typeDataAccess instanceof HollowObjectTypeDataAccess) { HollowObjectTypeDataAccess objectAccess = (HollowObjectTypeDataAccess) typeDataAccess; HollowObjectSchema schema = objectAccess.getSchema(); int fieldIdx = schema.getPosition(childName); if(schema.getFieldType(fieldIdx) == FieldType.REFERENCE) { String childType = schema.getReferencedType(fieldIdx); HollowTypeDataAccess childTypeAccess = dataAccess.getTypeDataAccess(childType); return createTypeNode(childTypeAccess); } else { return new HollowIndexerObjectFieldTraversalNode(objectAccess, fieldMatchLists); } } else if(typeDataAccess instanceof HollowCollectionTypeDataAccess) { HollowCollectionSchema schema = (HollowCollectionSchema) typeDataAccess.getSchema(); HollowTypeDataAccess childTypeAccess = dataAccess.getTypeDataAccess(schema.getElementType()); return createTypeNode(childTypeAccess); } else if(typeDataAccess instanceof HollowMapTypeDataAccess) { HollowMapSchema schema = (HollowMapSchema) typeDataAccess.getSchema(); String childType = "key".equals(childName) ? schema.getKeyType() : schema.getValueType(); HollowTypeDataAccess childTypeAccess = dataAccess.getTypeDataAccess(childType); return createTypeNode(childTypeAccess); } throw new IllegalArgumentException("I can't create a child node for a " + typeDataAccess.getClass()); }
public static List<EffigyFieldPair> pair(HollowEffigy from, HollowEffigy to, Map<String, PrimaryKey> matchHints) { if(from == null || to == null) return new HollowEffigyNullPartnerPairer(from, to).pair(); if(from.getDataAccess() == null) return new HollowEffigyObjectPairer(from, to).pair(); HollowSchema schema = from.getDataAccess().getSchema(); switch(schema.getSchemaType()) { case OBJECT: return new HollowEffigyObjectPairer(from, to).pair(); case MAP: String keyType = ((HollowMapSchema)schema).getKeyType(); return new HollowEffigyMapPairer(from, to, matchHints.get(keyType)).pair(); case LIST: case SET: String elementType = ((HollowCollectionSchema)schema).getElementType(); return new HollowEffigyCollectionPairer(from, to, matchHints.get(elementType)).pair(); } throw new IllegalArgumentException("I don't know how to pair fields for type " + schema.getName() + "(" + schema.getSchemaType() + ")"); } }
fieldTypeDataAccess[i] = typeDataAccess; if(typeDataAccess instanceof HollowObjectTypeDataAccess) { HollowObjectSchema schema = (HollowObjectSchema)typeDataAccess.getSchema(); if(schema.getFieldType(fieldSchemaPositions[i]) == FieldType.REFERENCE) { fieldSchemaPositions[i] = -1;