StorageFormatRegistry.java 文件源码

java
阅读 78 收藏 0 点赞 0 评论 0

项目:sql-layer 作者:
/** 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);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号