@Override
@Nullable
public <T> T getConvertedValue(@NotNull final PsiElement context,
@NotNull final StrutsConstantKey<T> strutsConstantKey) {
final PsiFile containingFile = context.getContainingFile();
final StrutsModel strutsModel = getStrutsModel(containingFile);
if (strutsModel == null) {
return null;
}
final String stringValue = getStringValue(containingFile,
strutsModel,
strutsConstantKey.getKey());
if (stringValue == null) {
return null;
}
final Converter<T> converter = findConverter(context, strutsConstantKey);
if (converter == null) {
//noinspection unchecked
return (T) stringValue;
}
final DomFileElement<StrutsRoot> first = strutsModel.getRoots().iterator().next();
final ConvertContext convertContext = ConvertContextFactory.createConvertContext(first);
//noinspection unchecked
return converter.fromString(stringValue, convertContext);
}