Похожие чаты

Hi guys "in retrofit": We have a model class which its

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?

8 ответов

15 просмотров
X- Автор вопроса

Any idea?

X
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

X- Автор вопроса
Roman Chumachenko
It isn't exactly about retrofit. Thing is Retrofit...

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

X
yep I knew it was from gson but my problem was ab...

As far as I know those annotations are only markers. Rule breaking is done via reflection. Really amusing thing

X- Автор вопроса
Roman Chumachenko
As far as I know those annotations are only marker...

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...

X
if i wanna talk about it i'll give you right becau...

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

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта