Example usage for com.google.common.reflect TypeToken method

List of usage examples for com.google.common.reflect TypeToken method

Introduction

In this page you can find the example usage for com.google.common.reflect TypeToken method.

Prototype

public final Invokable<T, Object> method(Method method) 

Source Link

Document

Returns the Invokable for method , which must be a member of T .

Usage

From source file:org.cebolla.repositories.AbstractFakeRepository.java

/**
 * For internal use only//from  www .jav  a  2 s .  c  o m
 */
@SuppressWarnings("serial")
public Class<?> getEntityType() {
    TypeToken<AbstractFakeRepository<EntityType>> token = new TypeToken<AbstractFakeRepository<EntityType>>(
            getClass()) {
    };
    Invokable<AbstractFakeRepository<EntityType>, Object> invokable = token.method(getAddMethod());
    return invokable.getParameters().get(0).getType().getRawType();
}

From source file:com.google.cloud.dataflow.sdk.util.ApiSurface.java

/**
 * Returns an {@link Invokable} for each public methods or constructors of a type.
 *//* w ww . j  av  a2s .c  om*/
private Set<Invokable> getExposedInvokables(TypeToken<?> type) {
    Set<Invokable> invokables = Sets.newHashSet();

    for (Constructor constructor : type.getRawType().getConstructors()) {
        if (0 != (constructor.getModifiers() & (Modifier.PUBLIC | Modifier.PROTECTED))) {
            invokables.add(type.constructor(constructor));
        }
    }

    for (Method method : type.getRawType().getMethods()) {
        if (0 != (method.getModifiers() & (Modifier.PUBLIC | Modifier.PROTECTED))) {
            invokables.add(type.method(method));
        }
    }

    return invokables;
}