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

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

Go to download

OpenFlowJ API supporting OpenFlow versions 1.0 through 1.5.1, generated by LoxiGen

The newest version!
package org.projectfloodlight.openflow.protocol.match;

import java.util.Set;

import org.projectfloodlight.openflow.types.OFValueType;

import com.google.common.collect.ImmutableSet;

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

    @SafeVarargs
    public Prerequisite(MatchField field, OFValueType... values) {
        this.field = field;
        /* possible null values, since public constructor */
        if (values == null || values.length == 0) {
            this.any = true;
            this.values = ImmutableSet.of();
        } else {
            this.any = false;
            this.values = ImmutableSet.copyOf(values);
        }
    }

    /**
     * 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;
    }

    /**
     * Get valid/possible values for this prerequisite match.
     *
     * @return unmodifiable set of possible values
     */
    public Set> getValues() {
        return this.values;   
    }

    /**
     * Get the MatchField of this prerequisite.
     *
     * @return the MatchField that is required
     */
    public MatchField getMatchField() {
        return this.field; /* immutable */
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy