Last active
March 5, 2016 16:02
-
-
Save jmatsu/2b1eef9fe14f7e43e7f2 to your computer and use it in GitHub Desktop.
Orma with Kotlin data class
This file contains 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
@Table | |
data class AuthorizedUser( | |
@Column | |
val ok: Boolean, | |
@Column | |
val url: String, | |
@Column | |
val team: String, | |
@Column | |
val user: String, | |
@PrimaryKey(auto = false) | |
@Column | |
val teamId: String, | |
@Column | |
val userId: String | |
) | |
@Override | |
public AuthorizedUser newModelFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int offset) { | |
// No argument constructor is not defined | |
AuthorizedUser authorizedUser = new AuthorizedUser(); | |
authorizedUser.ok = cursor.getLong(offset + 0) != 0; | |
authorizedUser.url = cursor.getString(offset + 1); | |
authorizedUser.team = cursor.getString(offset + 2); | |
authorizedUser.user = cursor.getString(offset + 3); | |
authorizedUser.userId = cursor.getString(offset + 4); | |
authorizedUser.teamId = cursor.getString(offset + 5); | |
return authorizedUser; | |
} |
This file contains 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
@Table | |
data class AuthorizedUser @Setter constructor( | |
@Column | |
val ok: Boolean, | |
@Column | |
val url: String, | |
@Column | |
val team: String, | |
@Column | |
val user: String, | |
@PrimaryKey(auto = false) | |
@Column | |
val teamId: String, | |
@Column | |
val userId: String | |
) | |
@Override | |
public AuthorizedUser newModelFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int offset) { | |
boolean ok = cursor.getLong(offset + 0) != 0; | |
String url = cursor.getString(offset + 1); | |
String team = cursor.getString(offset + 2); | |
String user = cursor.getString(offset + 3); | |
String userId = cursor.getString(offset + 4); | |
String teamId = cursor.getString(offset + 5); | |
// arg0..arg5 are not defined | |
return new AuthorizedUser(arg0, arg1, arg2, arg3, arg4, arg5); | |
} |
This file contains 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
@Table | |
data class AuthorizedUser( | |
@Column | |
@Setter("ok") | |
val ok: Boolean, | |
@Column | |
@Setter("url") | |
val url: String, | |
@Column | |
@Setter("team") | |
val team: String, | |
@Column | |
@Setter("user") | |
val user: String, | |
@PrimaryKey(auto = false) | |
@Column | |
@Setter("teamId") | |
val teamId: String, | |
@Column | |
@Setter("userId") | |
val userId: String | |
) | |
@Override | |
public AuthorizedUser newModelFromCursor(@NonNull OrmaConnection conn, @NonNull Cursor cursor, int offset) { | |
boolean ok = cursor.getLong(offset + 0) != 0; | |
String url = cursor.getString(offset + 1); | |
String team = cursor.getString(offset + 2); | |
String user = cursor.getString(offset + 3); | |
String userId = cursor.getString(offset + 4); | |
String teamId = cursor.getString(offset + 5); | |
return new AuthorizedUser(ok, url, team, user, teamId, userId); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment