fields are private and they are read only and there is no initialization in constructor for them
how Call<model> gives them value?
Ex:
public class MyModel{
private String name;
public void getName(){
return name;
}
}
public interface ModelService{
@Get
Call<MyModel> getName();
}
here how Call<MyModel> could gives the name value while name is readonly and it's in distinct class?
Any idea?
It isn't exactly about retrofit. Thing is Retrofit uses converter (gson or whatever you provide to it) and you're question is completely about converter library you use. Assuming that it is Gson (well some other libs I know about do it in same way) it uses java reflection under the hood. And reflection is hell of a magic. It can break all those restrictions like visibility read-only and other limitations
yep I knew it was from gson but my problem was about breaking the java rules of course i think its rule is in "annotations" which gson used that
As far as I know those annotations are only markers. Rule breaking is done via reflection. Really amusing thing
if i wanna talk about it i'll give you right because i dont know what reflection is but if you look for some annotaions they could pass some values in their parentheses...
Just google: java reflection Just to have a general undestanding of it. You won't use on a daily basis especially in android
The structure that shares, it's made for get vale from API, use can get value from api. You can get URL and path from modelServer
Обсуждают сегодня