當前位置: 首頁>>代碼示例>>Java>>正文


Java GeneratedMessage.GeneratedExtension方法代碼示例

本文整理匯總了Java中com.google.protobuf.GeneratedMessage.GeneratedExtension方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratedMessage.GeneratedExtension方法的具體用法?Java GeneratedMessage.GeneratedExtension怎麽用?Java GeneratedMessage.GeneratedExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.protobuf.GeneratedMessage的用法示例。


在下文中一共展示了GeneratedMessage.GeneratedExtension方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerStorageFormat

import com.google.protobuf.GeneratedMessage; //導入方法依賴的package包/類
/** Register a new {@link StorageFormat}.
 * @param protobufExtension the extension field that keys use of this format
 * @param sqlIdentifier the <code>STORAGE_FORMAT</code> identifier that keys use of this format or <code>null</code>
 * @param descriptionClass that specific class used to hold this format
 * @param storageFormat the mapping handler
 */
public <T extends StorageDescription> void registerStorageFormat(GeneratedMessage.GeneratedExtension<Storage,?> protobufExtension, String sqlIdentifier, Class<T> descriptionClass, StorageFormat<T> storageFormat) {
    int fieldNumber = protobufExtension.getDescriptor().getNumber();
    if (formatsByField.containsKey(fieldNumber))
        throw new IllegalArgumentException("there is already a StorageFormat registered for field " + fieldNumber);
    if ((sqlIdentifier != null) &&
            formatsByIdentifier.containsKey(sqlIdentifier))
        throw new IllegalArgumentException("there is already a StorageFormat registered for STORAGE_FORMAT " + sqlIdentifier);
    if (!isDescriptionClassAllowed(descriptionClass)) {
        throw new IllegalArgumentException("description " + descriptionClass + " not allowed for " + getClass().getSimpleName());
    }
    extensionRegistry.add(protobufExtension);
    Format<T> format = new Format<T>(protobufExtension, sqlIdentifier, descriptionClass, storageFormat);
    formatsInOrder.add(format);
    formatsByField.put(fieldNumber, format);
    if (sqlIdentifier != null) {
        formatsByIdentifier.put(sqlIdentifier, format);
    }
}
 
開發者ID:jaytaylor,項目名稱:sql-layer,代碼行數:25,代碼來源:StorageFormatRegistry.java

示例2: add

import com.google.protobuf.GeneratedMessage; //導入方法依賴的package包/類
public ProtobufExtensionLookup add(Class<?> parent) {
  // find all the generated service extensions for the class specified
  for (Field field : parent.getFields()) {
    // skip anything that isn't a generated extension. should be fine as long as we dont start
    // mucking around with class loaders
    if (field.getType() != GeneratedMessage.GeneratedExtension.class) {
      continue;
    }

    try {
      GeneratedMessage.GeneratedExtension extension =
          (GeneratedMessage.GeneratedExtension) field.get(parent);
      Message defaultMessageInst = extension.getMessageDefaultInstance();
      this.fields.put(defaultMessageInst.getClass(), extension);
    } catch (IllegalAccessException e) {
      LOG.warn("Could not not access " + field + " for " + parent);
    }
  }
  return this;
}
 
開發者ID:salesforce,項目名稱:coyote,代碼行數:21,代碼來源:ProtobufExtensionLookup.java

示例3: Format

import com.google.protobuf.GeneratedMessage; //導入方法依賴的package包/類
public Format(GeneratedMessage.GeneratedExtension<Storage,?> protobufExtension, String sqlIdentifier, Class<T> descriptionClass, StorageFormat<T> storageFormat) {
    this.protobufExtension = protobufExtension;
    this.sqlIdentifier = sqlIdentifier;
    this.descriptionClass = descriptionClass;
    this.storageFormat = storageFormat;
}
 
開發者ID:jaytaylor,項目名稱:sql-layer,代碼行數:7,代碼來源:StorageFormatRegistry.java

示例4: getExtension

import com.google.protobuf.GeneratedMessage; //導入方法依賴的package包/類
public GeneratedMessage.GeneratedExtension getExtension(Message message) {
  return fields.get(message.getClass());
}
 
開發者ID:salesforce,項目名稱:coyote,代碼行數:4,代碼來源:ProtobufExtensionLookup.java

示例5: translate

import com.google.protobuf.GeneratedMessage; //導入方法依賴的package包/類
/**
 * Translate from the external RPC message to the actual message embedded as an extension in
 * the Rpc message
 *
 * @param receivedMessage generic RPC received
 * @param prototype prototype of the message that we expect to receive
 * @return the twice wrapped underlying rpc message
 */
public Message translate(Rpc rpc, Message prototype) {
  // unwrap the underlying message, which should be bound to one of the extensions
  GeneratedMessage.GeneratedExtension<RpcMessages.Rpc, Message> responseExtension =
      extensions.getExtension(prototype);
  return rpc.getExtension(responseExtension);
}
 
開發者ID:salesforce,項目名稱:coyote,代碼行數:15,代碼來源:ProtobufServiceTranslator.java


注:本文中的com.google.protobuf.GeneratedMessage.GeneratedExtension方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。