All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.protostream.impl.parser.mappers.ProtofileMapper Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.protostream.impl.parser.mappers;

import static org.infinispan.protostream.impl.parser.mappers.Mappers.ENUM_LIST_MAPPER;
import static org.infinispan.protostream.impl.parser.mappers.Mappers.EXTEND_LIST_MAPPER;
import static org.infinispan.protostream.impl.parser.mappers.Mappers.MESSAGE_LIST_MAPPER;
import static org.infinispan.protostream.impl.parser.mappers.Mappers.OPTION_LIST_MAPPER;
import static org.infinispan.protostream.impl.parser.mappers.Mappers.filter;

import java.util.List;

import org.infinispan.protostream.descriptors.FileDescriptor;

import com.squareup.protoparser.EnumElement;
import com.squareup.protoparser.MessageElement;
import com.squareup.protoparser.ProtoFile;

/**
 * Mapper for high level protofile to FileDescriptor.
 *
 * @author gustavonalle
 * @author [email protected]
 * @since 2.0
 */
public final class ProtofileMapper implements Mapper {

   @Override
   public FileDescriptor map(ProtoFile protoFile) {
      List messageTypes = filter(protoFile.typeElements(), MessageElement.class);
      List enumTypes = filter(protoFile.typeElements(), EnumElement.class);
      return new FileDescriptor.Builder()
            .withName(protoFile.filePath())
            .withPackageName(protoFile.packageName())
            .withMessageTypes(MESSAGE_LIST_MAPPER.map(messageTypes))
            .withEnumTypes(ENUM_LIST_MAPPER.map(enumTypes))
            .withExtendDescriptors(EXTEND_LIST_MAPPER.map(protoFile.extendDeclarations()))
            .withOptions(OPTION_LIST_MAPPER.map(protoFile.options()))
            .withDependencies(protoFile.dependencies())
            .withPublicDependencies(protoFile.publicDependencies())
            .build();
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy