text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/api/billing.proto

package com.google.api;

/**
 *
 *
 *

 * Billing related configuration of the service.
 * The following example shows how to configure monitored resources and metrics
 * for billing, `consumer_destinations` is the only supported destination and
 * the monitored resources need at least one label key
 * `cloud.googleapis.com/location` to indicate the location of the billing
 * usage, using different monitored resources between monitoring and billing is
 * recommended so they can be evolved independently:
 *     monitored_resources:
 *     - type: library.googleapis.com/billing_branch
 *       labels:
 *       - key: cloud.googleapis.com/location
 *         description: |
 *           Predefined label to support billing location restriction.
 *       - key: city
 *         description: |
 *           Custom label to define the city where the library branch is located
 *           in.
 *       - key: name
 *         description: Custom label to define the name of the library branch.
 *     metrics:
 *     - name: library.googleapis.com/book/borrowed_count
 *       metric_kind: DELTA
 *       value_type: INT64
 *       unit: "1"
 *     billing:
 *       consumer_destinations:
 *       - monitored_resource: library.googleapis.com/billing_branch
 *         metrics:
 *         - library.googleapis.com/book/borrowed_count
 *

 *
 * Protobuf type {@code google.api.Billing}
 */
public final class Billing extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.api.Billing)
    BillingOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use Billing.newBuilder() to construct.
  private Billing(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private Billing() {
    consumerDestinations_ = java.util.Collections.emptyList();
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
    return new Billing();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
    return this.unknownFields;
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.api.BillingProto.internal_static_google_api_Billing_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.api.BillingProto.internal_static_google_api_Billing_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.api.Billing.class, com.google.api.Billing.Builder.class);
  }

  public interface BillingDestinationOrBuilder
      extends
      // @@protoc_insertion_point(interface_extends:google.api.Billing.BillingDestination)
      com.google.protobuf.MessageOrBuilder {

    /**
     *
     *
     *

     * The monitored resource type. The type must be defined in
     * [Service.monitored_resources][google.api.Service.monitored_resources] section.
     *

     *
     * string monitored_resource = 1;
     *
     * @return The monitoredResource.
     */
    java.lang.String getMonitoredResource();
    /**
     *
     *
     *

     * The monitored resource type. The type must be defined in
     * [Service.monitored_resources][google.api.Service.monitored_resources] section.
     *

     *
     * string monitored_resource = 1;
     *
     * @return The bytes for monitoredResource.
     */
    com.google.protobuf.ByteString getMonitoredResourceBytes();

    /**
     *
     *
     *

     * Names of the metrics to report to this billing destination.
     * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
     *

     *
     * repeated string metrics = 2;
     *
     * @return A list containing the metrics.
     */
    java.util.List<java.lang.String> getMetricsList();
    /**
     *
     *
     *

     * Names of the metrics to report to this billing destination.
     * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
     *

     *
     * repeated string metrics = 2;
     *
     * @return The count of metrics.
     */
    int getMetricsCount();
    /**
     *
     *
     *

     * Names of the metrics to report to this billing destination.
     * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
     *

     *
     * repeated string metrics = 2;
     *
     * @param index The index of the element to return.
     * @return The metrics at the given index.
     */
    java.lang.String getMetrics(int index);
    /**
     *
     *
     *

     * Names of the metrics to report to this billing destination.
     * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
     *

     *
     * repeated string metrics = 2;
     *
     * @param index The index of the value to return.
     * @return The bytes of the metrics at the given index.
     */
    com.google.protobuf.ByteString getMetricsBytes(int index);
  }
  /**
   *
   *
   *

   * Configuration of a specific billing destination (Currently only support
   * bill against consumer project).
   *

   *
   * Protobuf type {@code google.api.Billing.BillingDestination}
   */
  public static final class BillingDestination extends com.google.protobuf.GeneratedMessageV3
      implements
      // @@protoc_insertion_point(message_implements:google.api.Billing.BillingDestination)
      BillingDestinationOrBuilder {
    private static final long serialVersionUID = 0L;
    // Use BillingDestination.newBuilder() to construct.
    private BillingDestination(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
      super(builder);
    }

    private BillingDestination() {
      monitoredResource_ = "";
      metrics_ = com.google.protobuf.LazyStringArrayList.EMPTY;
    }

    @java.lang.Override
    @SuppressWarnings({"unused"})
    protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
      return new BillingDestination();
    }

    @java.lang.Override
    public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
      return this.unknownFields;
    }

    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.api.BillingProto
          .internal_static_google_api_Billing_BillingDestination_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.api.BillingProto
          .internal_static_google_api_Billing_BillingDestination_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.api.Billing.BillingDestination.class,
              com.google.api.Billing.BillingDestination.Builder.class);
    }

    public static final int MONITORED_RESOURCE_FIELD_NUMBER = 1;
    private volatile java.lang.Object monitoredResource_;
    /**
     *
     *
     *

     * The monitored resource type. The type must be defined in
     * [Service.monitored_resources][google.api.Service.monitored_resources] section.
     *

     *
     * string monitored_resource = 1;
     *
     * @return The monitoredResource.
     */
    @java.lang.Override
    public java.lang.String getMonitoredResource() {
      java.lang.Object ref = monitoredResource_;
      if (ref instanceof java.lang.String) {
        return (java.lang.String) ref;
      } else {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        monitoredResource_ = s;
        return s;
      }
    }
    /**
     *
     *
     *

     * The monitored resource type. The type must be defined in
     * [Service.monitored_resources][google.api.Service.monitored_resources] section.
     *

     *
     * string monitored_resource = 1;
     *
     * @return The bytes for monitoredResource.
     */
    @java.lang.Override
    public com.google.protobuf.ByteString getMonitoredResourceBytes() {
      java.lang.Object ref = monitoredResource_;
      if (ref instanceof java.lang.String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        monitoredResource_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }

    public static final int METRICS_FIELD_NUMBER = 2;
    private com.google.protobuf.LazyStringList metrics_;
    /**
     *
     *
     *

     * Names of the metrics to report to this billing destination.
     * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
     *

     *
     * repeated string metrics = 2;
     *
     * @return A list containing the metrics.
     */
    public com.google.protobuf.ProtocolStringList getMetricsList() {
      return metrics_;
    }
    /**
     *
     *
     *

     * Names of the metrics to report to this billing destination.
     * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
     *

     *
     * repeated string metrics = 2;
     *
     * @return The count of metrics.
     */
    public int getMetricsCount() {
      return metrics_.size();
    }
    /**
     *
     *
     *

     * Names of the metrics to report to this billing destination.
     * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
     *

     *
     * repeated string metrics = 2;
     *
     * @param index The index of the element to return.
     * @return The metrics at the given index.
     */
    public java.lang.String getMetrics(int index) {
      return metrics_.get(index);
    }
    /**
     *
     *
     *

     * Names of the metrics to report to this billing destination.
     * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
     *

     *
     * repeated string metrics = 2;
     *
     * @param index The index of the value to return.
     * @return The bytes of the metrics at the given index.
     */
    public com.google.protobuf.ByteString getMetricsBytes(int index) {
      return metrics_.getByteString(index);
    }

    private byte memoizedIsInitialized = -1;

    @java.lang.Override
    public final boolean isInitialized() {
      byte isInitialized = memoizedIsInitialized;
      if (isInitialized == 1) return true;
      if (isInitialized == 0) return false;

      memoizedIsInitialized = 1;
      return true;
    }

    @java.lang.Override
    public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
      if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(monitoredResource_)) {
        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, monitoredResource_);
      }
      for (int i = 0; i < metrics_.size(); i++) {
        com.google.protobuf.GeneratedMessageV3.writeString(output, 2, metrics_.getRaw(i));
      }
      getUnknownFields().writeTo(output);
    }

    @java.lang.Override
    public int getSerializedSize() {
      int size = memoizedSize;
      if (size != -1) return size;

      size = 0;
      if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(monitoredResource_)) {
        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, monitoredResource_);
      }
      {
        int dataSize = 0;
        for (int i = 0; i < metrics_.size(); i++) {
          dataSize += computeStringSizeNoTag(metrics_.getRaw(i));
        }
        size += dataSize;
        size += 1 * getMetricsList().size();
      }
      size += getUnknownFields().getSerializedSize();
      memoizedSize = size;
      return size;
    }

    @java.lang.Override
    public boolean equals(final java.lang.Object obj) {
      if (obj == this) {
        return true;
      }
      if (!(obj instanceof com.google.api.Billing.BillingDestination)) {
        return super.equals(obj);
      }
      com.google.api.Billing.BillingDestination other =
          (com.google.api.Billing.BillingDestination) obj;

      if (!getMonitoredResource().equals(other.getMonitoredResource())) return false;
      if (!getMetricsList().equals(other.getMetricsList())) return false;
      if (!getUnknownFields().equals(other.getUnknownFields())) return false;
      return true;
    }

    @java.lang.Override
    public int hashCode() {
      if (memoizedHashCode != 0) {
        return memoizedHashCode;
      }
      int hash = 41;
      hash = (19 * hash) + getDescriptor().hashCode();
      hash = (37 * hash) + MONITORED_RESOURCE_FIELD_NUMBER;
      hash = (53 * hash) + getMonitoredResource().hashCode();
      if (getMetricsCount() > 0) {
        hash = (37 * hash) + METRICS_FIELD_NUMBER;
        hash = (53 * hash) + getMetricsList().hashCode();
      }
      hash = (29 * hash) + getUnknownFields().hashCode();
      memoizedHashCode = hash;
      return hash;
    }

    public static com.google.api.Billing.BillingDestination parseFrom(java.nio.ByteBuffer data)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data);
    }

    public static com.google.api.Billing.BillingDestination parseFrom(
        java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data, extensionRegistry);
    }

    public static com.google.api.Billing.BillingDestination parseFrom(
        com.google.protobuf.ByteString data)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data);
    }

    public static com.google.api.Billing.BillingDestination parseFrom(
        com.google.protobuf.ByteString data,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data, extensionRegistry);
    }

    public static com.google.api.Billing.BillingDestination parseFrom(byte[] data)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data);
    }

    public static com.google.api.Billing.BillingDestination parseFrom(
        byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data, extensionRegistry);
    }

    public static com.google.api.Billing.BillingDestination parseFrom(java.io.InputStream input)
        throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
    }

    public static com.google.api.Billing.BillingDestination parseFrom(
        java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
          PARSER, input, extensionRegistry);
    }

    public static com.google.api.Billing.BillingDestination parseDelimitedFrom(
        java.io.InputStream input) throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
    }

    public static com.google.api.Billing.BillingDestination parseDelimitedFrom(
        java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(
          PARSER, input, extensionRegistry);
    }

    public static com.google.api.Billing.BillingDestination parseFrom(
        com.google.protobuf.CodedInputStream input) throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
    }

    public static com.google.api.Billing.BillingDestination parseFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
          PARSER, input, extensionRegistry);
    }

    @java.lang.Override
    public Builder newBuilderForType() {
      return newBuilder();
    }

    public static Builder newBuilder() {
      return DEFAULT_INSTANCE.toBuilder();
    }

    public static Builder newBuilder(com.google.api.Billing.BillingDestination prototype) {
      return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
    }

    @java.lang.Override
    public Builder toBuilder() {
      return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
    }

    @java.lang.Override
    protected Builder newBuilderForType(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      Builder builder = new Builder(parent);
      return builder;
    }
    /**
     *
     *
     *

     * Configuration of a specific billing destination (Currently only support
     * bill against consumer project).
     *

     *
     * Protobuf type {@code google.api.Billing.BillingDestination}
     */
    public static final class Builder
        extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
        implements
        // @@protoc_insertion_point(builder_implements:google.api.Billing.BillingDestination)
        com.google.api.Billing.BillingDestinationOrBuilder {
      public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
        return com.google.api.BillingProto
            .internal_static_google_api_Billing_BillingDestination_descriptor;
      }

      @java.lang.Override
      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
          internalGetFieldAccessorTable() {
        return com.google.api.BillingProto
            .internal_static_google_api_Billing_BillingDestination_fieldAccessorTable
            .ensureFieldAccessorsInitialized(
                com.google.api.Billing.BillingDestination.class,
                com.google.api.Billing.BillingDestination.Builder.class);
      }

      // Construct using com.google.api.Billing.BillingDestination.newBuilder()
      private Builder() {}

      private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
        super(parent);
      }

      @java.lang.Override
      public Builder clear() {
        super.clear();
        monitoredResource_ = "";

        metrics_ = com.google.protobuf.LazyStringArrayList.EMPTY;
        bitField0_ = (bitField0_ & ~0x00000001);
        return this;
      }

      @java.lang.Override
      public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
        return com.google.api.BillingProto
            .internal_static_google_api_Billing_BillingDestination_descriptor;
      }

      @java.lang.Override
      public com.google.api.Billing.BillingDestination getDefaultInstanceForType() {
        return com.google.api.Billing.BillingDestination.getDefaultInstance();
      }

      @java.lang.Override
      public com.google.api.Billing.BillingDestination build() {
        com.google.api.Billing.BillingDestination result = buildPartial();
        if (!result.isInitialized()) {
          throw newUninitializedMessageException(result);
        }
        return result;
      }

      @java.lang.Override
      public com.google.api.Billing.BillingDestination buildPartial() {
        com.google.api.Billing.BillingDestination result =
            new com.google.api.Billing.BillingDestination(this);
        int from_bitField0_ = bitField0_;
        result.monitoredResource_ = monitoredResource_;
        if (((bitField0_ & 0x00000001) != 0)) {
          metrics_ = metrics_.getUnmodifiableView();
          bitField0_ = (bitField0_ & ~0x00000001);
        }
        result.metrics_ = metrics_;
        onBuilt();
        return result;
      }

      @java.lang.Override
      public Builder clone() {
        return super.clone();
      }

      @java.lang.Override
      public Builder setField(
          com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
        return super.setField(field, value);
      }

      @java.lang.Override
      public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
        return super.clearField(field);
      }

      @java.lang.Override
      public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
        return super.clearOneof(oneof);
      }

      @java.lang.Override
      public Builder setRepeatedField(
          com.google.protobuf.Descriptors.FieldDescriptor field,
          int index,
          java.lang.Object value) {
        return super.setRepeatedField(field, index, value);
      }

      @java.lang.Override
      public Builder addRepeatedField(
          com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
        return super.addRepeatedField(field, value);
      }

      @java.lang.Override
      public Builder mergeFrom(com.google.protobuf.Message other) {
        if (other instanceof com.google.api.Billing.BillingDestination) {
          return mergeFrom((com.google.api.Billing.BillingDestination) other);
        } else {
          super.mergeFrom(other);
          return this;
        }
      }

      public Builder mergeFrom(com.google.api.Billing.BillingDestination other) {
        if (other == com.google.api.Billing.BillingDestination.getDefaultInstance()) return this;
        if (!other.getMonitoredResource().isEmpty()) {
          monitoredResource_ = other.monitoredResource_;
          onChanged();
        }
        if (!other.metrics_.isEmpty()) {
          if (metrics_.isEmpty()) {
            metrics_ = other.metrics_;
            bitField0_ = (bitField0_ & ~0x00000001);
          } else {
            ensureMetricsIsMutable();
            metrics_.addAll(other.metrics_);
          }
          onChanged();
        }
        this.mergeUnknownFields(other.getUnknownFields());
        onChanged();
        return this;
      }

      @java.lang.Override
      public final boolean isInitialized() {
        return true;
      }

      @java.lang.Override
      public Builder mergeFrom(
          com.google.protobuf.CodedInputStream input,
          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
          throws java.io.IOException {
        if (extensionRegistry == null) {
          throw new java.lang.NullPointerException();
        }
        try {
          boolean done = false;
          while (!done) {
            int tag = input.readTag();
            switch (tag) {
              case 0:
                done = true;
                break;
              case 10:
                {
                  monitoredResource_ = input.readStringRequireUtf8();

                  break;
                } // case 10
              case 18:
                {
                  java.lang.String s = input.readStringRequireUtf8();
                  ensureMetricsIsMutable();
                  metrics_.add(s);
                  break;
                } // case 18
              default:
                {
                  if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                    done = true; // was an endgroup tag
                  }
                  break;
                } // default:
            } // switch (tag)
          } // while (!done)
        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
          throw e.unwrapIOException();
        } finally {
          onChanged();
        } // finally
        return this;
      }

      private int bitField0_;

      private java.lang.Object monitoredResource_ = "";
      /**
       *
       *
       *

       * The monitored resource type. The type must be defined in
       * [Service.monitored_resources][google.api.Service.monitored_resources] section.
       *

       *
       * string monitored_resource = 1;
       *
       * @return The monitoredResource.
       */
      public java.lang.String getMonitoredResource() {
        java.lang.Object ref = monitoredResource_;
        if (!(ref instanceof java.lang.String)) {
          com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
          java.lang.String s = bs.toStringUtf8();
          monitoredResource_ = s;
          return s;
        } else {
          return (java.lang.String) ref;
        }
      }
      /**
       *
       *
       *

       * The monitored resource type. The type must be defined in
       * [Service.monitored_resources][google.api.Service.monitored_resources] section.
       *

       *
       * string monitored_resource = 1;
       *
       * @return The bytes for monitoredResource.
       */
      public com.google.protobuf.ByteString getMonitoredResourceBytes() {
        java.lang.Object ref = monitoredResource_;
        if (ref instanceof String) {
          com.google.protobuf.ByteString b =
              com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
          monitoredResource_ = b;
          return b;
        } else {
          return (com.google.protobuf.ByteString) ref;
        }
      }
      /**
       *
       *
       *

       * The monitored resource type. The type must be defined in
       * [Service.monitored_resources][google.api.Service.monitored_resources] section.
       *

       *
       * string monitored_resource = 1;
       *
       * @param value The monitoredResource to set.
       * @return This builder for chaining.
       */
      public Builder setMonitoredResource(java.lang.String value) {
        if (value == null) {
          throw new NullPointerException();
        }

        monitoredResource_ = value;
        onChanged();
        return this;
      }
      /**
       *
       *
       *

       * The monitored resource type. The type must be defined in
       * [Service.monitored_resources][google.api.Service.monitored_resources] section.
       *

       *
       * string monitored_resource = 1;
       *
       * @return This builder for chaining.
       */
      public Builder clearMonitoredResource() {

        monitoredResource_ = getDefaultInstance().getMonitoredResource();
        onChanged();
        return this;
      }
      /**
       *
       *
       *

       * The monitored resource type. The type must be defined in
       * [Service.monitored_resources][google.api.Service.monitored_resources] section.
       *

       *
       * string monitored_resource = 1;
       *
       * @param value The bytes for monitoredResource to set.
       * @return This builder for chaining.
       */
      public Builder setMonitoredResourceBytes(com.google.protobuf.ByteString value) {
        if (value == null) {
          throw new NullPointerException();
        }
        checkByteStringIsUtf8(value);

        monitoredResource_ = value;
        onChanged();
        return this;
      }

      private com.google.protobuf.LazyStringList metrics_ =
          com.google.protobuf.LazyStringArrayList.EMPTY;

      private void ensureMetricsIsMutable() {
        if (!((bitField0_ & 0x00000001) != 0)) {
          metrics_ = new com.google.protobuf.LazyStringArrayList(metrics_);
          bitField0_ |= 0x00000001;
        }
      }
      /**
       *
       *
       *

       * Names of the metrics to report to this billing destination.
       * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
       *

       *
       * repeated string metrics = 2;
       *
       * @return A list containing the metrics.
       */
      public com.google.protobuf.ProtocolStringList getMetricsList() {
        return metrics_.getUnmodifiableView();
      }
      /**
       *
       *
       *

       * Names of the metrics to report to this billing destination.
       * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
       *

       *
       * repeated string metrics = 2;
       *
       * @return The count of metrics.
       */
      public int getMetricsCount() {
        return metrics_.size();
      }
      /**
       *
       *
       *

       * Names of the metrics to report to this billing destination.
       * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
       *

       *
       * repeated string metrics = 2;
       *
       * @param index The index of the element to return.
       * @return The metrics at the given index.
       */
      public java.lang.String getMetrics(int index) {
        return metrics_.get(index);
      }
      /**
       *
       *
       *

       * Names of the metrics to report to this billing destination.
       * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
       *

       *
       * repeated string metrics = 2;
       *
       * @param index The index of the value to return.
       * @return The bytes of the metrics at the given index.
       */
      public com.google.protobuf.ByteString getMetricsBytes(int index) {
        return metrics_.getByteString(index);
      }
      /**
       *
       *
       *

       * Names of the metrics to report to this billing destination.
       * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
       *

       *
       * repeated string metrics = 2;
       *
       * @param index The index to set the value at.
       * @param value The metrics to set.
       * @return This builder for chaining.
       */
      public Builder setMetrics(int index, java.lang.String value) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureMetricsIsMutable();
        metrics_.set(index, value);
        onChanged();
        return this;
      }
      /**
       *
       *
       *

       * Names of the metrics to report to this billing destination.
       * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
       *

       *
       * repeated string metrics = 2;
       *
       * @param value The metrics to add.
       * @return This builder for chaining.
       */
      public Builder addMetrics(java.lang.String value) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureMetricsIsMutable();
        metrics_.add(value);
        onChanged();
        return this;
      }
      /**
       *
       *
       *

       * Names of the metrics to report to this billing destination.
       * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
       *

       *
       * repeated string metrics = 2;
       *
       * @param values The metrics to add.
       * @return This builder for chaining.
       */
      public Builder addAllMetrics(java.lang.Iterable<java.lang.String> values) {
        ensureMetricsIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(values, metrics_);
        onChanged();
        return this;
      }
      /**
       *
       *
       *

       * Names of the metrics to report to this billing destination.
       * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
       *

       *
       * repeated string metrics = 2;
       *
       * @return This builder for chaining.
       */
      public Builder clearMetrics() {
        metrics_ = com.google.protobuf.LazyStringArrayList.EMPTY;
        bitField0_ = (bitField0_ & ~0x00000001);
        onChanged();
        return this;
      }
      /**
       *
       *
       *

       * Names of the metrics to report to this billing destination.
       * Each name must be defined in [Service.metrics][google.api.Service.metrics] section.
       *

       *
       * repeated string metrics = 2;
       *
       * @param value The bytes of the metrics to add.
       * @return This builder for chaining.
       */
      public Builder addMetricsBytes(com.google.protobuf.ByteString value) {
        if (value == null) {
          throw new NullPointerException();
        }
        checkByteStringIsUtf8(value);
        ensureMetricsIsMutable();
        metrics_.add(value);
        onChanged();
        return this;
      }

      @java.lang.Override
      public final Builder setUnknownFields(
          final com.google.protobuf.UnknownFieldSet unknownFields) {
        return super.setUnknownFields(unknownFields);
      }

      @java.lang.Override
      public final Builder mergeUnknownFields(
          final com.google.protobuf.UnknownFieldSet unknownFields) {
        return super.mergeUnknownFields(unknownFields);
      }

      // @@protoc_insertion_point(builder_scope:google.api.Billing.BillingDestination)
    }

    // @@protoc_insertion_point(class_scope:google.api.Billing.BillingDestination)
    private static final com.google.api.Billing.BillingDestination DEFAULT_INSTANCE;

    static {
      DEFAULT_INSTANCE = new com.google.api.Billing.BillingDestination();
    }

    public static com.google.api.Billing.BillingDestination getDefaultInstance() {
      return DEFAULT_INSTANCE;
    }

    private static final com.google.protobuf.Parser<BillingDestination> PARSER =
        new com.google.protobuf.AbstractParser<BillingDestination>() {
          @java.lang.Override
          public BillingDestination parsePartialFrom(
              com.google.protobuf.CodedInputStream input,
              com.google.protobuf.ExtensionRegistryLite extensionRegistry)
              throws com.google.protobuf.InvalidProtocolBufferException {
            Builder builder = newBuilder();
            try {
              builder.mergeFrom(input, extensionRegistry);
            } catch (com.google.protobuf.InvalidProtocolBufferException e) {
              throw e.setUnfinishedMessage(builder.buildPartial());
            } catch (com.google.protobuf.UninitializedMessageException e) {
              throw e.asInvalidProtocolBufferException()
                  .setUnfinishedMessage(builder.buildPartial());
            } catch (java.io.IOException e) {
              throw new com.google.protobuf.InvalidProtocolBufferException(e)
                  .setUnfinishedMessage(builder.buildPartial());
            }
            return builder.buildPartial();
          }
        };

    public static com.google.protobuf.Parser<BillingDestination> parser() {
      return PARSER;
    }

    @java.lang.Override
    public com.google.protobuf.Parser<BillingDestination> getParserForType() {
      return PARSER;
    }

    @java.lang.Override
    public com.google.api.Billing.BillingDestination getDefaultInstanceForType() {
      return DEFAULT_INSTANCE;
    }
  }

  public static final int CONSUMER_DESTINATIONS_FIELD_NUMBER = 8;
  private java.util.List<com.google.api.Billing.BillingDestination> consumerDestinations_;
  /**
   *
   *
   *

   * Billing configurations for sending metrics to the consumer project.
   * There can be multiple consumer destinations per service, each one must have
   * a different monitored resource type. A metric can be used in at most
   * one consumer destination.
   *

   *
   * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
   */
  @java.lang.Override
  public java.util.List<com.google.api.Billing.BillingDestination> getConsumerDestinationsList() {
    return consumerDestinations_;
  }
  /**
   *
   *
   *

   * Billing configurations for sending metrics to the consumer project.
   * There can be multiple consumer destinations per service, each one must have
   * a different monitored resource type. A metric can be used in at most
   * one consumer destination.
   *

   *
   * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
   */
  @java.lang.Override
  public java.util.List<? extends com.google.api.Billing.BillingDestinationOrBuilder>
      getConsumerDestinationsOrBuilderList() {
    return consumerDestinations_;
  }
  /**
   *
   *
   *

   * Billing configurations for sending metrics to the consumer project.
   * There can be multiple consumer destinations per service, each one must have
   * a different monitored resource type. A metric can be used in at most
   * one consumer destination.
   *

   *
   * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
   */
  @java.lang.Override
  public int getConsumerDestinationsCount() {
    return consumerDestinations_.size();
  }
  /**
   *
   *
   *

   * Billing configurations for sending metrics to the consumer project.
   * There can be multiple consumer destinations per service, each one must have
   * a different monitored resource type. A metric can be used in at most
   * one consumer destination.
   *

   *
   * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
   */
  @java.lang.Override
  public com.google.api.Billing.BillingDestination getConsumerDestinations(int index) {
    return consumerDestinations_.get(index);
  }
  /**
   *
   *
   *

   * Billing configurations for sending metrics to the consumer project.
   * There can be multiple consumer destinations per service, each one must have
   * a different monitored resource type. A metric can be used in at most
   * one consumer destination.
   *

   *
   * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
   */
  @java.lang.Override
  public com.google.api.Billing.BillingDestinationOrBuilder getConsumerDestinationsOrBuilder(
      int index) {
    return consumerDestinations_.get(index);
  }

  private byte memoizedIsInitialized = -1;

  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
    for (int i = 0; i < consumerDestinations_.size(); i++) {
      output.writeMessage(8, consumerDestinations_.get(i));
    }
    getUnknownFields().writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    for (int i = 0; i < consumerDestinations_.size(); i++) {
      size +=
          com.google.protobuf.CodedOutputStream.computeMessageSize(8, consumerDestinations_.get(i));
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof com.google.api.Billing)) {
      return super.equals(obj);
    }
    com.google.api.Billing other = (com.google.api.Billing) obj;

    if (!getConsumerDestinationsList().equals(other.getConsumerDestinationsList())) return false;
    if (!getUnknownFields().equals(other.getUnknownFields())) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    if (getConsumerDestinationsCount() > 0) {
      hash = (37 * hash) + CONSUMER_DESTINATIONS_FIELD_NUMBER;
      hash = (53 * hash) + getConsumerDestinationsList().hashCode();
    }
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.api.Billing parseFrom(java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.api.Billing parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.api.Billing parseFrom(com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.api.Billing parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.api.Billing parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.api.Billing parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.api.Billing parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.api.Billing parseFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.api.Billing parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.api.Billing parseDelimitedFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.api.Billing parseFrom(com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.api.Billing parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() {
    return newBuilder();
  }

  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }

  public static Builder newBuilder(com.google.api.Billing prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }

  @java.lang.Override
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   *
   *
   *

   * Billing related configuration of the service.
   * The following example shows how to configure monitored resources and metrics
   * for billing, `consumer_destinations` is the only supported destination and
   * the monitored resources need at least one label key
   * `cloud.googleapis.com/location` to indicate the location of the billing
   * usage, using different monitored resources between monitoring and billing is
   * recommended so they can be evolved independently:
   *     monitored_resources:
   *     - type: library.googleapis.com/billing_branch
   *       labels:
   *       - key: cloud.googleapis.com/location
   *         description: |
   *           Predefined label to support billing location restriction.
   *       - key: city
   *         description: |
   *           Custom label to define the city where the library branch is located
   *           in.
   *       - key: name
   *         description: Custom label to define the name of the library branch.
   *     metrics:
   *     - name: library.googleapis.com/book/borrowed_count
   *       metric_kind: DELTA
   *       value_type: INT64
   *       unit: "1"
   *     billing:
   *       consumer_destinations:
   *       - monitored_resource: library.googleapis.com/billing_branch
   *         metrics:
   *         - library.googleapis.com/book/borrowed_count
   *

   *
   * Protobuf type {@code google.api.Billing}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.api.Billing)
      com.google.api.BillingOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.api.BillingProto.internal_static_google_api_Billing_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.api.BillingProto.internal_static_google_api_Billing_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.api.Billing.class, com.google.api.Billing.Builder.class);
    }

    // Construct using com.google.api.Billing.newBuilder()
    private Builder() {}

    private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      if (consumerDestinationsBuilder_ == null) {
        consumerDestinations_ = java.util.Collections.emptyList();
      } else {
        consumerDestinations_ = null;
        consumerDestinationsBuilder_.clear();
      }
      bitField0_ = (bitField0_ & ~0x00000001);
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.api.BillingProto.internal_static_google_api_Billing_descriptor;
    }

    @java.lang.Override
    public com.google.api.Billing getDefaultInstanceForType() {
      return com.google.api.Billing.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.api.Billing build() {
      com.google.api.Billing result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.api.Billing buildPartial() {
      com.google.api.Billing result = new com.google.api.Billing(this);
      int from_bitField0_ = bitField0_;
      if (consumerDestinationsBuilder_ == null) {
        if (((bitField0_ & 0x00000001) != 0)) {
          consumerDestinations_ = java.util.Collections.unmodifiableList(consumerDestinations_);
          bitField0_ = (bitField0_ & ~0x00000001);
        }
        result.consumerDestinations_ = consumerDestinations_;
      } else {
        result.consumerDestinations_ = consumerDestinationsBuilder_.build();
      }
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }

    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.setField(field, value);
    }

    @java.lang.Override
    public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }

    @java.lang.Override
    public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }

    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }

    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.api.Billing) {
        return mergeFrom((com.google.api.Billing) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.api.Billing other) {
      if (other == com.google.api.Billing.getDefaultInstance()) return this;
      if (consumerDestinationsBuilder_ == null) {
        if (!other.consumerDestinations_.isEmpty()) {
          if (consumerDestinations_.isEmpty()) {
            consumerDestinations_ = other.consumerDestinations_;
            bitField0_ = (bitField0_ & ~0x00000001);
          } else {
            ensureConsumerDestinationsIsMutable();
            consumerDestinations_.addAll(other.consumerDestinations_);
          }
          onChanged();
        }
      } else {
        if (!other.consumerDestinations_.isEmpty()) {
          if (consumerDestinationsBuilder_.isEmpty()) {
            consumerDestinationsBuilder_.dispose();
            consumerDestinationsBuilder_ = null;
            consumerDestinations_ = other.consumerDestinations_;
            bitField0_ = (bitField0_ & ~0x00000001);
            consumerDestinationsBuilder_ =
                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders
                    ? getConsumerDestinationsFieldBuilder()
                    : null;
          } else {
            consumerDestinationsBuilder_.addAllMessages(other.consumerDestinations_);
          }
        }
      }
      this.mergeUnknownFields(other.getUnknownFields());
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      if (extensionRegistry == null) {
        throw new java.lang.NullPointerException();
      }
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            case 66:
              {
                com.google.api.Billing.BillingDestination m =
                    input.readMessage(
                        com.google.api.Billing.BillingDestination.parser(), extensionRegistry);
                if (consumerDestinationsBuilder_ == null) {
                  ensureConsumerDestinationsIsMutable();
                  consumerDestinations_.add(m);
                } else {
                  consumerDestinationsBuilder_.addMessage(m);
                }
                break;
              } // case 66
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private int bitField0_;

    private java.util.List<com.google.api.Billing.BillingDestination> consumerDestinations_ =
        java.util.Collections.emptyList();

    private void ensureConsumerDestinationsIsMutable() {
      if (!((bitField0_ & 0x00000001) != 0)) {
        consumerDestinations_ =
            new java.util.ArrayList<com.google.api.Billing.BillingDestination>(
                consumerDestinations_);
        bitField0_ |= 0x00000001;
      }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.api.Billing.BillingDestination,
            com.google.api.Billing.BillingDestination.Builder,
            com.google.api.Billing.BillingDestinationOrBuilder>
        consumerDestinationsBuilder_;

    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public java.util.List<com.google.api.Billing.BillingDestination> getConsumerDestinationsList() {
      if (consumerDestinationsBuilder_ == null) {
        return java.util.Collections.unmodifiableList(consumerDestinations_);
      } else {
        return consumerDestinationsBuilder_.getMessageList();
      }
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public int getConsumerDestinationsCount() {
      if (consumerDestinationsBuilder_ == null) {
        return consumerDestinations_.size();
      } else {
        return consumerDestinationsBuilder_.getCount();
      }
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public com.google.api.Billing.BillingDestination getConsumerDestinations(int index) {
      if (consumerDestinationsBuilder_ == null) {
        return consumerDestinations_.get(index);
      } else {
        return consumerDestinationsBuilder_.getMessage(index);
      }
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public Builder setConsumerDestinations(
        int index, com.google.api.Billing.BillingDestination value) {
      if (consumerDestinationsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureConsumerDestinationsIsMutable();
        consumerDestinations_.set(index, value);
        onChanged();
      } else {
        consumerDestinationsBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public Builder setConsumerDestinations(
        int index, com.google.api.Billing.BillingDestination.Builder builderForValue) {
      if (consumerDestinationsBuilder_ == null) {
        ensureConsumerDestinationsIsMutable();
        consumerDestinations_.set(index, builderForValue.build());
        onChanged();
      } else {
        consumerDestinationsBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public Builder addConsumerDestinations(com.google.api.Billing.BillingDestination value) {
      if (consumerDestinationsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureConsumerDestinationsIsMutable();
        consumerDestinations_.add(value);
        onChanged();
      } else {
        consumerDestinationsBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public Builder addConsumerDestinations(
        int index, com.google.api.Billing.BillingDestination value) {
      if (consumerDestinationsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureConsumerDestinationsIsMutable();
        consumerDestinations_.add(index, value);
        onChanged();
      } else {
        consumerDestinationsBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public Builder addConsumerDestinations(
        com.google.api.Billing.BillingDestination.Builder builderForValue) {
      if (consumerDestinationsBuilder_ == null) {
        ensureConsumerDestinationsIsMutable();
        consumerDestinations_.add(builderForValue.build());
        onChanged();
      } else {
        consumerDestinationsBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public Builder addConsumerDestinations(
        int index, com.google.api.Billing.BillingDestination.Builder builderForValue) {
      if (consumerDestinationsBuilder_ == null) {
        ensureConsumerDestinationsIsMutable();
        consumerDestinations_.add(index, builderForValue.build());
        onChanged();
      } else {
        consumerDestinationsBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public Builder addAllConsumerDestinations(
        java.lang.Iterable<? extends com.google.api.Billing.BillingDestination> values) {
      if (consumerDestinationsBuilder_ == null) {
        ensureConsumerDestinationsIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(values, consumerDestinations_);
        onChanged();
      } else {
        consumerDestinationsBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public Builder clearConsumerDestinations() {
      if (consumerDestinationsBuilder_ == null) {
        consumerDestinations_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
        onChanged();
      } else {
        consumerDestinationsBuilder_.clear();
      }
      return this;
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public Builder removeConsumerDestinations(int index) {
      if (consumerDestinationsBuilder_ == null) {
        ensureConsumerDestinationsIsMutable();
        consumerDestinations_.remove(index);
        onChanged();
      } else {
        consumerDestinationsBuilder_.remove(index);
      }
      return this;
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public com.google.api.Billing.BillingDestination.Builder getConsumerDestinationsBuilder(
        int index) {
      return getConsumerDestinationsFieldBuilder().getBuilder(index);
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public com.google.api.Billing.BillingDestinationOrBuilder getConsumerDestinationsOrBuilder(
        int index) {
      if (consumerDestinationsBuilder_ == null) {
        return consumerDestinations_.get(index);
      } else {
        return consumerDestinationsBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public java.util.List<? extends com.google.api.Billing.BillingDestinationOrBuilder>
        getConsumerDestinationsOrBuilderList() {
      if (consumerDestinationsBuilder_ != null) {
        return consumerDestinationsBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(consumerDestinations_);
      }
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public com.google.api.Billing.BillingDestination.Builder addConsumerDestinationsBuilder() {
      return getConsumerDestinationsFieldBuilder()
          .addBuilder(com.google.api.Billing.BillingDestination.getDefaultInstance());
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public com.google.api.Billing.BillingDestination.Builder addConsumerDestinationsBuilder(
        int index) {
      return getConsumerDestinationsFieldBuilder()
          .addBuilder(index, com.google.api.Billing.BillingDestination.getDefaultInstance());
    }
    /**
     *
     *
     *

     * Billing configurations for sending metrics to the consumer project.
     * There can be multiple consumer destinations per service, each one must have
     * a different monitored resource type. A metric can be used in at most
     * one consumer destination.
     *

     *
     * repeated .google.api.Billing.BillingDestination consumer_destinations = 8;
     */
    public java.util.List<com.google.api.Billing.BillingDestination.Builder>
        getConsumerDestinationsBuilderList() {
      return getConsumerDestinationsFieldBuilder().getBuilderList();
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.api.Billing.BillingDestination,
            com.google.api.Billing.BillingDestination.Builder,
            com.google.api.Billing.BillingDestinationOrBuilder>
        getConsumerDestinationsFieldBuilder() {
      if (consumerDestinationsBuilder_ == null) {
        consumerDestinationsBuilder_ =
            new com.google.protobuf.RepeatedFieldBuilderV3<
                com.google.api.Billing.BillingDestination,
                com.google.api.Billing.BillingDestination.Builder,
                com.google.api.Billing.BillingDestinationOrBuilder>(
                consumerDestinations_,
                ((bitField0_ & 0x00000001) != 0),
                getParentForChildren(),
                isClean());
        consumerDestinations_ = null;
      }
      return consumerDestinationsBuilder_;
    }

    @java.lang.Override
    public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

    @java.lang.Override
    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }

    // @@protoc_insertion_point(builder_scope:google.api.Billing)
  }

  // @@protoc_insertion_point(class_scope:google.api.Billing)
  private static final com.google.api.Billing DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.api.Billing();
  }

  public static com.google.api.Billing getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<Billing> PARSER =
      new com.google.protobuf.AbstractParser<Billing>() {
        @java.lang.Override
        public Billing parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          Builder builder = newBuilder();
          try {
            builder.mergeFrom(input, extensionRegistry);
          } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(builder.buildPartial());
          } catch (com.google.protobuf.UninitializedMessageException e) {
            throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
          } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(e)
                .setUnfinishedMessage(builder.buildPartial());
          }
          return builder.buildPartial();
        }
      };

  public static com.google.protobuf.Parser<Billing> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<Billing> getParserForType() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.api.Billing getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}


text:
//
//  InterruptVector.h
//  BakingPi
//
//  Created by Jeremy Pereira on 29/11/2012.
//  Copyright (c) 2012 Jeremy Pereira. All rights reserved.
//

#ifndef BakingPi_InterruptVector_h
#define BakingPi_InterruptVector_h

#include "bptypes.h"

enum IVType
{
    IV_RESET 					= 0,
    IV_UNDEFINED_INSTRUCTION	= 1,
    IV_SOFTWARE					= 2,
    IV_INSTRUCTION_ABORT		= 3,
    IV_DATA_ABORT				= 4,
    IV_IRQ						= 6,
    IV_FAST_IRQ					= 7,
    IV_NUM_VECTORS
};

typedef uint32_t InterruptVector;

struct InterruptVectorTable;
typedef struct InterruptVectorTable InterruptVectorTable;

/*!
 *  @brief Initialise the interrup vector table
 */
void iv_initialise(void);

#endif

redpajama_set_name: RedPajamaGithub


text:
void Deviation  PROTO((void));
void Identorder PROTO((int));


text:
print ("Example: Load a STEP file, generated by a CAD.");
print ("Please wait! this may take a while to load the file...");

import pychrono.core as chrono
import pychrono.irrlicht as chronoirr
import pychrono.cascade as cascade
from OCC.Core import TopoDS

# The path to the Chrono data directory containing various assets (meshes, textures, data files)
# is automatically set, relative to the default location of this demo.
# If running from a different directory, you must change the path to the data directory with:
#chrono.SetChronoDataPath('path/to/data')

# ---------------------------------------------------------------------
#
#  Create the simulation system and add items
#

mysystem      = chrono.ChSystemNSC()

# Load a STEP file, containing a mechanism. The demo STEP file has been
# created using a 3D CAD (in this case, SolidEdge v.18).
#

# Create the ChCascadeDoc, a container that loads the STEP model
# and manages its subassembles
mydoc = cascade.ChCascadeDoc()

# load the STEP model using this command:
load_ok = mydoc.Load_STEP(chrono.GetChronoDataFile('cascade/IRB7600_23_500_m2000_rev1_01_decorated.stp'))  # or specify abs.path: ("C:\\data\\cascade\\assembly.stp");

if not load_ok:
    raise ValueError("Warning. Desired STEP file could not be opened/parsed \n")

CH_C_PI = 3.1456

# In most CADs the Y axis is horizontal, but we want it vertical.
# So define a root transformation for rotating all the imported objects.
rotation1 = chrono.ChQuaternionD()
rotation1.Q_from_AngAxis(-CH_C_PI / 2, chrono.ChVectorD(1, 0, 0))  # 1: rotate 90° on X axis
rotation2 = chrono.ChQuaternionD()
rotation2.Q_from_AngAxis(CH_C_PI, chrono.ChVectorD(0, 1, 0))  # 2: rotate 180° on vertical Y axis
tot_rotation = chrono.ChQuaternionD()
tot_rotation = rotation2 % rotation1     # rotate on 1 then on 2, using quaternion product
root_frame = chrono.ChFrameMovingD(chrono.ChVectorD(0, 0, 0), tot_rotation)

# Retrieve some sub shapes from the loaded model, using
# the GetNamedShape() function, that can use path/subpath/subsubpath/part
# syntax and * or ? wildcards, etc.

def make_body_from_name(partname, root_transformation):
    shape1 = TopoDS.TopoDS_Shape()
    if (mydoc.GetNamedShape(shape1, partname)):
        # Make a ChBody representing the TopoDS_Shape part from the CAD:
        mbody1 = cascade.ChBodyEasyCascade(shape1, # shape
                                           1000,   # density (center of mass & inertia automatically computed)
                                           True,    # mesh for visualization?
                                           False)   # mesh for collision?
        mysystem.Add(mbody1)
        # Move the body as for global displacement/rotation (also mbody1 %= root_frame; )
        mbody1.ConcatenatePreTransformation(root_transformation)
        return mbody1
    else:
        raise ValueError("Warning. Body part name cannot be found in STEP file.\n")

mrigidBody_base     = make_body_from_name("Assem10/Assem8", root_frame)
mrigidBody_turret   = make_body_from_name("Assem10/Assem4", root_frame)
mrigidBody_bicep    = make_body_from_name("Assem10/Assem1", root_frame)
mrigidBody_elbow    = make_body_from_name("Assem10/Assem5", root_frame)
mrigidBody_forearm  = make_body_from_name("Assem10/Assem7", root_frame)
mrigidBody_wrist    = make_body_from_name("Assem10/Assem6", root_frame)
mrigidBody_hand     = make_body_from_name("Assem10/Assem9", root_frame)
mrigidBody_cylinder = make_body_from_name("Assem10/Assem3", root_frame)
mrigidBody_rod      = make_body_from_name("Assem10/Assem2", root_frame)

mrigidBody_base.SetBodyFixed(True)
#mrigidBody_hand.SetBodyFixed(True)

# Create joints between two parts.
# To understand where is the axis of the joint, we can exploit the fact
# that in the STEP file that we prepared for this demo, we inserted some
# objects called 'marker' and we placed them aligned to the shafts, so now
# we can fetch them and get their position/rotation.

def make_frame_from_name(partname, root_transformation):
    shape_marker = TopoDS.TopoDS_Shape()
    if (mydoc.GetNamedShape(shape_marker, partname)):
        frame_marker = chrono.ChFrameD()
        mydoc.FromCascadeToChrono(shape_marker.Location(), frame_marker)
        frame_marker.ConcatenatePreTransformation(root_transformation)
        return frame_marker
    else:
        raise ValueError("Warning. Marker part name cannot be found in STEP file.\n")

frame_marker_base_turret    = make_frame_from_name("Assem10/Assem8/marker#1", root_frame)
frame_marker_turret_bicep   = make_frame_from_name("Assem10/Assem4/marker#2", root_frame)
frame_marker_bicep_elbow    = make_frame_from_name("Assem10/Assem1/marker#2", root_frame)
frame_marker_elbow_forearm  = make_frame_from_name("Assem10/Assem5/marker#2", root_frame)
frame_marker_forearm_wrist  = make_frame_from_name("Assem10/Assem7/marker#2", root_frame)
frame_marker_wrist_hand     = make_frame_from_name("Assem10/Assem6/marker#2", root_frame)
frame_marker_turret_cylinder= make_frame_from_name("Assem10/Assem4/marker#3", root_frame)
frame_marker_cylinder_rod   = make_frame_from_name("Assem10/Assem3/marker#2", root_frame)
frame_marker_rod_bicep      = make_frame_from_name("Assem10/Assem2/marker#2", root_frame)

# Create joints between the parts.
# This can be done by creating link objects between couples of the bodies
# created in the section above, where the joint position is one of the
# frame_marker_xxxx_zzzz frames created above.

my_link1 = chrono.ChLinkLockRevolute()
my_link1.Initialize(mrigidBody_base, mrigidBody_turret, frame_marker_base_turret.GetCoord())
mysystem.Add(my_link1)

my_link2 = chrono.ChLinkLockRevolute()
my_link2.Initialize(mrigidBody_turret, mrigidBody_bicep, frame_marker_turret_bicep.GetCoord())
mysystem.Add(my_link2)

my_link3 = chrono.ChLinkLockRevolute()
my_link3.Initialize(mrigidBody_bicep, mrigidBody_elbow, frame_marker_bicep_elbow.GetCoord())
mysystem.Add(my_link3)

my_link4 = chrono.ChLinkLockRevolute()
my_link4.Initialize(mrigidBody_elbow, mrigidBody_forearm, frame_marker_elbow_forearm.GetCoord())
mysystem.Add(my_link4)

my_link5 = chrono.ChLinkLockRevolute()
my_link5.Initialize(mrigidBody_forearm, mrigidBody_wrist, frame_marker_forearm_wrist.GetCoord())
mysystem.Add(my_link5)

my_link6 = chrono.ChLinkLockRevolute()
my_link6.Initialize(mrigidBody_wrist, mrigidBody_hand, frame_marker_wrist_hand.GetCoord())
mysystem.Add(my_link6)

my_link7 = chrono.ChLinkLockRevolute()
my_link7.Initialize(mrigidBody_turret, mrigidBody_cylinder, frame_marker_turret_cylinder.GetCoord())
mysystem.Add(my_link7)

my_link8 = chrono.ChLinkLockRevolute()
my_link8.Initialize(mrigidBody_cylinder, mrigidBody_rod, frame_marker_cylinder_rod.GetCoord())
mysystem.Add(my_link8)

my_link9 = chrono.ChLinkLockRevolute()
my_link9.Initialize(mrigidBody_rod, mrigidBody_bicep, frame_marker_rod_bicep.GetCoord())
mysystem.Add(my_link9)

# Create a large cube as a floor.

mfloor = chrono.ChBodyEasyBox(5, 1, 5, 1000, True, True)
mfloor.SetPos(chrono.ChVectorD(0,-0.5,0))
mfloor.SetBodyFixed(True)
mysystem.Add(mfloor)

mcolor = chrono.ChColorAsset(0.3, 0.3, 0.8)
mfloor.AddAsset(mcolor)

# We want to move the hand of the robot using a trajectory.
# Since in this demo all joints are 'off' (i.e just revolute joints),
# it follows that if we move the hand all the robot will automatically
# move as in inverse kinematics.

# Create a ChLinePath geometry, for the hand path, and insert arc/lines sub-paths:
mpath = chrono.ChLinePath()
ma1 = chrono.ChLineArc(
            chrono.ChCoordsysD(mrigidBody_hand.GetPos(), # arc center position
                               chrono.Q_ROTATE_X_TO_Z),   # arc plane alignment (default: xy plane)
            0.3, # radius
            -chrono.CH_C_PI_2, # start arc ngle (counterclockwise, from local x)
            -chrono.CH_C_PI_2+chrono.CH_C_2PI, # end arc angle
            True)
mpath.AddSubLine(ma1)
mpath.SetPathDuration(2)
mpath.Set_closed(True)

# Create a ChLineShape, a visualization asset for lines.
mpathasset = chrono.ChLineShape()
mpathasset.SetLineGeometry(mpath)
mfloor.AddAsset(mpathasset)

# This is the constraint that uses the trajectory
mtrajectory = chrono.ChLinkTrajectory()
# Define which parts are connected (the trajectory is considered in the 2nd body).
mtrajectory.Initialize(mrigidBody_hand, # body1 that follows the trajectory
          mfloor,                 # body2 that 'owns' the trajectory
          chrono.VNULL,           # point on body1 that will follow the trajectory, in body1 coords
          mpath                   # the trajectory (reuse the one already added to body2 as asset)
          )
mysystem.Add(mtrajectory)
# Optionally, set a function that gets the curvilinear
# abscyssa s of the line, as a function of time s(t).
# By default it was simply  s=t.
mspacefx = chrono.ChFunction_Ramp(0, 0.5)
mtrajectory.Set_space_fx(mspacefx)

# Just to constraint the hand rotation:
mparallelism = chrono.ChLinkLockParallel()
mparallelism.Initialize(mrigidBody_hand, mfloor, frame_marker_wrist_hand.GetCoord())
mysystem.Add(mparallelism);

# ---------------------------------------------------------------------
#
#  Create an Irrlicht application to visualize the system
#

myapplication = chronoirr.ChIrrApp(mysystem, 'Import STEP', chronoirr.dimension2du(1024,768))

myapplication.AddTypicalSky()
myapplication.AddTypicalLogo(chrono.GetChronoDataFile('logo_pychrono_alpha.png'))
myapplication.AddTypicalCamera(chronoirr.vector3df(2,2,2),chronoirr.vector3df(0,0.8,0))
#myapplication.AddTypicalLights()
myapplication.AddLightWithShadow(chronoirr.vector3df(3,6,2),    # point
                                 chronoirr.vector3df(0,0,0),    # aimpoint
                                 12,                 # radius (power)
                                 1,11,              # near, far
                                 55)                # angle of FOV

            # ==IMPORTANT!== Use this function for adding a ChIrrNodeAsset to all items
			# in the system. These ChIrrNodeAsset assets are 'proxies' to the Irrlicht meshes.
			# If you need a finer control on which item really needs a visualization proxy in
			# Irrlicht, just use application.AssetBind(myitem); on a per-item basis.

myapplication.AssetBindAll();

			# ==IMPORTANT!== Use this function for 'converting' into Irrlicht meshes the assets
			# that you added to the bodies into 3D shapes, they can be visualized by Irrlicht!

myapplication.AssetUpdateAll();

            # If you want to show shadows because you used "AddLightWithShadow()'
            # you must remember this:
myapplication.AddShadowAll();

# ---------------------------------------------------------------------
#
#  Run the simulation
#

# Change the solver form the default SOR to a more precise solver

#msolver = mkl.ChSolverMKLcsm()
#mysystem.SetSolver(msolver)

mysystem.SetSolverType(chrono.ChSolver.Type_BARZILAIBORWEIN);
#mysystem.SetSolverType(chrono.ChSolver.Type_MINRES);
mysystem.SetSolverMaxIterations(300)

myapplication.SetTimestep(0.01)

while(myapplication.GetDevice().run()):
    myapplication.BeginScene()
    myapplication.DrawAll()
    myapplication.DoStep()
    myapplication.EndScene()


text:
from mako.template import Template
import unittest
import os
from mako.compat import py3k, py26, py25
from mako.util import function_named
import re
from mako.cache import CacheImpl, register_plugin
from nose import SkipTest
import sys

template_base = os.path.join(os.path.dirname(__file__), 'templates')
module_base = os.path.join(template_base, 'modules')

class TemplateTest(unittest.TestCase):

    def _file_template(self, filename, **kw):
        filepath = self._file_path(filename)
        return Template(uri=filename, filename=filepath,
                            module_directory=module_base, **kw)

    def _file_path(self, filename):
        name, ext = os.path.splitext(filename)

        if py3k:
            py3k_path = os.path.join(template_base, name + "_py3k" + ext)
            if os.path.exists(py3k_path):
                return py3k_path

        return os.path.join(template_base, filename)

    def _do_file_test(self, filename, expected, filters=None,
                        unicode_=True, template_args=None, **kw):
        t1 = self._file_template(filename, **kw)
        self._do_test(t1, expected, filters=filters,
                        unicode_=unicode_, template_args=template_args)

    def _do_memory_test(self, source, expected, filters=None,
                        unicode_=True, template_args=None, **kw):
        t1 = Template(text=source, **kw)
        self._do_test(t1, expected, filters=filters,
                        unicode_=unicode_, template_args=template_args)

    def _do_test(self, template, expected, filters=None, template_args=None,
                                unicode_=True):
        if template_args is None:
            template_args = {}
        if unicode_:
            output = template.render_unicode(**template_args)
        else:
            output = template.render(**template_args)

        if filters:
            output = filters(output)
        eq_(output, expected)

def eq_(a, b, msg=None):
    """Assert a == b, with repr messaging on failure."""
    assert a == b, msg or "%r != %r" % (a, b)

def teardown():
    import shutil
    shutil.rmtree(module_base, True)

def assert_raises(except_cls, callable_, *args, **kw):
    try:
        callable_(*args, **kw)
        success = False
    except except_cls:
        success = True

    # assert outside the block so it works for AssertionError too !
    assert success, "Callable did not raise an exception"

def assert_raises_message(except_cls, msg, callable_, *args, **kwargs):
    try:
        callable_(*args, **kwargs)
        assert False, "Callable did not raise an exception"
    except except_cls:
        e = sys.exc_info()[1]
        assert re.search(msg, str(e)), "%r !~ %s" % (msg, e)
        print(str(e))

def skip_if(predicate, reason=None):
    """Skip a test if predicate is true."""
    reason = reason or predicate.__name__

    def decorate(fn):
        fn_name = fn.__name__
        def maybe(*args, **kw):
            if predicate():
                msg = "'%s' skipped: %s" % (
                    fn_name, reason)
                raise SkipTest(msg)
            else:
                return fn(*args, **kw)
        return function_named(maybe, fn_name)
    return decorate

def requires_python_2(fn):
    return skip_if(lambda: py3k, "Requires Python 2.xx")(fn)

def requires_python_26_or_greater(fn):
    return skip_if(lambda: not py26, "Requires Python 2.6 or greater")(fn)

def requires_python_25_or_greater(fn):
    return skip_if(lambda: not py25, "Requires Python 2.5 or greater")(fn)

def requires_pygments_14(fn):
    try:
        import pygments
        version = pygments.__version__
    except:
        version = "0"
    return skip_if(lambda: version < "1.4")(fn)

def requires_no_pygments_exceptions(fn):
    def go(*arg, **kw):
        from mako import exceptions
        exceptions._install_fallback()
        try:
            return fn(*arg, **kw)
        finally:
            exceptions._install_highlighting()
    return function_named(go, fn.__name__)

class PlainCacheImpl(CacheImpl):
    """Simple memory cache impl so that tests which
    use caching can run without beaker.  """

    def __init__(self, cache):
        self.cache = cache
        self.data = {}

    def get_or_create(self, key, creation_function, **kw):
        if key in self.data:
            return self.data[key]
        else:
            self.data[key] = data = creation_function(**kw)
            return data

    def put(self, key, value, **kw):
        self.data[key] = value

    def get(self, key, **kw):
        return self.data[key]

    def invalidate(self, key, **kw):
        del self.data[key]

register_plugin("plain", __name__, "PlainCacheImpl")