Package dev.cel.common
Class CelDescriptorUtil
- java.lang.Object
-
- dev.cel.common.CelDescriptorUtil
-
public final class CelDescriptorUtil extends java.lang.Object
Utility class for working with protobuf descriptors.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Descriptors.GenericDescriptor>
com.google.common.collect.ImmutableMap<java.lang.String,T>descriptorCollectionToMap(java.util.Collection<T> descriptors)
Converts descriptor collection to an ImmutableMap.static CelDescriptors
getAllDescriptorsFromFileDescriptor(Descriptors.FileDescriptor... fileDescriptors)
Extract the full messageCelDescriptors
set from the input set offileDescriptors
.static CelDescriptors
getAllDescriptorsFromFileDescriptor(java.lang.Iterable<Descriptors.FileDescriptor> fileDescriptors)
Extract the full messageCelDescriptors
set from the input set offileDescriptors
.static CelDescriptors
getAllDescriptorsFromFileDescriptor(java.lang.Iterable<Descriptors.FileDescriptor> fileDescriptors, boolean resolveTypeDependencies)
Extract the full messageFileDescriptor
set from the input set offileDescriptors
.static com.google.common.collect.ImmutableSet<Descriptors.FileDescriptor>
getFileDescriptorsForDescriptors(java.lang.Iterable<Descriptors.Descriptor> descriptors)
Get the fullFileDescriptor
set needed to accurately instantiate thedescriptors
.static com.google.common.collect.ImmutableSet<Descriptors.FileDescriptor>
getFileDescriptorsFromFileDescriptorSet(DescriptorProtos.FileDescriptorSet fileDescriptorSet)
Convert aFileDescriptorSet
into a set ofFileDescriptor
instances.
-
-
-
Method Detail
-
descriptorCollectionToMap
public static <T extends Descriptors.GenericDescriptor> com.google.common.collect.ImmutableMap<java.lang.String,T> descriptorCollectionToMap(java.util.Collection<T> descriptors)
Converts descriptor collection to an ImmutableMap.Key: Descriptor's full name, Value: Descriptor object
-
getFileDescriptorsForDescriptors
public static com.google.common.collect.ImmutableSet<Descriptors.FileDescriptor> getFileDescriptorsForDescriptors(java.lang.Iterable<Descriptors.Descriptor> descriptors)
Get the fullFileDescriptor
set needed to accurately instantiate thedescriptors
.
-
getFileDescriptorsFromFileDescriptorSet
public static com.google.common.collect.ImmutableSet<Descriptors.FileDescriptor> getFileDescriptorsFromFileDescriptorSet(DescriptorProtos.FileDescriptorSet fileDescriptorSet)
Convert aFileDescriptorSet
into a set ofFileDescriptor
instances.Warning: This will produce unique FileDescriptor instances. Use with care especially in hermetic environments.
-
getAllDescriptorsFromFileDescriptor
public static CelDescriptors getAllDescriptorsFromFileDescriptor(Descriptors.FileDescriptor... fileDescriptors)
Extract the full messageCelDescriptors
set from the input set offileDescriptors
. All message type, enum, extension and file descriptors will be extracted.Note, the input
fileDescriptors
set will be expanded to the complete set of dependencies needed to describe the types within the provided files.
-
getAllDescriptorsFromFileDescriptor
public static CelDescriptors getAllDescriptorsFromFileDescriptor(java.lang.Iterable<Descriptors.FileDescriptor> fileDescriptors)
Extract the full messageCelDescriptors
set from the input set offileDescriptors
. All message type, enum, extension and file descriptors will be extracted.Note, the input
fileDescriptors
set will be expanded to the complete set of dependencies needed to describe the types within the provided files.
-
getAllDescriptorsFromFileDescriptor
public static CelDescriptors getAllDescriptorsFromFileDescriptor(java.lang.Iterable<Descriptors.FileDescriptor> fileDescriptors, boolean resolveTypeDependencies)
Extract the full messageFileDescriptor
set from the input set offileDescriptors
. All message type, enum, extension and file descriptors will be extracted.- Parameters:
resolveTypeDependencies
- Performs a deep type dependency resolution by expanding all the FileDescriptors marked as dependents listed in their imports (Ex: If FileDescriptor A imports on FileDescriptor B, FD B's descriptors will be pulled in). Setting false will disable this.
-
-