-
Notifications
You must be signed in to change notification settings - Fork 13
Identifiers
Identifiers are really usefull in programing, because they index datas and thus improve performances when searching for them. The gold condition is that identifiers must be unique.
In Riot API there are numbers of identifiers: SummonerId, ChampionId, AccountId, ProfileIconId, SummonerSpellId... They are most of the time Long (Int64) or String. League API used to expose methods with identifier parameter as this primitive type. However it appear that it was not clear about what was expected when using them and could lead to errors due to bad usage of the framework. So type alias was created to name parameter type. It was way better but was not perfect since user could use AccountId instead of SummonerId by mistake and would not understand why he receives not found errors. So a new generic class was created in the framework: Identifier. A typical example is Summoner object. It has SummonerId, AccountId and ProfileIconId. Without identifiers, they were all Long (Int64) properties. But now they all have their own type and thus it is impossible to pass an AccountId as a SummonerId to another method.
The generic class is just a wrapper on a primitive value. By doing this, instances that user will manipulate will have a specific identifier type. LeagueAPI will return you instances with identifers already created and that you can send to another method. Like this, it is totally transparent. But if you need to get the primitive value, you'll find a property value in Identifier object.