Я занимаюсь разработкой и внедрением новостного приложения, но не могу преобразовать класс модели в typeconverter ниже своего класса модели
@Entity
@ForeignKey(entity = Source.class,parentColumns = "source", childColumns = "content")
public class Article {
@PrimaryKey
@SerializedName("source")
@Expose
@ColumnInfo(name ="source")
@TypeConverters(SourceTypeConverter.class)
private Source source;
public Source getSource() {
return source;
}
public void setSource(Source source) {
this.source = source;
}
@SerializedName("author")
@Expose
@ColumnInfo(name = "author")
private String author;
@SerializedName("title")
@Expose
@ColumnInfo(name = "title")
private String title;
@SerializedName("description")
@Expose
@ColumnInfo(name = "description")
private String description;
@SerializedName("url")
@Expose
@ColumnInfo(name = "url")
private String url;
@SerializedName("urlToImage")
@Expose
@ColumnInfo(name = "urlToImage")
private String urlToImage;
@SerializedName("publishedAt")
@Expose
@ColumnInfo(name = "publishedAt")
private String publishedAt;
@SerializedName("content")
@Expose
@ColumnInfo(name = "content")
private String content;
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUrlToImage() {
return urlToImage;
}
public void setUrlToImage(String urlToImage) {
this.urlToImage = urlToImage;
}
public String getPublishedAt() {
return publishedAt;
}
public void setPublishedAt(String publishedAt) {
this.publishedAt = publishedAt;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
ниже моего класса SourceTypeConverter
public class SourceTypeConverter {
@TypeConverter
public static Source ConvertSource(Source source){
return source == null ? null : new Source(source);
}
}
ниже источникаОткрытый класс .java Source {
@SerializedName("id")
@Expose
private String id;
@SerializedName("name")
@Expose
private String name;
public Source(Source source) {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
ниже Я получаю C: \ Users \ Edgar \ Desktop \ Sport News \ app \ src \ main \ java \ edgar \ yodgorbek \sportnews \ model \ Article.java: 18: error: Невозможно понять, как сохранить это поле в базе данных.Вы можете рассмотреть возможность добавления конвертера типов для него.частный источник;
below my database class
@Database(entities = {Article.class}, version = 1, exportSchema = false)
public abstract class SportNewsDatabase extends RoomDatabase {
public abstract SportNewsDao sportNewsDao();
}