Skip to content

Commit 25d16d6

Browse files
committed
added supress warnings
1 parent 0b78c79 commit 25d16d6

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed

app/src/main/java/promise/base/AppDatabase.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package promise.base
1515

16+
import promise.base.comment.Like
1617
import promise.base.comment.PostComment
1718
import promise.base.photo.Photo
1819
import promise.base.post.Post
@@ -26,7 +27,8 @@ import promise.db.PromiseDatabase
2627
PostComment::class,
2728
Photo::class,
2829
Post::class,
29-
Todo::class
30+
Todo::class,
31+
Like::class
3032
]
3133
)
3234
abstract class AppDatabase(fastDatabase: FastDatabase)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright 2017, Peter Vincent
3+
* Licensed under the Apache License, Version 2.0, Android Promise.
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing,
8+
* software distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
package promise.base.comment;
15+
16+
import android.annotation.SuppressLint;
17+
18+
import org.jetbrains.annotations.NotNull;
19+
20+
import promise.base.ID;
21+
import promise.base.post.Post;
22+
import promise.database.AddedEntity;
23+
import promise.database.Entity;
24+
import promise.database.HasOne;
25+
import promise.db.ActiveRecord;
26+
27+
@SuppressLint("ParcelCreator")
28+
@Entity
29+
@AddedEntity(fromVersion = 1, toVersion = 2)
30+
public class Like extends ActiveRecord<Like> {
31+
private ID uId;
32+
33+
@HasOne
34+
private Post post;
35+
36+
37+
@Override
38+
public String toString(){
39+
return
40+
"Comment{" +
41+
",id = '" + uId + '\'' +
42+
43+
"}";
44+
}
45+
46+
@NotNull
47+
@Override
48+
public Like getEntity() {
49+
return this;
50+
}
51+
52+
public ID getUId() {
53+
return uId;
54+
}
55+
56+
public void setUId(ID uId) {
57+
this.uId = uId;
58+
}
59+
60+
public void setPost(Post post) {
61+
this.post = post;
62+
}
63+
64+
public Post getPost() {
65+
return post;
66+
}
67+
}

app/src/main/java/promise/base/post/Post.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.List;
88

99
import promise.base.ID;
10+
import promise.base.comment.Like;
1011
import promise.base.comment.PostComment;
1112
import promise.base.photo.Photo;
1213
import promise.db.ActiveRecord;
@@ -39,6 +40,8 @@ public String toString() {
3940
@HasMany
4041
private List<Photo> photos;
4142

43+
@HasMany
44+
private List<Like> likes;
4245

4346
public String getTitle(){
4447
return title;
@@ -96,6 +99,14 @@ public void setPhotos(List<Photo> photos) {
9699
this.photos = photos;
97100
}
98101

102+
public List<Like> getLikes() {
103+
return likes;
104+
}
105+
106+
public void setLikes(List<Like> likes) {
107+
this.likes = likes;
108+
}
109+
99110
@NotNull
100111
@Override
101112
public Post getEntity() {

compiler/src/main/java/promise/database/ompiler/DatabaseEntityAnnotatedProcessor.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package promise.database.ompiler
1515

16+
import com.squareup.javapoet.AnnotationSpec
1617
import com.squareup.javapoet.ClassName
1718
import com.squareup.javapoet.JavaFile
1819
import com.squareup.javapoet.MethodSpec
@@ -84,8 +85,12 @@ class DatabaseEntityAnnotatedProcessor(private val processingEnv: ProcessingEnvi
8485
.build()
8586
})
8687

88+
val supressWarningsSpec = AnnotationSpec.builder(SuppressWarnings::class.java)
89+
.addMember("value" , "{\"unchecked\"}")
90+
8791
classBuilder.superclass(ClassName.get(pack, className))
8892
.addAnnotation(databaseAnnotationSpec)
93+
.addAnnotation(supressWarningsSpec.build())
8994
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
9095
.addMethod(constructorMethod.build())
9196

@@ -94,6 +99,7 @@ class DatabaseEntityAnnotatedProcessor(private val processingEnv: ProcessingEnvi
9499
.addModifiers(Modifier.PUBLIC)
95100
.returns(it.asTableClassName(processingEnv))
96101
.addCode(JavaUtils.generateGetTableStatement(processingEnv, it))
102+
.addAnnotation(supressWarningsSpec.build())
97103
.build())
98104
}
99105

0 commit comments

Comments
 (0)