How would i show that Class1Repo uses Class1 as a type in this UML class diagram? Do i put something on the dashed line or should i specify which type the methods return in Class1?
interface ISomeInterface<T>
{
T? GetById(string id);
List<T> GetAll();
}
class Class1Repo : ISomeInterface<Class1>
{
public Class1? GetById(string id) {
return new Class1(id);
}
public List<Class1> GetAll() {
return new List<Class1>();
}
}
There are several possibilities, the main ones using the «bind» relationship, either explicitly or implicitly (in which case the root interface does not even need to be in the same diagram):
One could even think of binding directly the class to the template interface, considering that:
UML specs, section 9.3.3.1: (...) the details of how the contents are merged into a bound element are left open. (...) A bound Classifier may have contents in addition to those resulting from its bindings.
However I would not advise it to keep making a strong difference between realization and template binding.
P.S: What is currently missing in UML is a way to show how the specific classes in the different repositories are related to the T in the template interface. Indeed, you could show the association of ISomeInterface with T, but not UML semantics unambiguously relate this T to the parameter name T. You could eventually think of using a template class with parameter T, named T itself, to show that we are still at template naming. But again this is not a defined semantic in the UML specs.