コンストラクタ変更

This commit is contained in:
r-ca 2024-01-14 16:05:23 +09:00
parent 8f0f95d8af
commit b63e2dd862
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -44,41 +44,24 @@ public class DocumentMeta {
String defaultBranch; String defaultBranch;
// Constructor // Constructor
public DocumentMeta() { public DocumentMeta() {
} }
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, List<DocumentTag> tags) { // With all public DocumentMeta(String title, List<DocumentTag> tags, String author, String defaultBranch) {
this.id = id; this.id = UUID.randomUUID().toString();
this.title = title; this.title = title;
this.updatedAt = updatedAt;
this.createdAt = createdAt;
this.tags = tags; this.tags = tags;
this.author = author;
this.defaultBranch = defaultBranch;
} }
public DocumentMeta(String id, String title, Date updatedAt, Date createdAt) { // Without tags public DocumentMeta(String id, String title, List<DocumentTag> tags, String author, String defaultBranch) {
this.id = id; this.id = id;
this.title = title; this.title = title;
this.updatedAt = updatedAt; this.tags = tags;
this.createdAt = createdAt; this.author = author;
this.tags = new ArrayList<>(); this.defaultBranch = defaultBranch;
}
public DocumentMeta(String id, String title) { // Without tags, updatedAt, createdAt
this.id = id;
this.title = title;
// 現在時刻を設定
this.updatedAt = new Date();
this.createdAt = new Date();
this.tags = new ArrayList<>();
}
public DocumentMeta(String title) { // title only
this.id = UUID.randomUUID().toString(); // 新規作成時想定なのでコンストラクタで生成してしまう(使う人が楽なので)
this.title = title;
// 現在時刻を設定
this.updatedAt = new Date();
this.createdAt = new Date();
this.tags = new ArrayList<>();
} }
// Getter // Getter