Skip to content

Commit

Permalink
HSEARCH-3135 Allow passing the value/identifier bridge instance direc…
Browse files Browse the repository at this point in the history
…tly in the programmatic mapping

Because it's easier, and because value bridges are immutable anyway, so
there's nothing wrong with re-using the same instances in multiple
places of the mapping (e.g. a parent class and its child class).

This will help making examples clearer in the next commits.
  • Loading branch information
yrodiere committed Nov 18, 2019
1 parent 159f21b commit a151230
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Expand Up @@ -31,6 +31,15 @@ public interface PropertyMappingDocumentIdOptionsStep extends PropertyMappingSte
*/
PropertyMappingDocumentIdOptionsStep identifierBridge(BeanReference<? extends IdentifierBridge<?>> bridgeReference);

/**
* @param bridgeInstance A bridge instance to use.
* @return {@code this}, for method chaining.
* @see IdentifierBridge
*/
default PropertyMappingDocumentIdOptionsStep identifierBridge(IdentifierBridge<?> bridgeInstance) {
return identifierBridge( BeanReference.ofInstance( bridgeInstance ) );
}

/**
* @param binder A {@link IdentifierBinder} responsible for creating a bridge.
* @return {@code this}, for method chaining.
Expand Down
Expand Up @@ -36,6 +36,15 @@ public interface PropertyMappingFieldOptionsStep<S extends PropertyMappingFieldO
*/
S valueBridge(BeanReference<? extends ValueBridge<?, ?>> bridgeReference);

/**
* @param bridgeInstance The bridge instance to use.
* @return {@code this}, for method chaining.
* @see GenericField#valueBridge()
*/
default S valueBridge(ValueBridge<?, ?> bridgeInstance) {
return valueBridge( BeanReference.ofInstance( bridgeInstance ) );
}

/**
* @param binder A {@link ValueBinder} responsible for creating a bridge.
* @return {@code this}, for method chaining.
Expand Down

0 comments on commit a151230

Please sign in to comment.