当前位置: 首页>>代码示例>>Java>>正文


Java Internal.EnumLite方法代码示例

本文整理汇总了Java中com.google.protobuf.Internal.EnumLite方法的典型用法代码示例。如果您正苦于以下问题:Java Internal.EnumLite方法的具体用法?Java Internal.EnumLite怎么用?Java Internal.EnumLite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.Internal的用法示例。


在下文中一共展示了Internal.EnumLite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: match

import com.google.protobuf.Internal; //导入方法依赖的package包/类
@Override
public boolean match(Internal.EnumLite forward, Internal.EnumLite opcode) {
    return DOMAIN.MATCHING_VALUE == forward.getNumber() && REQUEST_OPCODE.JOIN_MATCH_QUENE.equals(opcode);
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:5,代码来源:MatchingJoinMatch.java

示例2: match

import com.google.protobuf.Internal; //导入方法依赖的package包/类
@Override
public boolean match(Internal.EnumLite forward, Internal.EnumLite opcode) {
    return forward.getNumber() == DOMAIN.MATCHING_VALUE
            && NOTIFY_OPCODE.NOTIFY_MATCH_SUCCESS.getNumber() == opcode.getNumber();
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:6,代码来源:MatchingWaitForMatchStatus.java

示例3: match

import com.google.protobuf.Internal; //导入方法依赖的package包/类
@Override
public boolean match(Internal.EnumLite forward, Internal.EnumLite opcode) {
    return forward.getNumber() == DOMAIN.MATCHING_VALUE && opcode.getNumber() == REQUEST_OPCODE.JOIN_MATCH_QUENE_VALUE;
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:5,代码来源:MatchingWaitForJoinRoom.java

示例4: error

import com.google.protobuf.Internal; //导入方法依赖的package包/类
public static ResponseBodyMessage<String> error(Internal.EnumLite code) {
    Preconditions.checkArgument(code.getNumber() > 0);
    return success(code, null);
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:5,代码来源:ResponseBodyMessage.java

示例5: success

import com.google.protobuf.Internal; //导入方法依赖的package包/类
public static <T extends Serializable> ResponseBodyMessage<T> success(Internal.EnumLite code, T data) {
    return new ResponseBodyMessage<>(code.getNumber(), data);
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:4,代码来源:ResponseBodyMessage.java

示例6: error

import com.google.protobuf.Internal; //导入方法依赖的package包/类
public static ResponseBodyEntity<String> error(Internal.EnumLite code) {
    return success(code, null);
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:4,代码来源:ResponseBodyEntity.java

示例7: success

import com.google.protobuf.Internal; //导入方法依赖的package包/类
public static <T> ResponseBodyEntity<T> success(Internal.EnumLite code, T data) {
    return new ResponseBodyEntity<>(code.getNumber(), data);
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:4,代码来源:ResponseBodyEntity.java

示例8: ServiceEmptyMessage

import com.google.protobuf.Internal; //导入方法依赖的package包/类
private ServiceEmptyMessage(Internal.EnumLite errorCode) {
    this.errorCode = errorCode;
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:4,代码来源:ServiceEmptyMessage.java

示例9: newMessage

import com.google.protobuf.Internal; //导入方法依赖的package包/类
public static ServiceEmptyMessage newMessage(Internal.EnumLite errorCode) {
    return newMessage(errorCode);
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:4,代码来源:ServiceEmptyMessage.java

示例10: getErrorCode

import com.google.protobuf.Internal; //导入方法依赖的package包/类
public Internal.EnumLite getErrorCode() {
    return errorCode;
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:4,代码来源:ServiceEmptyMessage.java

示例11: ServiceMessage

import com.google.protobuf.Internal; //导入方法依赖的package包/类
private ServiceMessage(Internal.EnumLite errorCode, T data) {
    this.errorCode = errorCode;
    this.data = data;
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:5,代码来源:ServiceMessage.java

示例12: newMessage

import com.google.protobuf.Internal; //导入方法依赖的package包/类
public static <T> ServiceMessage<T> newMessage(Internal.EnumLite errorCode, T t) {
    return new ServiceMessage<>(errorCode, t);
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:4,代码来源:ServiceMessage.java

示例13: computeElementSizeNoTag

import com.google.protobuf.Internal; //导入方法依赖的package包/类
/**
 * Compute the number of bytes that would be needed to encode a particular value of arbitrary type, excluding tag.
 *
 * @param type The field's type.
 * @param value Object representing the field's value. Must be of the exact type which would be returned by
 *            {@link Message#getField(Descriptors.FieldDescriptor)} for this field.
 * @return the int
 */
public static int computeElementSizeNoTag(final WireFormat.FieldType type, final Object value) {
    switch (type) {
        // Note: Minor violation of 80-char limit rule here because this would
        // actually be harder to read if we wrapped the lines.
        case DOUBLE:
            return CodedOutputStream.computeDoubleSizeNoTag((Double) value);
        case FLOAT:
            return CodedOutputStream.computeFloatSizeNoTag((Float) value);
        case INT64:
            return CodedOutputStream.computeInt64SizeNoTag((Long) value);
        case UINT64:
            return CodedOutputStream.computeUInt64SizeNoTag((Long) value);
        case INT32:
            return CodedOutputStream.computeInt32SizeNoTag((Integer) value);
        case FIXED64:
            return CodedOutputStream.computeFixed64SizeNoTag((Long) value);
        case FIXED32:
            return CodedOutputStream.computeFixed32SizeNoTag((Integer) value);
        case BOOL:
            return CodedOutputStream.computeBoolSizeNoTag((Boolean) value);
        case STRING:
            return CodedOutputStream.computeStringSizeNoTag((String) value);
        case GROUP:
            return CodedOutputStream.computeGroupSizeNoTag((MessageLite) value);
        case BYTES:
            if (value instanceof ByteString) {
                return CodedOutputStream.computeBytesSizeNoTag((ByteString) value);
            } else {
                return CodedOutputStream.computeByteArraySizeNoTag((byte[]) value);
            }
        case UINT32:
            return CodedOutputStream.computeUInt32SizeNoTag((Integer) value);
        case SFIXED32:
            return CodedOutputStream.computeSFixed32SizeNoTag((Integer) value);
        case SFIXED64:
            return CodedOutputStream.computeSFixed64SizeNoTag((Long) value);
        case SINT32:
            return CodedOutputStream.computeSInt32SizeNoTag((Integer) value);
        case SINT64:
            return CodedOutputStream.computeSInt64SizeNoTag((Long) value);

        case MESSAGE:
            if (value instanceof LazyField) {
                return CodedOutputStream.computeLazyFieldSizeNoTag((LazyField) value);
            } else {
                return computeObjectSizeNoTag(value);
            }

        case ENUM:
            if (value instanceof Internal.EnumLite) {
                return CodedOutputStream.computeEnumSizeNoTag(((Internal.EnumLite) value).getNumber());
            } else {
                if (value instanceof EnumReadable) {
                    return CodedOutputStream.computeEnumSizeNoTag(((EnumReadable) value).value());
                } else if (value instanceof Enum) {
                    return CodedOutputStream.computeEnumSizeNoTag(((Enum) value).ordinal());
                }

                return CodedOutputStream.computeEnumSizeNoTag((Integer) value);
            }
    }

    throw new RuntimeException("There is no way to get here, but the compiler thinks otherwise.");
}
 
开发者ID:jhunters,项目名称:jprotobuf,代码行数:73,代码来源:CodedConstant.java

示例14: verifySingleValue

import com.google.protobuf.Internal; //导入方法依赖的package包/类
private static void verifySingleValue(final FieldDescriptor field, final Object value,
    final Class<? extends MessageOrBuilder> type) {
  if (value == null) {
    throw new NullPointerException();
  }

  boolean isValid = false;

  switch (field.getJavaType()) {
    case INT:
      isValid = value instanceof Integer;
      break;
    case LONG:
      isValid = value instanceof Long;
      break;
    case FLOAT:
      isValid = value instanceof Float;
      break;
    case DOUBLE:
      isValid = value instanceof Double;
      break;
    case BOOLEAN:
      isValid = value instanceof Boolean;
      break;
    case STRING:
      isValid = value instanceof String;
      break;
    case BYTE_STRING:
      isValid = value instanceof ByteString;
      break;
    case ENUM:
      if (value instanceof EnumValueDescriptor) {
        isValid = ((EnumValueDescriptor) value).getType() == field.getEnumType();
      } else if (value instanceof Internal.EnumLite) {
        isValid =
            field.getEnumType().findValueByNumber(((Internal.EnumLite) value).getNumber()) != null;
      } else if (value instanceof Number) {
        isValid = field.getEnumType().findValueByNumber(((Number) value).intValue()) != null;
      } else if (value instanceof String) {
        isValid = field.getEnumType().findValueByName((String) value) != null;
      }

      break;
    case MESSAGE:
      final Class<? extends MessageOrBuilder> expectedType =
      type == null ? Message.class : (Class<? extends MessageOrBuilder>) type;
      final Object resolvedValue =
          value instanceof LazyField ? ((LazyField) value).getValue() : value;
          isValid =
              expectedType.cast(resolvedValue).getDescriptorForType() == field.getMessageType();
          break;
  }

  if (!isValid) {
    // TODO(kenton): When chaining calls to setField(), it can be hard to
    // tell from the stack trace which exact call failed, since the whole
    // chain is considered one line of code. It would be nice to print
    // more information here, e.g. naming the field. We used to do that.
    // But we can't now that FieldSet doesn't use descriptors. Maybe this
    // isn't a big deal, though, since it would only really apply when using
    // reflection and generally people don't chain reflection setters.
    throw new IllegalArgumentException(
        "Wrong object type used with protocol message reflection.");
  }
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:66,代码来源:DynamicMessage.java

示例15: getVerifiedSingleValue

import com.google.protobuf.Internal; //导入方法依赖的package包/类
private static Object getVerifiedSingleValue(final FieldDescriptor field, final Object value,
    final Class<? extends MessageOrBuilder> type) {
  if (value == null) {
    throw new NullPointerException();
  }

  switch (field.getJavaType()) {
    case INT:
      return Integer.class.cast(value);
    case LONG:
      return Long.class.cast(value);
    case FLOAT:
      return Float.class.cast(value);
    case DOUBLE:
      return Double.class.cast(value);
    case BOOLEAN:
      return Boolean.class.cast(value);
    case STRING:
      return String.class.cast(value);
    case BYTE_STRING:
      return ByteString.class.cast(value);
    case ENUM:
      if (value instanceof EnumValueDescriptor) {
        if (((EnumValueDescriptor) value).getType() == field.getEnumType()) {
          return value;
        }
      } else {
        EnumValueDescriptor enumValue = null;

        if (value instanceof Internal.EnumLite) {
          enumValue =
              field.getEnumType().findValueByNumber(((Internal.EnumLite) value).getNumber());
        } else if (value instanceof Number) {
          enumValue = field.getEnumType().findValueByNumber(((Number) value).intValue());
        } else if (value instanceof String) {
          enumValue = field.getEnumType().findValueByName((String) value);
        }

        if (enumValue != null) {
          return enumValue;
        }
      }

      break;
    case MESSAGE:
      final Class<? extends MessageOrBuilder> expectedType =
      type == null ? Message.class : (Class<? extends MessageOrBuilder>) type;
      final MessageOrBuilder resolvedValue =
          expectedType
          .cast(value instanceof LazyField ? ((LazyField) value).getValue() : value);

      if (resolvedValue.getDescriptorForType() == field.getMessageType()) {
        return resolvedValue;
      }

      break;
  }

  throw new IllegalArgumentException("Wrong object type used with protocol message reflection.");
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:61,代码来源:DynamicMessage.java


注:本文中的com.google.protobuf.Internal.EnumLite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。