Make entity object of event optional (#1209)
* explicitly return an optional entity by an event Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io> * fix assertions in tests Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.remote.EventEntityManagerHolder;
|
||||
import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
@@ -52,11 +54,11 @@ public class RemoteEntityEvent<E extends TenantAwareBaseEntity> extends RemoteId
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public E getEntity() {
|
||||
public Optional<E> getEntity() {
|
||||
if (entity == null) {
|
||||
entity = reloadEntityFromRepository();
|
||||
}
|
||||
return entity;
|
||||
return Optional.ofNullable(entity);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user