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

io.bitsensor.lib.entity.FalsePositive Maven / Gradle / Ivy

The newest version!
package io.bitsensor.lib.entity;

import io.bitsensor.plugins.shaded.com.fasterxml.jackson.annotation.JsonFormat;
import io.bitsensor.proto.shaded.com.google.re2j.Pattern;
import io.bitsensor.lib.entity.proto.Datapoint;
import io.bitsensor.lib.entity.proto.Detection;

import javax.validation.constraints.NotNull;
import java.util.AbstractMap.SimpleEntry;
import java.util.Date;
import java.util.List;

public class FalsePositive {

    @NotNull
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long detectionHash;

    /**
     * List of key-value pairs in the DataPoint that must match before the @{@link FalsePositive} is considered to be a
     * match
     */
    private List> triggerSet;

    /**
     * List of jregex {@link Pattern} that must match, to declare a {@link Detection} as false positive
     */
    private List keyPatterns;

    private Date creationDate = new Date();
    private String dataPointIdentifier;
    private Detection basedOnDetection;

    /**
     * @param detectionHash       Hash or ruleHash that the false positive matches on
     * @param dataPointIdentifier {@link Datapoint} from which the false positive is added
     * @param triggerNameSet      List of keys and values that all have to match before the {@link Detection} is a false
     *                            positive
     */
    public FalsePositive(Long detectionHash,
                         String dataPointIdentifier,
                         List> triggerNameSet,
                         List keyPatterns
    ) {
        this(detectionHash, dataPointIdentifier, triggerNameSet, keyPatterns, null);
    }

    /**
     * @param detectionHash       Hash or ruleHash that the false positive matches on
     * @param triggerNameSet      List of keys and values that all have to match before the {@link Detection} is a false
     *                            positive
     * @param dataPointIdentifier {@link Datapoint} from which the false positive is added
     * @param basedOnDetection    {@link Detection} that has been triggered but is treated as false positive
     */
    public FalsePositive(Long detectionHash,
                         String dataPointIdentifier,
                         List> triggerNameSet,
                         List keyPatterns,
                         Detection basedOnDetection) {
        this.setDetection(basedOnDetection);
        this.setDetectionHash(detectionHash);
        this.setDataPointIdentifier(dataPointIdentifier);
        this.setKeyPatterns(keyPatterns);
        this.setTriggerSet(triggerNameSet);
    }

    public FalsePositive() {
    }

    public Long getDetectionHash() {
        return detectionHash;
    }

    public void setDetectionHash(Long detectionHash) {
        this.detectionHash = detectionHash;
    }

    /**
     * @return {@link List} of {@link java.util.Map.Entry} with as key the {@link Datapoint} key, and the value it
     * should have. A {@link FalsePositive} should only match if all keys and values match.
     */
    public List> getTriggerSet() {
        return triggerSet;
    }

    public void setTriggerSet(List> triggerSet) {
        this.triggerSet = triggerSet;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public String getDataPointIdentifier() {
        return dataPointIdentifier;
    }

    public void setDataPointIdentifier(String dataPointIdentifier) {
        this.dataPointIdentifier = dataPointIdentifier;
    }

    public Detection getDetection() {
        return basedOnDetection;
    }

    public void setDetection(Detection basedOnDetection) {
        this.basedOnDetection = basedOnDetection;
    }

    public List getKeyPatterns() {
        return keyPatterns;
    }

    public void setKeyPatterns(List keyPatterns) {
        this.keyPatterns = keyPatterns;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy