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

org.projectfloodlight.openflow.protocol.match.Prerequisite Maven / Gradle / Ivy

package org.projectfloodlight.openflow.protocol.match;

import java.util.HashSet;
import java.util.Set;

import org.projectfloodlight.openflow.types.OFValueType;

public class Prerequisite> {
    private final MatchField field;
    private final Set> values;
    private boolean any;

    @SafeVarargs
    public Prerequisite(MatchField field, OFValueType... values) {
        this.values = new HashSet>();
        this.field = field;
        if (values == null || values.length == 0) {
            this.any = true;
        } else {
            this.any = false;
            for (OFValueType value : values) {
                this.values.add(value);
            }
        }
    }

    /**
     * Returns true if this prerequisite is satisfied by the given match object.
     *
     * @param match Match object
     * @return true iff prerequisite is satisfied.
     */
    public boolean isSatisfied(Match match) {
        OFValueType res = match.get(this.field);
        if (res == null)
            return false;
        if (this.any)
            return true;
        if (this.values.contains(res)) {
            return true;
        }
        return false;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy