本文整理了Java中com.google.protobuf.Internal.hashEnum()
方法的一些代码示例,展示了Internal.hashEnum()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Internal.hashEnum()
方法的具体详情如下:
包路径:com.google.protobuf.Internal
类名称:Internal
方法名:hashEnum
[英]Helper method for implementing MessageLite#hashCode() for enums.
This is needed because java.lang.Enum#hashCode() is final, but we need to use the field number as the hash code to ensure compatibility between statically and dynamically generated enum objects.
[中]用于为枚举实现MessageLite#hashCode()的助手方法。
这是必要的,因为java。lang.Enum#hashCode()是最终的,但我们需要使用字段号作为哈希代码,以确保静态和动态生成的枚举对象之间的兼容性。
代码示例来源:origin: com.google.protobuf/protobuf-java
/**
* Helper method for implementing {@link Message#hashCode()} for
* enum lists.
*/
public static int hashEnumList(List<? extends EnumLite> list) {
int hash = 1;
for (EnumLite e : list) {
hash = 31 * hash + hashEnum(e);
}
return hash;
}
代码示例来源:origin: com.google.protobuf/protobuf-java
/** Get a hash code for given fields and values, using the given seed. */
@SuppressWarnings("unchecked")
protected static int hashFields(int hash, Map<FieldDescriptor, Object> map) {
for (Map.Entry<FieldDescriptor, Object> entry : map.entrySet()) {
FieldDescriptor field = entry.getKey();
Object value = entry.getValue();
hash = (37 * hash) + field.getNumber();
if (field.isMapField()) {
hash = (53 * hash) + hashMapField(value);
} else if (field.getType() != FieldDescriptor.Type.ENUM){
hash = (53 * hash) + value.hashCode();
} else if (field.isRepeated()) {
List<? extends EnumLite> list = (List<? extends EnumLite>) value;
hash = (53 * hash) + Internal.hashEnumList(list);
} else {
hash = (53 * hash) + Internal.hashEnum((EnumLite) value);
}
}
return hash;
}
代码示例来源:origin: WeAreFairphone/FP2-Launcher
/** Get a hash code for given fields and values, using the given seed. */
@SuppressWarnings("unchecked")
protected static int hashFields(int hash, Map<FieldDescriptor, Object> map) {
for (Map.Entry<FieldDescriptor, Object> entry : map.entrySet()) {
FieldDescriptor field = entry.getKey();
Object value = entry.getValue();
hash = (MAGIC_NUMBER_37 * hash) + field.getNumber();
if (field.getType() != FieldDescriptor.Type.ENUM){
hash = (MAGIC_NUMBER_53 * hash) + value.hashCode();
} else if (field.isRepeated()) {
List<? extends EnumLite> list = (List<? extends EnumLite>) value;
hash = (MAGIC_NUMBER_53 * hash) + Internal.hashEnumList(list);
} else {
hash = (MAGIC_NUMBER_53 * hash) + Internal.hashEnum((EnumLite) value);
}
}
return hash;
}
代码示例来源:origin: WeAreFairphone/FP2-Launcher
/**
* Helper method for implementing {@link MessageLite#hashCode()} for
* enum lists.
*/
public static int hashEnumList(List<? extends EnumLite> list) {
int hash = 1;
for (EnumLite e : list) {
hash = 31 * hash + hashEnum(e);
}
return hash;
}
代码示例来源:origin: yeriomin/play-store-api
/** Get a hash code for given fields and values, using the given seed. */
@SuppressWarnings("unchecked")
protected static int hashFields(int hash, Map<FieldDescriptor, Object> map) {
for (Map.Entry<FieldDescriptor, Object> entry : map.entrySet()) {
FieldDescriptor field = entry.getKey();
Object value = entry.getValue();
hash = (37 * hash) + field.getNumber();
if (field.isMapField()) {
hash = (53 * hash) + hashMapField(value);
} else if (field.getType() != FieldDescriptor.Type.ENUM){
hash = (53 * hash) + value.hashCode();
} else if (field.isRepeated()) {
List<? extends EnumLite> list = (List<? extends EnumLite>) value;
hash = (53 * hash) + Internal.hashEnumList(list);
} else {
hash = (53 * hash) + Internal.hashEnum((EnumLite) value);
}
}
return hash;
}
代码示例来源:origin: com.google.protobuf/protobuf-lite
/**
* Helper method for implementing {@link Message#hashCode()} for
* enum lists.
*/
public static int hashEnumList(List<? extends EnumLite> list) {
int hash = 1;
for (EnumLite e : list) {
hash = 31 * hash + hashEnum(e);
}
return hash;
}
代码示例来源:origin: com.github.protobufel/protobufel-protobuf-test-protos
hash = (53 * hash) + com.google.protobuf.Internal.hashEnum(
getEnumFieldCount12());
代码示例来源:origin: yeriomin/play-store-api
/**
* Helper method for implementing {@link Message#hashCode()} for
* enum lists.
*/
public static int hashEnumList(List<? extends EnumLite> list) {
int hash = 1;
for (EnumLite e : list) {
hash = 31 * hash + hashEnum(e);
}
return hash;
}
代码示例来源:origin: com.github.protobufel/protobufel-protobuf-test-protos
@java.lang.Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptorForType().hashCode();
if (hasParser()) {
hash = (37 * hash) + PARSER_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashEnum(
getParser());
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
代码示例来源:origin: com.github.protobufel/protobufel-protobuf-test-protos
@java.lang.Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptorForType().hashCode();
if (hasField1()) {
hash = (37 * hash) + FIELD1_FIELD_NUMBER;
hash = (53 * hash) + getField1();
}
if (hasField2()) {
hash = (37 * hash) + FIELD2_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashEnum(
getField2());
}
if (hasField3()) {
hash = (37 * hash) + FIELD3_FIELD_NUMBER;
hash = (53 * hash) + getField3().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash;
return hash;
}
内容来源于网络,如有侵权,请联系作者删除!