Documentation ¶
Index ¶
- func CalcCheckDigit(ownerCode string, equipCatID rune, serialNum int) int
- func IsEquipCatID(ID string) error
- func IsHeightWidthCode(code string) error
- func IsLengthCode(code string) error
- func IsOwnerCode(code string) error
- func IsTypeCode(code string) error
- func NewValidateError(message string) error
- type EquipCat
- type EquipCatID
- type GeneratorBuilder
- func (gb *GeneratorBuilder) Build() (*UniqueGenerator, error)
- func (gb *GeneratorBuilder) Count(count int) *GeneratorBuilder
- func (gb *GeneratorBuilder) End(end int) *GeneratorBuilder
- func (gb *GeneratorBuilder) ExcludeCheckDigit10(exclude bool) *GeneratorBuilder
- func (gb *GeneratorBuilder) ExcludeErrorProneSerialNumbers(exclude bool) *GeneratorBuilder
- func (gb *GeneratorBuilder) OwnerCodes(codes []string) *GeneratorBuilder
- func (gb *GeneratorBuilder) Start(start int) *GeneratorBuilder
- type GroupInfo
- type Height
- type Length
- type Number
- type Owner
- type TpNumber
- type TypeInfo
- type UniqueGenerator
- type ValidateError
- type Width
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcCheckDigit ¶
CalcCheckDigit calculates check digit for owner, equipment category ID and serial number.
func IsEquipCatID ¶
IsEquipCatID checks if string is one upper case letter.
func IsHeightWidthCode ¶
IsHeightWidthCode returns nil if input is one upper case alphanumeric character.
func IsLengthCode ¶
IsLengthCode returns nil if input is one upper case alphanumeric character.
func IsOwnerCode ¶
IsOwnerCode checks if string is three upper case letters.
func IsTypeCode ¶
IsTypeCode returns nil if input is two upper case alphanumeric characters.
func NewValidateError ¶
NewValidateError returns a new ValidateError.
Types ¶
type EquipCat ¶
EquipCat has an ID and additional information for the ID.
func NewEquipCatID ¶
NewEquipCatID creates a new equipment category with an ID and an information.
type EquipCatID ¶
type EquipCatID struct {
Value string
}
EquipCatID is the equipment category ID in a container number.
type GeneratorBuilder ¶
type GeneratorBuilder struct {
// contains filtered or unexported fields
}
GeneratorBuilder is the struct for the builder. Use NewUniqueGeneratorBuilder to create a new one.
func NewUniqueGeneratorBuilder ¶
func NewUniqueGeneratorBuilder(rand *rand.Rand) *GeneratorBuilder
NewUniqueGeneratorBuilder returns a new random unique container number generator. If possible maximum unique container numbers are exceeded, count is less than 1 or no owner codes are passed then nil and error is returned.
func (*GeneratorBuilder) Build ¶
func (gb *GeneratorBuilder) Build() (*UniqueGenerator, error)
Build returns a new UniqueGenerator if all requirements are met.
func (*GeneratorBuilder) Count ¶
func (gb *GeneratorBuilder) Count(count int) *GeneratorBuilder
Count sets the count of container number.
func (*GeneratorBuilder) End ¶
func (gb *GeneratorBuilder) End(end int) *GeneratorBuilder
End sets the end of serial number range.
func (*GeneratorBuilder) ExcludeCheckDigit10 ¶
func (gb *GeneratorBuilder) ExcludeCheckDigit10(exclude bool) *GeneratorBuilder
ExcludeCheckDigit10 sets the exclusion of container numbers with check digit 10.
func (*GeneratorBuilder) ExcludeErrorProneSerialNumbers ¶
func (gb *GeneratorBuilder) ExcludeErrorProneSerialNumbers(exclude bool) *GeneratorBuilder
ExcludeErrorProneSerialNumbers sets the exclusion of container numbers with error-prone serial numbers.
func (*GeneratorBuilder) OwnerCodes ¶
func (gb *GeneratorBuilder) OwnerCodes(codes []string) *GeneratorBuilder
OwnerCodes sets the owner codes for generation.
func (*GeneratorBuilder) Start ¶
func (gb *GeneratorBuilder) Start(start int) *GeneratorBuilder
Start sets the start of serial number range.
type Height ¶
type Height string
Height describes height of first code in the specified standard size code.
type Length ¶
type Length string
Length describes length of second code in the specified standard size code.
type Number ¶
Number is a container number with needed properties to conform to the specified standard.
type Owner ¶
Owner has a code and associated company with its location in the form of country and city.
type TpNumber ¶
type TpNumber struct { Number // Pos is the position of the two transposed numbers starting with 0. // For example Pos 1 means that the second and third digits are transposed. Pos int }
func CheckTransposition ¶
func CheckTransposition(ownerCode string, equipCatID rune, serialNum int, checkDigit int) []TpNumber
CheckTransposition returns an array of TpNumber's for error-prone serial numbers. CheckTransposition returns nil if no error-prone serial number is found. Not equal adjacent digits including check digit are transposed and checked.
type UniqueGenerator ¶
type UniqueGenerator struct {
// contains filtered or unexported fields
}
UniqueGenerator holds state for generating random unique container numbers. Use NewUniqueGeneratorBuilder for initialization.
func (*UniqueGenerator) ContNum ¶
func (g *UniqueGenerator) ContNum() Number
ContNum returns a generated container number.
func (*UniqueGenerator) Generate ¶
func (g *UniqueGenerator) Generate() bool
Generate advances the serial number iterator to the next serial number, which will then be available through the ContNum method. It returns false when the generation stops by reaching the count of generated container numbers.
type ValidateError ¶
type ValidateError struct {
// contains filtered or unexported fields
}
ValidateError is an error for validation of a container number part.
func (*ValidateError) Error ¶
func (e *ValidateError) Error() string