Skip to content

Commit

Permalink
Merge pull request #1938 from scireum/ili/OX-10805
Browse files Browse the repository at this point in the history
Exposes the ImportHandler.newEntity as public callable method
  • Loading branch information
idlira authored Feb 20, 2024
2 parents 2a1305c + 054e86e commit 9fef829
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/main/java/sirius/biz/importer/BaseImportHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,9 @@ public E findInCacheOrLoadAndCreate(Context data) {
return tryFindInCache(data).orElseGet(() -> createOrUpdateNow(load(data, newEntity())));
}

/**
* Creates a new entity of the handled entity type.
*
* @return new entity instance
*/
@Override
@SuppressWarnings("unchecked")
protected E newEntity() {
public E newEntity() {
try {
return (E) descriptor.getType().getConstructor().newInstance();
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException |
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/sirius/biz/importer/ImportHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ E warn(@Nullable E defaultValue,
*/
E findAndLoad(Context data);

/**
* Creates a new entity of the handled entity type.
*
* @return new entity instance
*/
E newEntity();

/**
* Tries to find an entity using the supplied <tt>data</tt> - creates, loads and persists a new entity if no match
* was found.
Expand Down

0 comments on commit 9fef829

Please sign in to comment.