mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[test framework] more usable MapDataContext
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,23 +17,30 @@ package com.intellij.testFramework;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MapDataContext implements DataContext {
|
||||
private final Map myMap = new HashMap();
|
||||
private final Map<String, Object> myMap = new HashMap<>();
|
||||
|
||||
public MapDataContext() { }
|
||||
|
||||
public MapDataContext(@NotNull Map<DataKey<?>, Object> context) {
|
||||
context.forEach((k, v) -> myMap.put(k.getName(), v));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(String dataId) {
|
||||
public Object getData(@NotNull String dataId) {
|
||||
return myMap.get(dataId);
|
||||
}
|
||||
|
||||
public void put(String dataId, Object data) {
|
||||
public void put(@NotNull String dataId, Object data) {
|
||||
myMap.put(dataId, data);
|
||||
}
|
||||
|
||||
public <T> void put(DataKey<T> dataKey, T data) {
|
||||
public <T> void put(@NotNull DataKey<T> dataKey, T data) {
|
||||
put(dataKey.getName(), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user