com.sippnex.fileblade.dtos.FilebladeItemDto Maven / Gradle / Ivy
package com.sippnex.fileblade.dtos;
import com.sippnex.fileblade.entities.Directory;
import com.sippnex.fileblade.entities.File;
import com.sippnex.fileblade.entities.FilebladeItem;
public abstract class FilebladeItemDto {
private Long id;
private String name;
private String path;
private Long parentDirectoryId;
private Type type;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public Long getParentDirectoryId() {
return parentDirectoryId;
}
public void setParentDirectoryId(Long parentDirectoryId) {
this.parentDirectoryId = parentDirectoryId;
}
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public static FilebladeItemDto parse(FilebladeItem filebladeItem, String serverBaseUrl) {
if(filebladeItem instanceof Directory) {
return DirectoryDto.parse((Directory)filebladeItem, serverBaseUrl);
} else if(filebladeItem instanceof File) {
return FileDto.parse((File)filebladeItem, serverBaseUrl);
} else {
System.out.println("Error parsing filebladeitem-dto: Unknown class type of entity");
return null;
}
}
public enum Type {
File,
Directory
}
}