Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.funcito;
 
 /*
  * Copyright 2011 Project Funcito Contributors
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
This class is the static entry point of the Funcito API for Google Guava.
public class FuncitoGuava {
    private static final GuavaDelegate guavaDelegate = new GuavaDelegate();
    private FuncitoGuava() {}

    
Generates a stub object for use with other FuncitoGuava static calls. This stub should not be used for any other purposes. An example of proper usage is as follows:

MyClass callsTo = callsTo(MyClass.class);
Function<MyClass,RetType> func = functionFor( callsTo.noArgMethodWithRetType() );

Stubs are cached, so this method can be called multiple times for the same class without penalty. But a single stub can also be reused for creating multiple Guava Function or Predicate objects.

Parameters:
clazz is the class to be stubbed
Returns:
a stub which can be used by other FuncitoGuava static calls
    public static <T> T callsTo(Class<T> clazz) {
        return .callsTo(clazz);
    }

    
Generates a Guava Function object that wraps a method call. Resulting Function is as thread-safe as the method itself.

Parameters:
stubbedMethodCall is the return value from a method call to a FuncitoGuava stub object
Returns:
a Guava Function object that wraps the method call.
    public static <T,V>Function<T,V> functionFor(V stubbedMethodCall) {
        return .functionFor(stubbedMethodCall);
    }

    
Generates a Guava Predicate object that wraps a Boolean- or boolean-return method call. Resulting Predicate is as thread-safe as the method itself. Auto-boxing means you may always safely wrap a method that has a primitive boolean return type.

Users of this Predicate should be aware of the inherent risk with Guava Predicates (not specific to Funcito) if the return type of the method being wrapped is a Boolean wrapper. Such calls are allowed, but there is no inherent null-pointer safety because Guava Predicate.apply(T) returns a boolean primitive. But see overloaded form of this method below for a mitigation of this risk.

Parameters:
stubbedMethodCall is the Boolean return value from a method call to a FuncitoGuava stub object
Returns:
a Guava Predicate object that wraps the method call.
See also:
predicateFor(java.lang.Boolean,boolean)
    public static <T>Predicate<T> predicateFor(Boolean stubbedMethodCall) {
        return .predicateFor(stubbedMethodCall);
    }

    
Generates a Guava Predicate object that wraps a Boolean- or boolean-return method call. Resulting Predicate is as thread-safe as the method itself. This form of the method is only required when there is a risk of the wrapped method returning a null-value, in which you case you provide the default value to substitute for null return values from the wrapped method.

Parameters:
stubbedMethodCall is the Boolean return value from a method call to a FuncitoGuava callsTo object
defaultForNull is the default value that Predicate will return if the wrapped method returns a null-value.
Returns:
a Guava Predicate object that wraps the method call.
See also:
predicateFor(java.lang.Boolean)
    public static <T>Predicate<T> predicateFor(Boolean stubbedMethodCallboolean defaultForNull) {
        return .predicateFor(stubbedMethodCalldefaultForNull);
    }
    static GuavaDelegate delegate() {
        return ;
    }
New to GrepCode? Check out our FAQ X