本文整理汇总了Java中com.baidu.bjf.remoting.protobuf.annotation.Protobuf类的典型用法代码示例。如果您正苦于以下问题:Java Protobuf类的具体用法?Java Protobuf怎么用?Java Protobuf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Protobuf类属于com.baidu.bjf.remoting.protobuf.annotation包,在下文中一共展示了Protobuf类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateProtobufDefinedForField
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf; //导入依赖的package包/类
/**
* to generate @Protobuf defined code for target field.
*
* @param code the code
* @param field the field
* @param enumNames the enum names
*/
private static void generateProtobufDefinedForField(StringBuilder code, Field field, Set<String> enumNames) {
code.append("@").append(Protobuf.class.getSimpleName()).append("(");
String fieldType = fieldTypeMapping.get(field.getType());
if (fieldType == null) {
if (enumNames.contains(field.getType())) {
fieldType = "FieldType.ENUM";
} else {
fieldType = "FieldType.OBJECT";
}
}
code.append("fieldType=").append(fieldType);
code.append(", order=").append(field.getTag());
if (Label.OPTIONAL == field.getLabel()) {
code.append(", required=false");
} else if (Label.REQUIRED == field.getLabel()) {
code.append(", required=true");
}
code.append(")\n");
}
示例2: generateProtobufDefinedForField
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf; //导入依赖的package包/类
/**
* to generate @Protobuf defined code for target field.
*
* @param code
* @param field
*/
private static void generateProtobufDefinedForField(StringBuilder code, Field field, Set<String> enumNames) {
code.append("@").append(Protobuf.class.getSimpleName()).append("(");
String fieldType = fieldTypeMapping.get(field.getType());
if (fieldType == null) {
if (enumNames.contains(field.getType())) {
fieldType = "FieldType.ENUM";
} else {
fieldType = "FieldType.OBJECT";
}
}
code.append("fieldType=").append(fieldType);
code.append(", order=").append(field.getTag());
if (Label.OPTIONAL == field.getLabel()) {
code.append(", required=false");
} else if (Label.REQUIRED == field.getLabel()) {
code.append(", required=true");
}
code.append(")\n");
}
示例3: ReflectiveCodec
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf; //导入依赖的package包/类
public ReflectiveCodec(Class<T> cls) {
this.cls = cls;
List<Field> fields = FieldUtils.findMatchedFields(cls, Protobuf.class);
if (fields.isEmpty()) {
throw new IllegalArgumentException("Invalid class [" + cls.getName() + "] no field use annotation @"
+ Protobuf.class.getName() + " at class " + cls.getName());
}
fieldInfos = ProtobufProxyUtils.processDefaultValue(fields);
orderFieldsMapping = new HashMap<Integer, FieldInfo>();
for (FieldInfo fieldInfo : fieldInfos) {
int tag = CodedConstant.makeTag(fieldInfo.getOrder(),
fieldInfo.getFieldType().getInternalFieldType().getWireType());
orderFieldsMapping.put(tag, fieldInfo);
}
}
示例4: generateProtobufDefinedForField
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf; //导入依赖的package包/类
/**
* to generate @Protobuf defined code for target field.
*
* @param code
* @param field
*/
private static void generateProtobufDefinedForField(StringBuilder code, FieldElement field, Set<String> enumNames) {
code.append("@").append(Protobuf.class.getSimpleName()).append("(");
String fieldType = fieldTypeMapping.get(getTypeName(field));
if (fieldType == null) {
if (enumNames.contains(getTypeName(field))) {
fieldType = "FieldType.ENUM";
} else {
if (field.type().kind() == DataType.Kind.MAP) {
fieldType = "FieldType.MAP";
} else {
fieldType = "FieldType.OBJECT";
}
}
}
code.append("fieldType=").append(fieldType);
code.append(", order=").append(field.tag());
if (FieldElement.Label.OPTIONAL == field.label()) {
code.append(", required=false");
} else if (Label.REQUIRED == field.label()) {
code.append(", required=true");
}
code.append(")\n");
}
示例5: ProtobufField
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf; //导入依赖的package包/类
public ProtobufField(Field field) {
annotation = field.getAnnotation(Protobuf.class);
name = field.getName();
type = field.getType();
declaredClass = field.getDeclaringClass();
genericType = field.getGenericType();
}
示例6: ProtobufField
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf; //导入依赖的package包/类
/**
* Instantiates a new protobuf field.
*
* @param field the field
*/
public ProtobufField(Field field) {
annotation = field.getAnnotation(Protobuf.class);
name = field.getName();
type = field.getType();
declaredClass = field.getDeclaringClass();
genericType = field.getGenericType();
}
示例7: getAnnotation
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf; //导入依赖的package包/类
/**
* get the annotation
* @return the annotation
*/
public Protobuf getAnnotation() {
return annotation;
}
示例8: getAnnotation
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf; //导入依赖的package包/类
/**
* Gets the annotation.
*
* @return the annotation
*/
public Protobuf getAnnotation() {
return annotation;
}