-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-4843 Remove the need for mappers to implement EntityReference…
…Factory
- Loading branch information
Showing
28 changed files
with
160 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
.../main/java/org/hibernate/search/engine/backend/common/spi/DocumentReferenceConverter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
.../java/org/hibernate/search/mapper/pojo/common/spi/PojoEntityReferenceFactoryDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.mapper.pojo.common.spi; | ||
|
||
import org.hibernate.search.engine.common.EntityReference; | ||
import org.hibernate.search.mapper.pojo.model.spi.PojoRawTypeIdentifier; | ||
|
||
/** | ||
* A delegate for the POJO implementation of {@link org.hibernate.search.engine.backend.common.spi.EntityReferenceFactory}. | ||
* <p> | ||
* Implementations of this class generally simply call a constructor. | ||
*/ | ||
@FunctionalInterface | ||
public interface PojoEntityReferenceFactoryDelegate { | ||
|
||
EntityReference create(PojoRawTypeIdentifier<?> typeIdentifier, String name, Object id); | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...c/main/java/org/hibernate/search/mapper/pojo/mapping/impl/PojoEntityReferenceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.mapper.pojo.mapping.impl; | ||
|
||
import org.hibernate.search.engine.backend.common.spi.EntityReferenceFactory; | ||
import org.hibernate.search.engine.common.EntityReference; | ||
import org.hibernate.search.mapper.pojo.common.spi.PojoEntityReferenceFactoryDelegate; | ||
import org.hibernate.search.mapper.pojo.work.impl.PojoWorkTypeContext; | ||
|
||
final class PojoEntityReferenceFactory implements EntityReferenceFactory<EntityReference> { | ||
|
||
public final PojoEntityReferenceFactoryDelegate delegate; | ||
private final PojoTypeManagerContainer typeManagers; | ||
|
||
PojoEntityReferenceFactory(PojoEntityReferenceFactoryDelegate delegate, | ||
PojoTypeManagerContainer typeManagers) { | ||
this.delegate = delegate; | ||
this.typeManagers = typeManagers; | ||
} | ||
|
||
@Override | ||
public EntityReference createEntityReference(String typeName, Object identifier) { | ||
PojoWorkTypeContext<?, ?> typeContext = typeManagers.byEntityName().getOrFail( typeName ); | ||
return delegate.create( typeContext.typeIdentifier(), typeContext.entityName(), identifier ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.