Lines 55-60
Link Here
|
55 |
/** |
55 |
/** |
56 |
* Context contains "environment" in which the refactoring was invoked |
56 |
* Context contains "environment" in which the refactoring was invoked |
57 |
* e.g. Java refactoring might put instance of ClasspathInfo here |
57 |
* e.g. Java refactoring might put instance of ClasspathInfo here |
|
|
58 |
* |
59 |
* Context acts as a {@code Map<Class,Object>} keyed off the concrete |
60 |
* implementation class of the "values". |
61 |
* |
58 |
* @see AbstractRefactoring |
62 |
* @see AbstractRefactoring |
59 |
* @author Jan Becicka |
63 |
* @author Jan Becicka |
60 |
*/ |
64 |
*/ |
Lines 74-91
Link Here
|
74 |
* for instance Java impl. puts instance of ClasspathInfo here. |
78 |
* for instance Java impl. puts instance of ClasspathInfo here. |
75 |
* If there is an instance already set for this context, old |
79 |
* If there is an instance already set for this context, old |
76 |
* value is replaced by new one. |
80 |
* value is replaced by new one. |
|
|
81 |
* |
82 |
* @param value the instance the add |
77 |
*/ |
83 |
*/ |
78 |
public void add(@NonNull Object value) { |
84 |
public void add(@NonNull Object value) { |
79 |
Parameters.notNull("value", value); // NOI18N |
85 |
Parameters.notNull("value", value); // NOI18N |
80 |
Object old = lookup(value.getClass()); |
86 |
remove(value.getClass()); |
81 |
if (old!=null) { |
|
|
82 |
instanceContent.remove(old); |
83 |
} |
84 |
instanceContent.add(value); |
87 |
instanceContent.add(value); |
85 |
} |
88 |
} |
86 |
|
89 |
|
87 |
/** |
90 |
/** |
88 |
* Removes value instance from this context. |
91 |
* Removes instance from this context. |
|
|
92 |
* |
93 |
* @param clazz the class to remove the instance of |
94 |
* |
95 |
* @since 1.24 |
89 |
*/ |
96 |
*/ |
90 |
public void remove(@NonNull Class<?> clazz) { |
97 |
public void remove(@NonNull Class<?> clazz) { |
91 |
Parameters.notNull("clazz", clazz); // NOI18N |
98 |
Parameters.notNull("clazz", clazz); // NOI18N |