...

Source file src/go.einride.tech/aip/proto/gen/einride/example/freight/v1/shipment_aip.go

Documentation: go.einride.tech/aip/proto/gen/einride/example/freight/v1

     1  // Code generated by protoc-gen-go-aip. DO NOT EDIT.
     2  //
     3  // versions:
     4  // 	protoc-gen-go-aip development
     5  // 	protoc (unknown)
     6  // source: einride/example/freight/v1/shipment.proto
     7  
     8  package freightv1
     9  
    10  import (
    11  	fmt "fmt"
    12  	resourcename "go.einride.tech/aip/resourcename"
    13  	strings "strings"
    14  )
    15  
    16  type ShipmentResourceName struct {
    17  	Shipper  string
    18  	Shipment string
    19  }
    20  
    21  func (n ShipperResourceName) ShipmentResourceName(
    22  	shipment string,
    23  ) ShipmentResourceName {
    24  	return ShipmentResourceName{
    25  		Shipper:  n.Shipper,
    26  		Shipment: shipment,
    27  	}
    28  }
    29  
    30  func (n ShipmentResourceName) Validate() error {
    31  	if n.Shipper == "" {
    32  		return fmt.Errorf("shipper: empty")
    33  	}
    34  	if strings.IndexByte(n.Shipper, '/') != -1 {
    35  		return fmt.Errorf("shipper: contains illegal character '/'")
    36  	}
    37  	if n.Shipment == "" {
    38  		return fmt.Errorf("shipment: empty")
    39  	}
    40  	if strings.IndexByte(n.Shipment, '/') != -1 {
    41  		return fmt.Errorf("shipment: contains illegal character '/'")
    42  	}
    43  	return nil
    44  }
    45  
    46  func (n ShipmentResourceName) ContainsWildcard() bool {
    47  	return false || n.Shipper == "-" || n.Shipment == "-"
    48  }
    49  
    50  func (n ShipmentResourceName) String() string {
    51  	return resourcename.Sprint(
    52  		"shippers/{shipper}/shipments/{shipment}",
    53  		n.Shipper,
    54  		n.Shipment,
    55  	)
    56  }
    57  
    58  func (n ShipmentResourceName) MarshalString() (string, error) {
    59  	if err := n.Validate(); err != nil {
    60  		return "", err
    61  	}
    62  	return n.String(), nil
    63  }
    64  
    65  func (n *ShipmentResourceName) UnmarshalString(name string) error {
    66  	err := resourcename.Sscan(
    67  		name,
    68  		"shippers/{shipper}/shipments/{shipment}",
    69  		&n.Shipper,
    70  		&n.Shipment,
    71  	)
    72  	if err != nil {
    73  		return err
    74  	}
    75  	return n.Validate()
    76  }
    77  
    78  func (n ShipmentResourceName) ShipperResourceName() ShipperResourceName {
    79  	return ShipperResourceName{
    80  		Shipper: n.Shipper,
    81  	}
    82  }
    83  

View as plain text