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


Java Presence.REQUIRED属性代码示例

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


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

示例1: MessageInfo

/**
 * Constructs a message info.
 *
 * @param messageAccessor descriptor for the protocol buffer
 * @param fields information about the fields
 */
public MessageInfo(Accessor messageAccessor, FieldInfo... fields) {
  // Track which fields in the message descriptor have not yet been covered by a FieldInfo.
  // We'll use this to verify that we get a FieldInfo for every field.
  Set<String> unusedDescriptors = new HashSet<String>();
  unusedDescriptors.addAll(messageAccessor.getAllFieldNames());

  this.messageAccessor = messageAccessor;
  for (FieldInfo info : fields) {
    // Lookup the field given the name in the FieldInfo.
    boolean removed = TypedUtil.remove(unusedDescriptors, info.getFieldDescriptor().getName());
    Preconditions.checkState(removed, "Bad field: %s", info.getFieldDescriptor().getName());

    // Add the field info to the number -> info map.
    fieldInfo.add(info);

    if (info.getPresence() == Presence.REQUIRED) {
      ++numRequiredFields;
    }
  }
  Preconditions.checkState(unusedDescriptors.isEmpty(), "Not all fields specified in %s: %s",
      messageAccessor, unusedDescriptors);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:28,代码来源:ProtoValidator.java

示例2: newRequired

/**
 * Returns a new instance describing a required field with name {@code fieldName} and validation
 * specified by {@code messageInfo}.
 */
public static FieldInfo newRequired(Descriptor fieldDescriptor, MessageInfo messageInfo) {
  return new FieldInfo(fieldDescriptor, Presence.REQUIRED,
      Preconditions.checkNotNull(messageInfo, "messageInfo cannot be null"));
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:8,代码来源:ProtoValidator.java


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