Created
November 24, 2016 13:05
-
-
Save mitchwongho/5859ac38c5708b318df160b256dabe68 to your computer and use it in GitHub Desktop.
`Person` model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mitchwongho.test.observablerealms.realms; | |
import android.support.annotation.NonNull; | |
import java.util.UUID; | |
import io.realm.RealmObject; | |
import io.realm.annotations.PrimaryKey; | |
/** | |
* | |
*/ | |
public class Person extends RealmObject { | |
@PrimaryKey | |
public String id; //uuid | |
public String name; //also some uuid | |
public boolean aBoolean; | |
public byte aByte; | |
public short aShort; | |
public int aInt; | |
public float aFloat; | |
public double aDouble; | |
public long timestamp; //System.timeMillis | |
/** | |
* Mandatory no-args constructor | |
*/ | |
public Person() { | |
} | |
public static Person create() { | |
final Person person = new Person(); | |
person.id = UUID.randomUUID().toString(); | |
person.name = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+{}:\"|<>?-=[];'\\,./'"; | |
person.aBoolean = true; | |
person.aByte = Byte.MAX_VALUE; | |
person.aShort = Short.MAX_VALUE; | |
person.aInt = Integer.MAX_VALUE; | |
person.aFloat = Float.MAX_VALUE; | |
person.aDouble = Double.MAX_VALUE; | |
person.timestamp = System.currentTimeMillis(); | |
return person; | |
} | |
public final Person getClone() { | |
final Person clone = new Person(); | |
clone.id = this.id; | |
clone.name = this.name; | |
clone.aBoolean = this.aBoolean; | |
clone.aByte = this.aByte; | |
clone.aShort = this.aShort; | |
clone.aInt = this.aInt; | |
clone.aFloat = this.aFloat; | |
clone.aDouble = this.aDouble; | |
clone.timestamp = this.timestamp; | |
return clone; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment