Исправления в StorylineContext
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Struchkov Mark 2023-04-23 04:14:21 +03:00
parent 2f2f3319a2
commit 1dabb026f3
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6
4 changed files with 6 additions and 4 deletions

View File

@ -8,7 +8,7 @@ import java.util.Map;
public interface StorylineContext { public interface StorylineContext {
Uni<Void> save(@NotNull String personId, @NotNull ContextKey<?> key, Object objectForSave); <T> Uni<Void> save(@NotNull String personId, @NotNull ContextKey<T> key, T objectForSave);
<T> Uni<T> getByKey(@NotNull String personId, @NotNull ContextKey<T> key); <T> Uni<T> getByKey(@NotNull String personId, @NotNull ContextKey<T> key);

View File

@ -8,7 +8,7 @@ import java.util.Optional;
public interface StorylineContext { public interface StorylineContext {
void save(@NotNull String personId, @NotNull ContextKey<?> key, Object objectForSave); <T> void save(@NotNull String personId, @NotNull ContextKey<T> key, T objectForSave);
<T> Optional<T> getByKey(@NotNull String personId, @NotNull ContextKey<T> key); <T> Optional<T> getByKey(@NotNull String personId, @NotNull ContextKey<T> key);

View File

@ -16,7 +16,8 @@ public class StorylineContextMapImpl implements StorylineContext {
private final Map<String, Map<String, Object>> map = new HashMap<>(); private final Map<String, Map<String, Object>> map = new HashMap<>();
public Uni<Void> save(@NotNull String personId, @NotNull ContextKey<?> key, Object objectForSave) { @Override
public <T> Uni<Void> save(@NotNull String personId, @NotNull ContextKey<T> key, T objectForSave) {
isNotNull(personId, key); isNotNull(personId, key);
map.computeIfAbsent(personId, k -> new HashMap<>()).put(key.getValue(), objectForSave); map.computeIfAbsent(personId, k -> new HashMap<>()).put(key.getValue(), objectForSave);
return Uni.createFrom().voidItem(); return Uni.createFrom().voidItem();

View File

@ -16,8 +16,9 @@ public class StorylineContextMapImpl implements StorylineContext {
private final Map<String, Map<String, Object>> map = new HashMap<>(); private final Map<String, Map<String, Object>> map = new HashMap<>();
@Override @Override
public void save(@NotNull String personId, @NotNull ContextKey<?> key, Object objectForSave) { public <T> void save(@NotNull String personId, @NotNull ContextKey<T> key, T objectForSave) {
isNotNull(personId, key); isNotNull(personId, key);
map.computeIfAbsent(personId, k -> new HashMap<>()).put(key.getValue(), objectForSave); map.computeIfAbsent(personId, k -> new HashMap<>()).put(key.getValue(), objectForSave);
} }