public final class ProtobufProxy extends Object
example code as follow: User user = new User(); ... Codeccodec = ProtobufProxy.create(User.class); // do encode byte[] result = codec.encode(user); // do decode User user2 = codec.decode(result);
| 限定符和类型 | 字段和说明 |
|---|---|
static ThreadLocal<Boolean> |
CACHE_ENABLED
The Constant OUTPUT_PATH for target directory to create generated source code out.
|
static ThreadLocal<Boolean> |
DEBUG_CONTROLLER
The Constant DEBUG_CONTROLLER.
|
static ThreadLocal<File> |
OUTPUT_PATH
The Constant OUTPUT_PATH for target directory to create generated source code out.
|
| 构造器和说明 |
|---|
ProtobufProxy() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
clearCache()
Clear cache.
|
static void |
compile(Class<?> cls,
File outputPath)
Compile.
|
static <T> Codec<T> |
create(Class<T> cls)
To create a protobuf proxy class for target class.
|
static <T> Codec<T> |
create(Class<T> cls,
boolean debug)
Creates the.
|
static <T> Codec<T> |
create(Class<T> cls,
boolean debug,
File path)
To create a protobuf proxy class for target class.
|
static <T> Codec<T> |
create(Class<T> cls,
boolean debug,
File path,
Compiler compiler,
ICodeGenerator codeGenerator)
To create a protobuf proxy class for target class.
|
static <T> Codec<T> |
create(Class<T> cls,
Compiler compiler,
ICodeGenerator codeGenerator)
To create a protobuf proxy class for target class.
|
protected static <T> Codec<T> |
doCreate(Class<T> cls,
boolean debug,
Compiler compiler,
ICodeGenerator cg)
To create a protobuf proxy class for target class.
|
static void |
dynamicCodeGenerate(OutputStream os,
Class cls,
Charset charset)
To generate a protobuf proxy java source code for target class.
|
static void |
dynamicCodeGenerate(OutputStream os,
Class cls,
Charset charset,
ICodeGenerator codeGenerator)
To generate a protobuf proxy java source code for target class.
|
static void |
enableCache(boolean enabled)
Enable cache.
|
static String |
getFullClassName(Class cls)
Gets the full class name.
|
static boolean |
isCacheEnabled()
Checks if is cache enabled.
|
static boolean |
isDebugEnabled()
Checks if is debug enabled.
|
public static final ThreadLocal<Boolean> DEBUG_CONTROLLER
public static final ThreadLocal<File> OUTPUT_PATH
public static final ThreadLocal<Boolean> CACHE_ENABLED
public static void clearCache()
public static void compile(Class<?> cls, File outputPath)
cls - target class to be compiledoutputPath - compile byte files output streampublic static <T> Codec<T> create(Class<T> cls)
T - generic typecls - target class to parse @Protobuf annotationCodec instance proxypublic static <T> Codec<T> create(Class<T> cls, boolean debug)
T - the generic typecls - the clsdebug - the debugpublic static <T> Codec<T> create(Class<T> cls, boolean debug, File path)
T - target object type to be proxied.cls - target object classdebug - true will print generate java source codepath - the pathpublic static <T> Codec<T> create(Class<T> cls, boolean debug, File path, Compiler compiler, ICodeGenerator codeGenerator)
T - target object type to be proxied.cls - target object classdebug - true will print generate java source codepath - the pathcompiler - the compilercodeGenerator - the code generatorpublic static <T> Codec<T> create(Class<T> cls, Compiler compiler, ICodeGenerator codeGenerator)
T - generic typecls - target class to parse @Protobuf annotationcompiler - the compilercodeGenerator - the code generatorCodec instance proxyprotected static <T> Codec<T> doCreate(Class<T> cls, boolean debug, Compiler compiler, ICodeGenerator cg)
T - target object type to be proxied.cls - target object classdebug - true will print generate java source codecompiler - the compilercg - the cgpublic static void dynamicCodeGenerate(OutputStream os, Class cls, Charset charset) throws IOException
os - to generate java source codecls - target classcharset - charset typeIOException - in case of any io relative exception.public static void dynamicCodeGenerate(OutputStream os, Class cls, Charset charset, ICodeGenerator codeGenerator) throws IOException
os - to generate java source codecls - target classcharset - charset typecodeGenerator - the code generatorIOException - in case of any io relative exception.public static void enableCache(boolean enabled)
enabled - the enabledpublic static String getFullClassName(Class cls)
cls - the clspublic static boolean isCacheEnabled()
public static boolean isDebugEnabled()
Copyright © 2022 Baidu, Inc.. All rights reserved.