Похожие чаты

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 ответов

12 просмотров
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

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

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

30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
Also, why can’t the community have a vote/ say when it comes to initiatives like buybacks. Isn’t the point of crypto decentralisation? Don’t we deserve input as long term supp...
👨🏽‍🦰
13
Привет)) уже кажется эту тему перемусолили, но вот я так и не понял. Я сейчас сижу на 27дюймов 2к мониторе. На Актуальной макоси, если я куплю 27д 4к монитор: - будет ли изобр...
Vladislav Piskunov
16
any reference of this implementation?
BitBuddha
29
Hi guys, any problem with Pulsebrige? Trying to transfer from wETH to ETH. First it tells me to connect my metamask "through mobile app" not desktop. Then I did and confirmed ...
Snowflakecrypto
13
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
13
Карта сайта