本文整理汇总了Java中com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader.hasMessageId方法的典型用法代码示例。如果您正苦于以下问题:Java ServerHeader.hasMessageId方法的具体用法?Java ServerHeader.hasMessageId怎么用?Java ServerHeader.hasMessageId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader
的用法示例。
在下文中一共展示了ServerHeader.hasMessageId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasField
import com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader; //导入方法依赖的package包/类
/** Returns whether {@code field} is present in {@code message}. */
@Override
@SuppressWarnings("unchecked")
public boolean hasField(MessageLite rawMessage, Descriptor field) {
Preconditions.checkNotNull(rawMessage);
Preconditions.checkNotNull(field);
ServerHeader message = (ServerHeader) rawMessage;
if (field == PROTOCOL_VERSION) {
return message.hasProtocolVersion();
}
if (field == CLIENT_TOKEN) {
return message.hasClientToken();
}
if (field == REGISTRATION_SUMMARY) {
return message.hasRegistrationSummary();
}
if (field == SERVER_TIME_MS) {
return message.hasServerTimeMs();
}
if (field == MESSAGE_ID) {
return message.hasMessageId();
}
throw new IllegalArgumentException("Bad descriptor: " + field);
}
示例2: postValidate
import com.google.protos.ipc.invalidation.ClientProtocol.ServerHeader; //导入方法依赖的package包/类
@Override
public boolean postValidate(MessageLite message) {
ServerHeader header = (ServerHeader) message;
if (header.getClientToken().isEmpty()) {
logger.info("Client token was empty: %s", header);
return false;
}
if (header.getServerTimeMs() < 0) {
logger.info("Server time was negative: %s", header);
return false;
}
// If set, message id must not be empty.
// Do not use String.isEmpty() here for Froyo (JDK5) compatibility.
if (header.hasMessageId() && (header.getMessageId().length() == 0)) {
logger.info("Message id was set but empty: %s", header);
return false;
}
return true;
}