framevpm-master/src/main/java/framevpm/learning/splitter/fileMeta/VulnerabilityInfo.java
package framevpm.learning.splitter.fileMeta;

import java.io.Serializable;

public class VulnerabilityInfo implements Serializable {
    private static final long serialVersionUID = 20180630L;
    private String cwe;
    private double cvss;
    private String cve;
    private int numberOfVuln;
    private long timestampDiscover;

    public VulnerabilityInfo(String cwe, String cvss, String cve, long timestampDiscover) {
        this.cwe = cwe;
        this.timestampDiscover = timestampDiscover;
        if (cvss != null) {
            this.cvss = Double.parseDouble(cvss);
        } else {
            this.cvss = 0;
        }
        this.cve = cve;
        numberOfVuln = 1;
    }

    public String getCwe() {
        return cwe;
    }

    public double getCvss() {
        return cvss;
    }

    public String getCve() {
        return cve;
    }

    public int getNumberOfVuln() {
        return numberOfVuln;
    }

    public long getTimestampDiscover() {
        return timestampDiscover;
    }

    public void update(String cwe, String cvss, String cve, long creationTime) {
        numberOfVuln++;
        double newCvss;
        if (creationTime < timestampDiscover)
            timestampDiscover = creationTime;
        if (cvss != null) {
            newCvss = Double.parseDouble(cvss);
        } else {
            newCvss = 0;
        }
        if (newCvss > this.cvss) {
            this.cvss = newCvss;
            this.cwe = cwe;
            this.cve = cve;
        }
    }
}
