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


Java TypedUtil.remove方法代码示例

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


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

示例1: MessageInfo

import com.google.ipc.invalidation.util.TypedUtil; //导入方法依赖的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: handleRegistrationStatus

import com.google.ipc.invalidation.util.TypedUtil; //导入方法依赖的package包/类
/**
 * Handles registration operation statuses from the server. Returns a list of booleans, one per
 * registration status, that indicates whether the registration operation was both successful and
 * agreed with the desired client state (i.e., for each registration status,
 * (status.optype == register) == desiredRegistrations.contains(status.objectid)).
 * <p>
 * REQUIRES: the caller subsequently make an informRegistrationStatus or informRegistrationFailure
 * upcall on the listener for each registration in {@code registrationStatuses}.
 */
List<Boolean> handleRegistrationStatus(List<RegistrationStatus> registrationStatuses) {
  // Local-processing result code for each element of registrationStatuses.
  List<Boolean> localStatuses = new ArrayList<Boolean>(registrationStatuses.size());
  for (RegistrationStatus registrationStatus : registrationStatuses) {
    ObjectIdP objectIdProto = registrationStatus.getRegistration().getObjectId();

    // The object is no longer pending, since we have received a server status for it, so
    // remove it from the pendingOperations map. (It may or may not have existed in the map,
    // since we can receive spontaneous status messages from the server.)
    TypedUtil.remove(pendingOperations, objectIdProto);

    // We start off with the local-processing set as success, then potentially fail.
    boolean isSuccess = true;

    // if the server operation succeeded, then local processing fails on "incompatibility" as
    // defined above.
    if (CommonProtos.isSuccess(registrationStatus.getStatus())) {
      boolean appWantsRegistration = desiredRegistrations.contains(objectIdProto);
      boolean isOpRegistration =
          registrationStatus.getRegistration().getOpType() == RegistrationP.OpType.REGISTER;
      boolean discrepancyExists = isOpRegistration ^ appWantsRegistration;
      if (discrepancyExists) {
        // Remove the registration and set isSuccess to false, which will cause the caller to
        // issue registration-failure to the application.
        desiredRegistrations.remove(objectIdProto);
        statistics.recordError(ClientErrorType.REGISTRATION_DISCREPANCY);
        logger.info("Ticl discrepancy detected: registered = %s, requested = %s. " +
            "Removing %s from requested",
            isOpRegistration, appWantsRegistration, objectIdProto);
        isSuccess = false;
      }
    } else {
      // If the server operation failed, then also local processing fails.
      desiredRegistrations.remove(objectIdProto);
      logger.fine("Removing %s from committed", objectIdProto);
      isSuccess = false;
    }
    localStatuses.add(isSuccess);
  }
  return localStatuses;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:51,代码来源:RegistrationManager.java

示例3: resetDelayGeneratorFor

import com.google.ipc.invalidation.util.TypedUtil; //导入方法依赖的package包/类
/**
 * If there is a backoff delay generator for the given object, removes it and sets dirty flag.
 */
private void resetDelayGeneratorFor(ObjectId objectId) {
  if (TypedUtil.remove(delayGenerators, objectId) != null) {
    isDirty = true;
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:9,代码来源:AndroidListenerState.java

示例4: handleRegistrationStatus

import com.google.ipc.invalidation.util.TypedUtil; //导入方法依赖的package包/类
/**
 * Handles registration operation statuses from the server. Returns a list of booleans, one per
 * registration status, that indicates whether the registration operation was both successful and
 * agreed with the desired client state (i.e., for each registration status,
 * (status.optype == register) == desiredRegistrations.contains(status.objectid)).
 * <p>
 * REQUIRES: the caller subsequently make an informRegistrationStatus or informRegistrationFailure
 * upcall on the listener for each registration in {@code registrationStatuses}.
 */
List<Boolean> handleRegistrationStatus(List<RegistrationStatus> registrationStatuses) {
  // Local-processing result code for each element of registrationStatuses.
  List<Boolean> localStatuses = new ArrayList<Boolean>(registrationStatuses.size());
  for (RegistrationStatus registrationStatus : registrationStatuses) {
    ObjectIdP objectIdProto = registrationStatus.getRegistration().getObjectId();

    // The object is no longer pending, since we have received a server status for it, so
    // remove it from the pendingOperations map. (It may or may not have existed in the map,
    // since we can receive spontaneous status messages from the server.)
    TypedUtil.remove(pendingOperations, ProtoWrapper.of(objectIdProto));

    // We start off with the local-processing set as success, then potentially fail.
    boolean isSuccess = true;

    // if the server operation succeeded, then local processing fails on "incompatibility" as
    // defined above.
    if (CommonProtos2.isSuccess(registrationStatus.getStatus())) {
      boolean appWantsRegistration = desiredRegistrations.contains(objectIdProto);
      boolean isOpRegistration =
          registrationStatus.getRegistration().getOpType() == RegistrationP.OpType.REGISTER;
      boolean discrepancyExists = isOpRegistration ^ appWantsRegistration;
      if (discrepancyExists) {
        // Remove the registration and set isSuccess to false, which will cause the caller to
        // issue registration-failure to the application.
        desiredRegistrations.remove(objectIdProto);
        statistics.recordError(ClientErrorType.REGISTRATION_DISCREPANCY);
        logger.info("Ticl discrepancy detected: registered = %s, requested = %s. " +
            "Removing %s from requested",
            isOpRegistration, appWantsRegistration,
            CommonProtoStrings2.toLazyCompactString(objectIdProto));
        isSuccess = false;
      }
    } else {
      // If the server operation failed, then also local processing fails.
      desiredRegistrations.remove(objectIdProto);
      logger.fine("Removing %s from committed",
          CommonProtoStrings2.toLazyCompactString(objectIdProto));
      isSuccess = false;
    }
    localStatuses.add(isSuccess);
  }
  return localStatuses;
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:53,代码来源:RegistrationManager.java


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