java - Get child model from parent class -



java - Get child model from parent class -

i've create simple self-made activerecord class project.

only stuck on problem have getmodel() in player class, beingness extended activerecord class.

when want utilize getmodel() method activerecord class, cant utilize cause it's not same type. don't want reference player here, because want utilize multiple models.

anyone has solution?

ok got up:

abstract class activerecord<t> { private t model; public t getmodel() { homecoming this.model; } } public class player extends activerecord<player> { } public class event extends activerecord<event> { }

but when seek output this.model in activerecord class, homecoming null. wrong here?

your method definition needs this

public class<? extends activerecord> getmodel();

meaning of homecoming type of class extends activerecord. when kid homecoming player.class player extends activerecord.

a brief note if getmodel homecoming object of class should remove class method function

public <? extends activerecord> getmodel();

java activerecord reflection

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -