diff --git a/platform/testFramework/src/com/intellij/testFramework/MapDataContext.java b/platform/testFramework/src/com/intellij/testFramework/MapDataContext.java index 344d5c6f7aca..e18b7aa8503e 100644 --- a/platform/testFramework/src/com/intellij/testFramework/MapDataContext.java +++ b/platform/testFramework/src/com/intellij/testFramework/MapDataContext.java @@ -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 myMap = new HashMap<>(); + + public MapDataContext() { } + + public MapDataContext(@NotNull Map, 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 void put(DataKey dataKey, T data) { + public void put(@NotNull DataKey dataKey, T data) { put(dataKey.getName(), data); } -} +} \ No newline at end of file