public virtual void TesCustomPredicate() { var mapOther = Client.GetMap <int, string>(TestSupport.RandomString()); var ep = new EqualPredicate(); var cp = new CustomPredicate <int, string>(); var ap = new AndPredicate(ep, cp); try { var keySet = mapOther.KeySet(ap); } finally { Assert.Pass("Predicate generics related compile test, if compiles it passes"); } }
/** * Create a new Transformer that uses the input object as a key to find the * transformer to call. * <p> * The Map consists of object keys and Transformer values. A transformer * is called if the input object equals the key. If there is no match, the * default transformer is called. The default transformer is set in the map * using a null key. If no default is set, null will be returned in a default case. * * @see org.apache.commons.collections.functors.SwitchTransformer * * @param objectsAndTransformers a map of objects to transformers * @return the transformer * @throws IllegalArgumentException if the map is null * @throws IllegalArgumentException if the map is empty * @throws IllegalArgumentException if any transformer in the map is null */ public static Transformer switchMapTransformer(java.util.Map <Object, Object> objectsAndTransformers) { Transformer[] trs = null; Predicate[] preds = null; if (objectsAndTransformers == null) { throw new java.lang.IllegalArgumentException("The object and transformer map must not be null"); } Transformer def = (Transformer)objectsAndTransformers.remove(null); int size = objectsAndTransformers.size(); trs = new Transformer[size]; preds = new Predicate[size]; int i = 0; for (java.util.Iterator <java.util.MapNS.Entry <Object, Object> > it = objectsAndTransformers.entrySet().iterator(); it.hasNext();) { java.util.MapNS.Entry <Object, Object> entry = (java.util.MapNS.Entry <Object, Object>)it.next(); preds[i] = EqualPredicate.getInstance(entry.getKey()); trs[i] = (Transformer)entry.getValue(); i++; } return(switchTransformer(preds, trs, def)); }
/** * Create a new Closure that uses the input object as a key to find the * closure to call. * <p> * The Map consists of object keys and Closure values. A closure * is called if the input object equals the key. If there is no match, the * default closure is called. The default closure is set in the map * using a null key. * * @see org.apache.commons.collections.functors.SwitchClosure * * @param objectsAndClosures a map of objects to closures * @return the closure * @throws IllegalArgumentException if the map is null * @throws IllegalArgumentException if the map is empty * @throws IllegalArgumentException if any closure in the map is null */ public static Closure switchMapClosure(java.util.Map <Object, Object> objectsAndClosures) { Closure[] trs = null; Predicate[] preds = null; if (objectsAndClosures == null) { throw new java.lang.IllegalArgumentException("The object and closure map must not be null"); } Closure def = (Closure)objectsAndClosures.remove(null); int size = objectsAndClosures.size(); trs = new Closure[size]; preds = new Predicate[size]; int i = 0; for (java.util.Iterator <java.util.MapNS.Entry <Object, Object> > it = objectsAndClosures.entrySet().iterator(); it.hasNext();) { java.util.MapNS.Entry <Object, Object> entry = it.next(); preds[i] = EqualPredicate.getInstance(entry.getKey()); trs[i] = (Closure)entry.getValue(); i++; } return(switchClosure(preds, trs, def)); }
/** * Creates a Predicate that checks if the input object is equal to the * specified object using equals(). * * @see org.apache.commons.collections.functors.EqualPredicate * * @param value the value to compare against * @return the predicate */ public static Predicate equalPredicate(Object value) { return(EqualPredicate.getInstance(value)); }
public static PsAccessScopeIsPredicate FromEnginePredicate(EqualPredicate condition) { return(new PsAccessScopeIsPredicate((AccessScope)condition.Value.ParsedValue)); }