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:
Stefan Klotz
2021-12-08 11:28:01 +01:00
committed by GitHub
parent 7cc89d6291
commit 476d1c37ed
7 changed files with 59 additions and 43 deletions

View File

@@ -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")