// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * Generated by CEL-Java library. DO NOT EDIT!
 * Version: ${version}
 */

package ${package_name};

import dev.cel.common.annotations.Generated;
import dev.cel.protobuf.CelLiteDescriptor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Generated("dev.cel.protobuf.CelLiteDescriptorGenerator")
public final class ${descriptor_class_name} extends CelLiteDescriptor {

  private static final ${descriptor_class_name} DESCRIPTOR = new ${descriptor_class_name}();

  public static ${descriptor_class_name} getDescriptor() {
    return DESCRIPTOR;
  }

  private static List<MessageLiteDescriptor> newDescriptors() {
    List<MessageLiteDescriptor> descriptors = new ArrayList<>(${descriptor_metadata_list?size});
    List<FieldLiteDescriptor> fieldDescriptors;
    <#list descriptor_metadata_list as descriptor_metadata>

    fieldDescriptors = new ArrayList<>(${descriptor_metadata.fieldDescriptors?size});
      <#list descriptor_metadata.fieldDescriptors as field_descriptor>
    fieldDescriptors.add(new FieldLiteDescriptor(
      ${field_descriptor.fieldNumber},
      "${field_descriptor.fieldName}",
      ${field_descriptor.javaTypeEnumName},
      ${field_descriptor.encodingTypeEnumName},
      ${field_descriptor.protoFieldTypeEnumName},
      ${field_descriptor.isPacked},
      "${field_descriptor.fieldProtoTypeName}"
      ));
      </#list>

    descriptors.add(
      new MessageLiteDescriptor(
        "${descriptor_metadata.protoTypeName}",
        fieldDescriptors,
        <#if descriptor_metadata.javaClassName??>
        ${descriptor_metadata.javaClassName}::newBuilder
        <#else>
        () -> null
        </#if>
        )
    );
    </#list>

    return Collections.unmodifiableList(descriptors);
  }

  private ${descriptor_class_name}() {
    super("${version}", newDescriptors());
  }
}