Newer
Older
AlgebraicDataflowArchitectureModel / GameEngine / src / main / java / gameEngine / ResourceManager.java
package gameEngine;

import java.util.ArrayList;
import java.util.List;

public class ResourceManager {
    private final List<String> paths = new ArrayList<>();
    //0番はEmpty用pathのため、削除、上書きは不可能

    public List<String> getPathList(){
        return paths;
    }

    //追加
    public int addPath(String path) {
        paths.add(path);
        return paths.size() - 1;
    }

    //上書き
    public boolean overwritePath(int id, String newPath) {
        if (id > 0 && id < paths.size() && newPath != null) {
            paths.set(id, newPath);
            return true;
        }
        return false;
    }

    //削除
    public boolean removePath(int id) {
        if (id > 0 && id < paths.size()) {
            paths.set(id, null);
            return true;
        }
        return false;
    }

    //取得
    public String getPath(int id) {
        if (id >= 0 && id < paths.size()) {
            return paths.get(id);
        }
        return null;
    }
}