return getBridge( getMetadata(), fieldName );
}
private FieldBridge getBridge(TypeMetadata typeMetadata, String fieldName) {
// process base fields
DocumentFieldMetadata documentFieldMetadata = typeMetadata.getDocumentFieldMetadataFor( fieldName );
if ( documentFieldMetadata != null && documentFieldMetadata.getFieldBridge() != null ) {
return documentFieldMetadata.getFieldBridge();
}
// process embedded fields
FieldBridge fieldBridge;
for ( EmbeddedTypeMetadata embeddedTypeMetadata : typeMetadata.getEmbeddedTypeMetadata() ) {
fieldBridge = getBridge( embeddedTypeMetadata, fieldName );
if ( fieldBridge != null ) {
return fieldBridge;
}
}
// process null embedded fields
for ( EmbeddedTypeMetadata embeddedTypeMetadata : typeMetadata.getEmbeddedTypeMetadata() ) {
fieldBridge = getNullBridge( embeddedTypeMetadata, fieldName );
if ( fieldBridge != null ) {
return fieldBridge;
}
}
//process class bridges
DocumentFieldMetadata fieldMetadata = typeMetadata.getFieldMetadataForClassBridgeField( fieldName );
fieldBridge = fieldMetadata == null ? null : fieldMetadata.getFieldBridge();
return fieldBridge;
}