@SafeVarargs public Prerequisite(MatchField<T> field, OFValueType<T>... values) { this.values = new HashSet<OFValueType<T>>(); this.field = field; if (values == null || values.length == 0) { this.any = true; } else { this.any = false; for (OFValueType<T> 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<T> res = match.get(this.field); if (res == null) return false; if (this.any) return true; if (this.values.contains(res)) { return true; } return false; }
@SafeVarargs public Prerequisite(MatchField<T> field, OFValueType<T>... 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); } }
@SuppressWarnings("unchecked") public <T extends OFValueType<T>> OFOxm<T> get(MatchField<T> matchField) { return (OFOxm<T>) oxmMap.get(matchField.id); }
public <T extends OFValueType<T>> void set(OFOxm<T> oxm) { oxmMap.put(oxm.getMatchField().id, oxm); }
public <T extends OFValueType<T>> void unset(MatchField<T> matchField) { oxmMap.remove(matchField.id); }
@SuppressWarnings("unchecked") public <T extends OFValueType<T>> OFOxs<T> get(StatField<T> statField) { return (OFOxs<T>) oxsMap.get(statField.id); }
public <T extends OFValueType<T>> void set(OFOxs<T> oxs) { oxsMap.put(oxs.getStatField().id, oxs); }
public <T extends OFValueType<T>> void unset(StatField<T> statField) { oxsMap.remove(statField.id); }
/** * Returns a value for the given field if: * <ul> * <li>Field is supported * <li>Field is not fully wildcarded * <li>Prerequisites are ok * </ul> * If one of the above conditions does not hold, returns null. Value is returned masked if partially wildcarded. * * @param field Match field to retrieve * @return Value of match field (may be masked), or <code>null</code> if field is one of the conditions above does not hold. * @throws UnsupportedOperationException If field is not supported. */ public <F extends OFValueType<F>> F get(MatchField<F> field) throws UnsupportedOperationException;
/** * Returns the masked value for the given field from this match, along with the mask itself. * Prerequisite: field is partially masked. * If prerequisite is not met, a <code>null</code> is returned. * * @param field Match field to retrieve. * @return Masked value of match field or null if no mask is set. * @throws UnsupportedOperationException If field is not supported. */ public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
/** * Sets a specific exact value for a field. * * @param field Match field to set. * @param value Value of match field. * @return the Builder instance used. * @throws UnsupportedOperationException If field is not supported. */ public <F extends OFValueType<F>> Builder setExact(MatchField<F> field, F value) throws UnsupportedOperationException;
/** * Sets a masked value for a field. * * @param field Match field to set. * @param value Value of field. * @param mask Mask value. * @return the Builder instance used. * @throws UnsupportedOperationException If field is not supported, if field is supported but does not support masking, or if mask structure is not supported. */ public <F extends OFValueType<F>> Builder setMasked(MatchField<F> field, F value, F mask) throws UnsupportedOperationException;
/** * Sets a masked value for a field. * * @param field Match field to set. * @param valueWithMask Compound Masked object contains the value and the mask. * @return the Builder instance used. * @throws UnsupportedOperationException If field is not supported, if field is supported but does not support masking, or if mask structure is not supported. */ public <F extends OFValueType<F>> Builder setMasked(MatchField<F> field, Masked<F> valueWithMask) throws UnsupportedOperationException;
/** * Unsets any value given for the field and wildcards it so that it matches any value. * * @param field Match field to unset. * @return the Builder instance used. * @throws UnsupportedOperationException If field is not supported. */ public <F extends OFValueType<F>> Builder wildcard(MatchField<F> field) throws UnsupportedOperationException;
/** * Get valid/possible values for this prerequisite match. * * @return unmodifiable set of possible values */ public Set<OFValueType<T>> getValues() { return this.values; }
/** * Returns a value for the given field if: * <ul> * <li>Field is supported * <li>Field is not fully wildcarded * <li>Prerequisites are ok * </ul> * If one of the above conditions does not hold, returns null. Value is returned masked if partially wildcarded. * * @param <F> MatchField type * @param field Match field to retrieve * @return Value of match field (may be masked), or <code>null</code> if field is one of the conditions above does not hold. * @throws UnsupportedOperationException If field is not supported. */ public <F extends OFValueType<F>> F get(MatchField<F> field) throws UnsupportedOperationException;
/** * Returns the masked value for the given field from this match, along with the mask itself. * Prerequisite: field is partially masked. * If prerequisite is not met, a <code>null</code> is returned. * * @param <F> MatchField type * @param field Match field to retrieve. * @return Masked value of match field or null if no mask is set. * @throws UnsupportedOperationException If field is not supported. */ public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
/** * Sets a specific exact value for a field. * * @param <F> MatchField and value type * @param field Match field to set. * @param value Value of match field. * @return the Builder instance used. * @throws UnsupportedOperationException If field is not supported. */ public <F extends OFValueType<F>> Builder setExact(MatchField<F> field, F value) throws UnsupportedOperationException;
/** * Sets a masked value for a field. * * @param <F> MatchField, value, and mask type * @param field Match field to set. * @param value Value of field. * @param mask Mask value. * @return the Builder instance used. * @throws UnsupportedOperationException If field is not supported, if field is supported but does not support masking, or if mask structure is not supported. */ public <F extends OFValueType<F>> Builder setMasked(MatchField<F> field, F value, F mask) throws UnsupportedOperationException;
/** * Sets a masked value for a field. * * @param <F> MatchField and value with mask type * @param field Match field to set. * @param valueWithMask Compound Masked object contains the value and the mask. * @return the Builder instance used. * @throws UnsupportedOperationException If field is not supported, if field is supported but does not support masking, or if mask structure is not supported. */ public <F extends OFValueType<F>> Builder setMasked(MatchField<F> field, Masked<F> valueWithMask) throws UnsupportedOperationException;
/** * Unsets any value given for the field and wildcards it so that it matches any value. * * @param <F> MatchField type * @param field Match field to unset. * @return the Builder instance used. * @throws UnsupportedOperationException If field is not supported. */ public <F extends OFValueType<F>> Builder wildcard(MatchField<F> field) throws UnsupportedOperationException;
/** * Sets a specific value for a stat field. * * @param <F> StatField type * @param field Stat field to set. * @param value Value of stat field. * @return the Builder instance used. * @throws UnsupportedOperationException If field is not supported. */ public <F extends OFValueType<F>> Builder set(StatField<F> field, F value) throws UnsupportedOperationException;
public <F extends OFValueType<F>> F get(MatchField<F> field) throws UnsupportedOperationException;
public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field) throws UnsupportedOperationException;
public <F extends OFValueType<F>> F get(StatField<F> field) throws UnsupportedOperationException;