All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sitoolkit.wt.gui.domain.script.CaseNoCache Maven / Gradle / Ivy

The newest version!
package io.sitoolkit.wt.gui.domain.script;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CaseNoCache {

  private Map cache = new HashMap<>();

  public CaseNoCache() {
    // TODO Auto-generated constructor stub
  }

  public void putCaesNos(File testScript, List caseNos) {
    cache.put(toCacheKey(testScript), new TestScript(testScript, caseNos));
  }

  public List getCaseNosIfNotModified(File testScript) {
    String key = toCacheKey(testScript);
    TestScript cachedTestScript = cache.get(key);

    if (cachedTestScript == null) {
      return null;
    }

    if (key.equals(toCacheKey(cachedTestScript))) {
      return cachedTestScript.caseNos;
    }
    return null;
  }

  private String toCacheKey(File file) {
    return file.getAbsolutePath() + ";" + file.lastModified();
  }

  private String toCacheKey(TestScript script) {
    return script.path + ";" + script.lastModified;
  }

  class TestScript {

    String path;

    long lastModified;

    List caseNos;

    public TestScript(File file, List caseNos) {
      super();
      this.path = file.getAbsolutePath();
      this.lastModified = file.lastModified();
      this.caseNos = caseNos;
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy