Mapped Superclass

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Mapped Superclass



I need to mapped a model object, which extends into the object to be inizialized.



Example:


class User

class RequestUser extends User


void main()
User user = new User();
RequestUser reqUser = user;



Is there a way to do it native ?, or should I use an external library?
Which do you recommend?



Thanks!




2 Answers
2



Why "RequestUser" must be a class? It should be a instance of User.





This answer is slightly low quality. It could have been added as a comment.
– cosmoonot
Aug 8 at 18:41





User it is a model, and RequestUser it's other model extended of User. I need instance new RequestUser with User data, i need mapped a superclass. it is understood?
– Juan Ignacio
Aug 8 at 18:44





Cant use initiate you "User" as a "RequestUser"?
– Vinícius Carvalho
Aug 8 at 18:54





@cosmoonot, i'm sorry, but I cant comment in the question, I need to have a 50 reputation to comment
– Vinícius Carvalho
Aug 8 at 18:57





User have your propertys, and UserRequest have user's propertys and more. I need instance new UserRequest with full properties that the class User has. In other languages exist mapped for it. In android, ¿do yo know how do?
– Juan Ignacio
Aug 8 at 19:06



Take a look in this link -> explicit casting from super class to subclass.



If you instantiate a new UserRequest, it will have UserRequest and User properties, UserRequest extends User.
Maybe you should do this:


class User
int id;
String name;

class RequestUser extends User
int requestCode;


public void teste()
User user = new RequestUser()
id = 0;
name = "User1";
;
RequestUser reqUser = (RequestUser)user;






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard