question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inheritance / Polymorphism

See original GitHub issue

A highly request feature is polymorphism. Mostly for use in ListAdapters, but a lot of other scenarios exists.

We need support for the following:

  • Abstract RealmObject classes
  • Query support

Example

public abstract Animal extends RealmObject {
  private String name;
}

public class Dog extends Animal {
  private boolean willPlayCatch;
}

public class Spider extends Animal {
  private boolean isScary;
}

// Following should be possible
RealmResults<Animal> animals = realm.where(Animal.class).equalsTo("name","Foo").findAll();
String name = animals.get(0).getName();

RealmResults<Dog> dogs = realm.where(Dog.class).equalsTo("name","Foo").and().equalsTo("willPlayCatch", true).findAll();
String name = dogs.get(0).getName();

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:401
  • Comments:186 (47 by maintainers)

github_iconTop GitHub Comments

66reactions
cmelchiorcommented, Jan 21, 2015

Hi @T-Spoon We have a couple of other major features we would like to look at first, so we don’t have a timeframe yet, sorry. If inheritance is a dealbreaker for you, you should probably not use us this time around. But we do hope you will come back 😃

37reactions
Drakuwacommented, Apr 15, 2016

Oh come on people, do not just comment “+1”, I know my comment also has no point, but, you could all just subscribe to the thread and wait for an actual valid response from someone from the team. This way you’re not just flooding the issue with unnecessary entries…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between Inheritance and Polymorphism
1. Inheritance is one in which a new class is created (derived class) that inherits the features from the already existing class(Base class)....
Read more >
5.4: Difference between Inheritance and Polymorphism
1. Inheritance is one in which a new class is created (derived class) that inherits the features from the already existing class(Base class)....
Read more >
What is the main difference between Inheritance and ...
Polymorphism is an effect of inheritance. It can only happen in classes that extend one another. It allows you to ...
Read more >
Polymorphism vs. Inheritance: Difference Between ... - upGrad
Inheritance is essentially making a class, and then having other classes in your program get their feature form the already existing base class....
Read more >
Inheritance, Encapsulation and Polymorphism
There are three more important concept, inheritance, which makes the OOP code more modular, easier to reuse and build a relationship between classes....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found