• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Presence类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Presence类属于com.google.ipc.invalidation.common.ProtoValidator.FieldInfo包,在下文中一共展示了Presence类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: MessageInfo

import com.google.ipc.invalidation.common.ProtoValidator.FieldInfo.Presence; //导入依赖的package包/类
/**
 * 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,代码行数:29,代码来源:ProtoValidator.java


示例2: checkMessage

import com.google.ipc.invalidation.common.ProtoValidator.FieldInfo.Presence; //导入依赖的package包/类
/**
 * Returns whether {@code message} is valid.
 * @param messageInfo specification of validity for {@code message}
 */

protected boolean checkMessage(MessageLite message, MessageInfo messageInfo) {
  for (FieldInfo fieldInfo : messageInfo.getAllFields()) {
    Descriptor fieldDescriptor = fieldInfo.getFieldDescriptor();
    boolean isFieldPresent =
        messageInfo.messageAccessor.hasField(message, fieldDescriptor);

    // If the field must be present but isn't, fail.
    if ((fieldInfo.getPresence() == FieldInfo.Presence.REQUIRED) && !(isFieldPresent)) {
      logger.warning("Required field not set: %s", fieldInfo.getFieldDescriptor().getName());
      return false;
    }

    // If the field is present and requires its own validation, validate it.
    if (isFieldPresent && fieldInfo.requiresAdditionalValidation()) {
      for (MessageLite subMessage : TiclMessageValidator2.<MessageLite>getFieldIterable(
          message, messageInfo.messageAccessor, fieldDescriptor)) {
        if (!checkMessage(subMessage, fieldInfo.getMessageInfo())) {
          return false;
        }
      }
    }
  }

  // Once we've validated all fields, post-validate this message.
  if (!messageInfo.postValidate(message)) {
    logger.info("Failed post-validation of message (%s): %s",
        message.getClass().getSimpleName(), message);
    return false;
  }
  return true;
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:37,代码来源:ProtoValidator.java


示例3: getPresence

import com.google.ipc.invalidation.common.ProtoValidator.FieldInfo.Presence; //导入依赖的package包/类
/** Returns the presence information for the field. */
Presence getPresence() {
  return presence;
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:5,代码来源:ProtoValidator.java


示例4: newRequired

import com.google.ipc.invalidation.common.ProtoValidator.FieldInfo.Presence; //导入依赖的package包/类
/**
 * 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,代码行数:9,代码来源:ProtoValidator.java


示例5: newOptional

import com.google.ipc.invalidation.common.ProtoValidator.FieldInfo.Presence; //导入依赖的package包/类
/**
 * Returns a new instance describing an optional field with name {@code fieldName} and
 * validation specified by {@code messageInfo}.
 */
public static FieldInfo newOptional(Descriptor fieldDescriptor, MessageInfo messageInfo) {
  return new FieldInfo(fieldDescriptor, Presence.OPTIONAL,
      Preconditions.checkNotNull(messageInfo));
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:9,代码来源:ProtoValidator.java


示例6: FieldInfo

import com.google.ipc.invalidation.common.ProtoValidator.FieldInfo.Presence; //导入依赖的package包/类
/**
 * Constructs an instance.
 *
 * @param fieldDescriptor identifier for the field
 * @param presence required/optional
 * @param messageInfo if not {@code null}, describes how to validate the field
 */
FieldInfo(Descriptor fieldDescriptor, Presence presence,
    MessageInfo messageInfo) {
  this.fieldDescriptor = fieldDescriptor;
  this.presence = presence;
  this.messageInfo = messageInfo;
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:14,代码来源:ProtoValidator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HttpMethod类代码示例发布时间:2022-05-22
下一篇:
Java JpegImageParser类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap