本文整理汇总了Java中org.apache.commons.collections4.functors.InvokerTransformer类的典型用法代码示例。如果您正苦于以下问题:Java InvokerTransformer类的具体用法?Java InvokerTransformer怎么用?Java InvokerTransformer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvokerTransformer类属于org.apache.commons.collections4.functors包,在下文中一共展示了InvokerTransformer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObject
import org.apache.commons.collections4.functors.InvokerTransformer; //导入依赖的package包/类
public Queue<Object> getObject(final String command) throws Exception {
final Object templates = Gadgets.createTemplatesImpl(command);
// mock method name until armed
final InvokerTransformer transformer = new InvokerTransformer("toString", new Class[0], new Object[0]);
// create queue with numbers and basic comparator
final PriorityQueue<Object> queue = new PriorityQueue<Object>(2,new TransformingComparator(transformer));
// stub data for replacement later
queue.add(1);
queue.add(1);
// switch method called by comparator
Reflections.setFieldValue(transformer, "iMethodName", "newTransformer");
// switch contents of queue
final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
queueArray[0] = templates;
queueArray[1] = 1;
return queue;
}
示例2: getObject
import org.apache.commons.collections4.functors.InvokerTransformer; //导入依赖的package包/类
public Queue<Object> getObject(CmdExecuteHelper cmdHelper) throws Exception {
final Object templates = Gadgets.createTemplatesImpl(cmdHelper.getCommandArray());
// mock method name until armed
final InvokerTransformer transformer = new InvokerTransformer("toString", new Class[0], new Object[0]);
// create queue with numbers and basic comparator
final PriorityQueue<Object> queue = new PriorityQueue<Object>(2,new TransformingComparator(transformer));
// stub data for replacement later
queue.add(1);
queue.add(1);
// switch method called by comparator
Reflections.setFieldValue(transformer, "iMethodName", "newTransformer");
// switch contents of queue
final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
queueArray[0] = templates;
queueArray[1] = 1;
return queue;
}
示例3: getObject
import org.apache.commons.collections4.functors.InvokerTransformer; //导入依赖的package包/类
public Queue<Object> getObject(final String command) throws Exception {
final TemplatesImpl templates = Gadgets.createTemplatesImpl(command);
// mock method name until armed
final InvokerTransformer transformer = new InvokerTransformer("toString", new Class[0], new Object[0]);
// create queue with numbers and basic comparator
final PriorityQueue<Object> queue = new PriorityQueue<Object>(2,new TransformingComparator(transformer));
// stub data for replacement later
queue.add(1);
queue.add(1);
// switch method called by comparator
Reflections.setFieldValue(transformer, "iMethodName", "newTransformer");
// switch contents of queue
final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
queueArray[0] = templates;
queueArray[1] = 1;
return queue;
}
示例4: getObject
import org.apache.commons.collections4.functors.InvokerTransformer; //导入依赖的package包/类
public Queue<Object> getObject(final String command) throws Exception {
final TemplatesImpl templates = Gadgets.createTemplatesImpl(command);
// mock method name until armed
final InvokerTransformer transformer = new InvokerTransformer("toString", new Class[0], new Object[0]);
// create queue with numbers and basic comparator
final PriorityQueue<Object> queue = new PriorityQueue<Object>(2,new TransformingComparator(transformer));
// stub data for replacement later
queue.add(1);
queue.add(1);
// switch method called by comparator
Reflections.setFieldValue(transformer, "iMethodName", "newTransformer");
// switch contents of queue
final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
queueArray[0] = templates;
queueArray[1] = 1;
return queue;
}
示例5: invokerPredicate
import org.apache.commons.collections4.functors.InvokerTransformer; //导入依赖的package包/类
/**
* Creates a Predicate that invokes a method on the input object.
* The method must return either a boolean or a non-null Boolean,
* and have no parameters. If the input object is null, a
* PredicateException is thrown.
* <p>
* For example, <code>PredicateUtils.invokerPredicate("isEmpty");</code>
* will call the <code>isEmpty</code> method on the input object to
* determine the predicate result.
*
* @param <T> the type that the predicate queries
* @param methodName the method name to call on the input object, may not be null
* @return the predicate
* @throws NullPointerException if the methodName is null.
* @see InvokerTransformer
* @see TransformerPredicate
*/
public static <T> Predicate<T> invokerPredicate(final String methodName) {
// reuse transformer as it has caching - this is lazy really, should have inner class here
return asPredicate(InvokerTransformer.<Object, Boolean>invokerTransformer(methodName));
}
示例6: invokerTransformer
import org.apache.commons.collections4.functors.InvokerTransformer; //导入依赖的package包/类
/**
* Gets a Transformer that invokes a method on the input object.
* The method must have no parameters. If the input object is null,
* null is returned.
* <p>
* For example, <code>TransformerUtils.invokerTransformer("getName");</code>
* will call the <code>getName/code> method on the input object to
* determine the transformer result.
*
* @param <I> the input type
* @param <O> the output type
* @param methodName the method name to call on the input object, may not be null
* @return the transformer
* @throws NullPointerException if the methodName is null.
* @see InvokerTransformer
*/
public static <I, O> Transformer<I, O> invokerTransformer(final String methodName) {
return InvokerTransformer.invokerTransformer(methodName, null, null);
}
示例7: invokerClosure
import org.apache.commons.collections4.functors.InvokerTransformer; //导入依赖的package包/类
/**
* Creates a Closure that will invoke a specific method on the closure's
* input object by reflection.
*
* @see org.apache.commons.collections4.functors.InvokerTransformer
* @see org.apache.commons.collections4.functors.TransformerClosure
*
* @param <E> the type that the closure acts on
* @param methodName the name of the method
* @return the <code>invoker</code> closure
* @throws NullPointerException if the method name is null
*/
public static <E> Closure<E> invokerClosure(final String methodName) {
// reuse transformer as it has caching - this is lazy really, should have inner class here
return asClosure(InvokerTransformer.<E, Object>invokerTransformer(methodName));
}