Realm's model can finally not inherit Realmobject __realmmodel

Source: Internet
Author: User

The old implementation can only be inherited realmobject this abstract class, for some Third-party class libraries, if the same need to inherit some of the base classes, there is likely to be a conflict:

public class User extends Realmobject {
    ...
}

Therefore, starting with version 0.89.0, you can implement a Realmmodel interface directly and precede the class declaration with a @realmclass annotation declaration:

@RealmClass public
class User implements Realmmodel {
    ...
}

Then the method invoked on the Realmobject object can only be invoked in the form of a static method:

With Realmobject
User.deletefromrealm ();
User.isvalid ();
User.addchangelistener (listener);

With Realmmodel
realmobject.deletefromrealm (user);
Realmobject.isvalid (user);
Realmobject.addchangelistener (user, listener);

Refer to official documents: HTTPS://REALM.IO/DOCS/JAVA/0.89.1/#realmmodel-interface
and change log:https://github.com/realm/realm-java/blob/master/changelog.md.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.