本文整理汇总了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);
}
示例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"));
}