Support adding own methods to objects
See: https://groups.google.com/forum/#!searchin/realm-java/complex$20data$20types/realm-java/4XwofSl-iwU/30p8Y6JWt5EJ
+1 for a modern db this should be possible. I've been doing it by starting the method names with 'get' but not sure if that's going to cause unexpected results? Seems to work, but full support would be nice to have.
+1 my team is reconsidering the use of Realm for our app since we need custom logic in our getters & setters
For reference (Five +1's from #637 has been transfered here).
+1 would like to be able to use toString() method which is used in custom adapter a lot.
+1 for ability to override at least toString() and equals() in RealmObject
+1 must have feature
+1
Any updates on this? Currently a lot of my code depends on custom methods like equals() which I cannot change easily (without making my own List class). Could it be explained why other methods cannot be defined in RealmObjects?
+1
For me, this feature is a must-have :/ Is it planned ?
+1 Can't override equals ??
Right now how I work around this is by adding a getter for an ignored field
@Ignore
String method;
public String getMethod();
Verrrrrry temporary :)
We are actively working on it and #1216 is part of the solution
:+1: @emanuelez
+1
I've discovered this can be implemented using the existing realm code by using default methods in an interface (which can be utilized using the gradle-retrolambda plugin. For example a simplification of an interface of mine is:
public interface BaseModel {
boolean isValid();
void removeFromRealm();
default String getUrlString() {
return ModelType.get(this).toString() + "/" + getId();
}
String getId();
void setId(String id);
}
By having my model classes implement BaseModel, I can use getUrlString without issue. This works due to the retrolambda plugin modifying code after the realm plugin. Like normal interfaces you can't define equals, toString, or hashCode, but this is a nice workaround until the folks at realm implement an official way. :)
+1 I seriously can't use Realm until this is added. I would have to add another layer of model objects, and then use an object to object mapper, which defeats the purpose of Realm.
We are actively working on this :)
Any information on when this will be ready for production?
We can't promise a delivery date since we prioritize support first, then bug fixing, and finally the development of new features. Which means that the release date depends on the support load and the bugs to fix.
I know it might be unpleasant not being able to rely on a precise date, but focusing on support is really important to us.
+1