public class ThriftUtils extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
ThriftUtils.Action |
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.lang.Class<?>,java.lang.Class<?>> |
CAST_TYPES |
static ThriftCatalog |
CATALOG |
static java.lang.String |
CLIENT_SUFFIX |
static java.lang.String |
DECORATOR_CLIENT_PKG_SUFFIX |
static java.lang.String |
DECORATOR_PKG_SUFFIX |
static java.lang.String |
ISLOCAL_METHOD_NAME |
static java.util.Set<java.lang.Class<?>> |
THRIFT_BUILTIN_KNOWNTYPES |
Constructor and Description |
---|
ThriftUtils() |
Modifier and Type | Method and Description |
---|---|
static <V> void |
addCallback(com.google.common.util.concurrent.ListenableFuture<V> future,
com.google.common.util.concurrent.FutureCallback<? super V> callback,
java.util.concurrent.Executor executor) |
static <T> T |
constructStruct(java.util.Map<java.lang.Short,TypeValue> data,
ThriftStructMetadata metadata)
构造
metadata 指定类型的实例并填充字段
参见 com.facebook.swift.codec.internal.reflection.ReflectionThriftStructCodec#constructStruct(Map |
static <T> T |
fillStructField(java.util.Map<java.lang.Short,TypeValue> data,
ThriftStructMetadata metadata,
T instance)
填充
instance 实例的字段参见 com.facebook.swift.codec.internal.reflection.ReflectionThriftStructCodec#constructStruct(Map |
static <T> java.lang.reflect.Constructor<T> |
getConstructor(java.lang.Class<T> clazz,
java.lang.Class<?>... parameterTypes) |
static <T,D extends ThriftDecorator<T>> |
getDecoratorType(java.lang.Class<T> clazz)
返回
clazz 对应的装饰类 |
static <T> java.lang.Class<? extends ThriftDecorator<T>> |
getDecoratorType(java.lang.reflect.Type type) |
static TypeValue |
getFieldValue(java.lang.Object instance,
ThriftFieldMetadata field)
获取
field 指定的字段值 |
static java.util.Map<java.lang.Short,TypeValue> |
getFieldValues(java.lang.Object instance,
ThriftStructMetadata metadata)
根据
metadata 类型数据获取instance 实例所有的字段值
参见 com.facebook.swift.codec.internal.reflection.ReflectionThriftStructCodec#write(Object, org.apache.thrift.protocol.TProtocol) |
static java.util.Map<java.lang.Short,TypeValue> |
getFiledValues(java.lang.Object instance,
ThriftStructMetadata metadata)
Deprecated.
name spell error, replaced by
getFieldValues(Object, ThriftStructMetadata) |
static <L,M extends ThriftDecorator<L>,R> |
getMiddleClass(java.lang.Class<L> left,
java.lang.Class<R> right)
返回
left & right 之间的decorator类型 |
static <L,M extends ThriftDecorator<L>,R> |
getMiddleClassChecked(java.lang.Class<L> left,
java.lang.Class<R> right) |
static <T> boolean |
hasConstructor(java.lang.Class<T> clazz,
java.lang.Class<?>... parameterTypes) |
static boolean |
hasDecoratorType(java.lang.reflect.Type type) |
static boolean |
isCastType(java.lang.reflect.Type type) |
static boolean |
isException(java.lang.reflect.Type type) |
static boolean |
isfloat(java.lang.reflect.Type type) |
static boolean |
isIsLocalMethod(java.lang.reflect.Method method) |
static boolean |
isPrimitiveArray(java.lang.reflect.Type type) |
static boolean |
isPrimitivefloat(java.lang.reflect.Type type) |
static boolean |
isThriftBuildinType(java.lang.reflect.Type type) |
static <L,R> boolean |
isThriftClientPair(java.lang.Class<L> left,
java.lang.Class<R> right)
判断
right 是否为left 对应的client端存根类型 |
static boolean |
isThriftDecorator(java.lang.reflect.Type type) |
static <L,R> boolean |
isThriftDecoratorPair(java.lang.Class<L> left,
java.lang.Class<R> right)
判断
left and right 之间是否为装饰类和被装饰类关系 |
static boolean |
isThriftException(java.lang.reflect.Type type) |
static boolean |
isThriftException(java.lang.reflect.Type left,
java.lang.reflect.Type right) |
static boolean |
isThriftStruct(java.lang.reflect.Type type) |
static <T> com.google.common.reflect.TypeToken<java.util.List<T>> |
listToken(com.google.common.reflect.TypeToken<T> keyToken) |
static <K,V> com.google.common.reflect.TypeToken<java.util.Map<K,V>> |
mapToken(com.google.common.reflect.TypeToken<K> keyToken,
com.google.common.reflect.TypeToken<V> valueToken) |
static boolean |
needTransformer(java.lang.reflect.Type type) |
static <T> T |
returnNull(com.facebook.swift.service.RuntimeTApplicationException e)
避免
null 抛出异常 |
static <T> T |
returnNull(java.lang.Throwable e)
避免
null 抛出异常 |
static <T> com.google.common.reflect.TypeToken<java.util.Set<T>> |
setToken(com.google.common.reflect.TypeToken<T> keyToken) |
static void |
traverseTypes(java.lang.reflect.Type type,
ThriftUtils.Action action) |
public static final ThriftCatalog CATALOG
public static final java.util.Set<java.lang.Class<?>> THRIFT_BUILTIN_KNOWNTYPES
public static final java.util.Map<java.lang.Class<?>,java.lang.Class<?>> CAST_TYPES
public static final java.lang.String DECORATOR_PKG_SUFFIX
public static final java.lang.String CLIENT_SUFFIX
public static final java.lang.String DECORATOR_CLIENT_PKG_SUFFIX
public static final java.lang.String ISLOCAL_METHOD_NAME
public ThriftUtils()
public static <T> T constructStruct(java.util.Map<java.lang.Short,TypeValue> data, ThriftStructMetadata metadata) throws java.lang.Exception
metadata
指定类型的实例并填充字段
参见 com.facebook.swift.codec.internal.reflection.ReflectionThriftStructCodec#constructStruct(Map)
data
- metadata
- java.lang.Exception
public static <T> T fillStructField(java.util.Map<java.lang.Short,TypeValue> data, ThriftStructMetadata metadata, T instance) throws java.lang.Exception
instance
实例的字段com.facebook.swift.codec.internal.reflection.ReflectionThriftStructCodec#constructStruct(Map)
data
- metadata
- instance
- java.lang.Exception
public static TypeValue getFieldValue(java.lang.Object instance, ThriftFieldMetadata field) throws java.lang.Exception
field
指定的字段值instance
- field
- java.lang.Exception
com.facebook.swift.codec.internal.reflection.AbstractReflectionThriftCodec#getFieldValue(Object, ThriftFieldMetadata)}
public static java.util.Map<java.lang.Short,TypeValue> getFieldValues(java.lang.Object instance, ThriftStructMetadata metadata)
metadata
类型数据获取instance
实例所有的字段值
参见 com.facebook.swift.codec.internal.reflection.ReflectionThriftStructCodec#write(Object, org.apache.thrift.protocol.TProtocol)
instance
- metadata
- public static java.util.Map<java.lang.Short,TypeValue> getFiledValues(java.lang.Object instance, ThriftStructMetadata metadata)
getFieldValues(Object, ThriftStructMetadata)
instance
- metadata
- public static boolean isThriftStruct(java.lang.reflect.Type type)
public static boolean isThriftDecorator(java.lang.reflect.Type type)
public static boolean isPrimitiveArray(java.lang.reflect.Type type)
public static boolean isThriftBuildinType(java.lang.reflect.Type type)
public static boolean isPrimitivefloat(java.lang.reflect.Type type)
public static boolean isfloat(java.lang.reflect.Type type)
public static boolean isCastType(java.lang.reflect.Type type)
public static boolean isException(java.lang.reflect.Type type)
public static <T> java.lang.reflect.Constructor<T> getConstructor(java.lang.Class<T> clazz, java.lang.Class<?>... parameterTypes)
public static <T> boolean hasConstructor(java.lang.Class<T> clazz, java.lang.Class<?>... parameterTypes)
public static boolean isThriftException(java.lang.reflect.Type type)
public static boolean isThriftException(java.lang.reflect.Type left, java.lang.reflect.Type right)
public static boolean needTransformer(java.lang.reflect.Type type)
public static void traverseTypes(java.lang.reflect.Type type, ThriftUtils.Action action)
public static <K,V> com.google.common.reflect.TypeToken<java.util.Map<K,V>> mapToken(com.google.common.reflect.TypeToken<K> keyToken, com.google.common.reflect.TypeToken<V> valueToken)
public static <T> com.google.common.reflect.TypeToken<java.util.List<T>> listToken(com.google.common.reflect.TypeToken<T> keyToken)
public static <T> com.google.common.reflect.TypeToken<java.util.Set<T>> setToken(com.google.common.reflect.TypeToken<T> keyToken)
public static boolean hasDecoratorType(java.lang.reflect.Type type)
type
- getDecoratorType(Type)
public static <T> java.lang.Class<? extends ThriftDecorator<T>> getDecoratorType(java.lang.reflect.Type type)
type
- getDecoratorType(Class)
public static <T,D extends ThriftDecorator<T>> java.lang.Class<D> getDecoratorType(java.lang.Class<T> clazz)
clazz
对应的装饰类clazz
- null
public static <L,R> boolean isThriftDecoratorPair(java.lang.Class<L> left, java.lang.Class<R> right)
left and right
之间是否为装饰类和被装饰类关系left
- 装饰类right
- 补装饰类public static <L,R> boolean isThriftClientPair(java.lang.Class<L> left, java.lang.Class<R> right)
right
是否为left
对应的client端存根类型left
- right
- public static <L,M extends ThriftDecorator<L>,R> java.lang.Class<M> getMiddleClass(java.lang.Class<L> left, java.lang.Class<R> right)
left & right
之间的decorator类型left
- 原始类型right
- left
对应的client端存根类型public static <L,M extends ThriftDecorator<L>,R> java.lang.Class<M> getMiddleClassChecked(java.lang.Class<L> left, java.lang.Class<R> right)
left
- right
- getMiddleClass(Class, Class)
public static boolean isIsLocalMethod(java.lang.reflect.Method method)
public static <T> T returnNull(com.facebook.swift.service.RuntimeTApplicationException e)
null
抛出异常public static <T> T returnNull(java.lang.Throwable e) throws java.lang.Throwable
null
抛出异常java.lang.Throwable
public static <V> void addCallback(com.google.common.util.concurrent.ListenableFuture<V> future, com.google.common.util.concurrent.FutureCallback<? super V> callback, java.util.concurrent.Executor executor)
Copyright © 2019. All rights reserved.