tw.yukina.notion.sdk.model.block.SyncedBlock Maven / Gradle / Ivy
package tw.yukina.notion.sdk.model.block;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.*;
import org.jetbrains.annotations.NotNull;
import tw.yukina.notion.sdk.model.common.unit.BlockUnit;
import java.util.List;
@Getter
@Setter
@ToString(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@JsonDeserialize(using = JsonDeserializer.None.class)
public class SyncedBlock extends Block {
private static final String SYNCED_BLOCK_FIELD = "synced_block";
@JsonProperty(SYNCED_BLOCK_FIELD)
private Synced synced;
@NotNull
public static SyncedBlock of(){
Synced synced = new Synced();
SyncedBlock syncedBlock = new SyncedBlock(synced);
syncedBlock.setType(BlockType.SYNCED_BLOCK);
return syncedBlock;
}
@NotNull
public static SyncedBlock of(String blockId){
Synced synced = new Synced();
synced.setBlockUnit(BlockUnit.of(blockId));
SyncedBlock syncedBlock = new SyncedBlock(synced);
syncedBlock.setType(BlockType.SYNCED_BLOCK);
return syncedBlock;
}
@NotNull
public static SyncedBlock of(List children){
Synced synced = new Synced();
synced.setChildren(children);
SyncedBlock syncedBlock = new SyncedBlock(synced);
syncedBlock.setType(BlockType.SYNCED_BLOCK);
return syncedBlock;
}
}