chinwag-android/app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java

128 lines
3.3 KiB
Java
Raw Normal View History

/* Copyright 2017 Andrew Dawson
*
* This file is a part of Tusky.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Tusky; if not,
* see <http://www.gnu.org/licenses>. */
2017-06-29 03:33:20 +10:00
package com.keylesspalace.tusky.db;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import androidx.room.TypeConverter;
import androidx.room.TypeConverters;
import androidx.annotation.Nullable;
import com.keylesspalace.tusky.entity.Status;
2017-06-29 03:33:20 +10:00
/**
* Toot model.
2017-06-29 03:33:20 +10:00
*/
@Entity
@TypeConverters(TootEntity.Converters.class)
2017-06-29 03:33:20 +10:00
public class TootEntity {
@PrimaryKey(autoGenerate = true)
private final int uid;
2017-06-29 03:33:20 +10:00
@ColumnInfo(name = "text")
private final String text;
2017-06-29 03:33:20 +10:00
2017-07-06 00:36:14 +10:00
@ColumnInfo(name = "urls")
private final String urls;
2017-07-06 00:36:14 +10:00
@ColumnInfo(name = "descriptions")
private final String descriptions;
2017-07-08 12:56:07 +10:00
@ColumnInfo(name = "contentWarning")
private final String contentWarning;
2017-07-08 12:56:07 +10:00
@ColumnInfo(name = "inReplyToId")
private final String inReplyToId;
@Nullable
@ColumnInfo(name = "inReplyToText")
private final String inReplyToText;
@Nullable
@ColumnInfo(name = "inReplyToUsername")
private final String inReplyToUsername;
@ColumnInfo(name = "visibility")
private final Status.Visibility visibility;
2017-06-29 03:33:20 +10:00
public TootEntity(int uid, String text, String urls, String descriptions, String contentWarning, String inReplyToId,
@Nullable String inReplyToText, @Nullable String inReplyToUsername,
Status.Visibility visibility) {
this.uid = uid;
2017-06-29 03:33:20 +10:00
this.text = text;
this.urls = urls;
this.descriptions = descriptions;
this.contentWarning = contentWarning;
this.inReplyToId = inReplyToId;
this.inReplyToText = inReplyToText;
this.inReplyToUsername = inReplyToUsername;
this.visibility = visibility;
2017-06-29 03:33:20 +10:00
}
public String getText() {
return text;
2017-07-08 12:56:07 +10:00
}
public String getContentWarning() {
return contentWarning;
2017-07-08 12:56:07 +10:00
}
2017-06-29 03:33:20 +10:00
public int getUid() {
return uid;
}
2017-07-06 00:36:14 +10:00
public String getUrls() {
return urls;
}
public String getDescriptions() {
return descriptions;
}
public String getInReplyToId() {
return inReplyToId;
}
@Nullable
public String getInReplyToText() {
return inReplyToText;
}
@Nullable
public String getInReplyToUsername() {
return inReplyToUsername;
}
public Status.Visibility getVisibility() {
return visibility;
}
public static final class Converters {
@TypeConverter
public Status.Visibility visibilityFromInt(int number) {
return Status.Visibility.byNum(number);
}
@TypeConverter
public int intToVisibility(Status.Visibility visibility) {
return visibility.getNum();
}
2017-07-06 00:36:14 +10:00
}
2017-06-29 03:33:20 +10:00
}