// EnumName returns the Nth enum in the shapes Enum list
165039
func (s *Shape) EnumName(n int) string {
	enum := s.Enum[n]
	enum = enumStrip.ReplaceAllLiteralString(enum, "")
	enum = enumCamelCase.ReplaceAllString(enum, "$1-$2")
	parts := enumDelims.Split(enum, -1)
	for i, v := range parts {
		v = strings.ToLower(v)
		parts[i] = ""
		if len(v) > 0 {
			parts[i] = strings.ToUpper(v[0:1])
		}
		if len(v) > 1 {
			parts[i] += v[1:]
		}
	}
	enum = strings.Join(parts, "")
	enum = strings.ToUpper(enum[0:1]) + enum[1:]
	return enum
}
1355684
func (s *Shape) ErrorName() string {
	name := s.ErrorInfo.Type
	switch s.API.Metadata.Protocol {
	case "query", "ec2query", "rest-xml":
		if len(s.ErrorInfo.Code) > 0 {
			name = s.ErrorInfo.Code
		}
	}

	if len(name) == 0 {
		name = s.OrigShapeName
	}
	if len(name) == 0 {
		name = s.ShapeName
	}

	return name
}
765233
func (c *UnitStateListCall) UnitName(unitName string) *UnitStateListCall {
	c.urlParams_.Set("unitName", unitName)
	return c
}
501635
func (f paramFiller) typeName(shape *Shape) string {
	if f.prefixPackageName && shape.Type == "structure" {
		return "*" + shape.API.PackageName() + "." + shape.GoTypeElem()
	}
	return shape.GoType()
}
216592
func typeName(g Generator, spec compile.TypeSpec) (string, error) {
	switch s := spec.(type) {
	case *compile.BoolSpec:
		return "bool", nil
	case *compile.I8Spec:
		return "int8", nil
	case *compile.I16Spec:
		return "int16", nil
	case *compile.I32Spec:
		return "int32", nil
	case *compile.I64Spec:
		return "int64", nil
	case *compile.DoubleSpec:
		return "float64", nil
	case *compile.StringSpec:
		return "string", nil
	case *compile.BinarySpec:
		return "[]byte", nil
	case *compile.MapSpec:
		k, err := typeReference(g, s.KeySpec)
		if err != nil {
			return "", err
		}
		v, err := typeReference(g, s.ValueSpec)
		if err != nil {
			return "", err
		}
		if !isHashable(s.KeySpec) {
			// unhashable type
			return fmt.Sprintf("[]struct{Key %s; Value %s}", k, v), nil
		}
		return fmt.Sprintf("map[%s]%s", k, v), nil
	case *compile.ListSpec:
		v, err := typeReference(g, s.ValueSpec)
		if err != nil {
			return "", err
		}
		return "[]" + v, nil
	case *compile.SetSpec:
		v, err := typeReference(g, s.ValueSpec)
		if err != nil {
			return "", err
		}
		// not annotated to be slice and hashable value type
		if setUsesMap(s) {
			return fmt.Sprintf("map[%s]struct{}", v), nil
		}
		return fmt.Sprintf("[]%s", v), nil
	case *compile.EnumSpec, *compile.StructSpec, *compile.TypedefSpec:
		return g.LookupTypeName(spec)
	default:
		panic(fmt.Sprintf("Unknown type (%T) %v", spec, spec))
	}
}
239356
func (p *printer) Enum(enum *descriptor.EnumDescriptorProto) {
	p.MaybeLeadingComments(enum)
	defer p.open("enum %s", enum.GetName())()

	for _, v := range enum.Value {
		p.EnumValue(v)
	}
}
1334175
func Enum(name rune, values []string, helpvalue ...string) *string {
	return CommandLine.Enum(name, values, helpvalue...)
}
14769
func serviceName(name string) string {
	aname := make([]byte, len(name))

	for i, r := range []byte(name) {
		if !labelRe.Match([]byte{r}) {
			aname[i] = '_'
			continue
		}
		aname[i] = r
	}

	return string(aname)
}
1012368
func (g *Generator) safeName(t reflect.Type) string {
	name := t.PkgPath()
	if t.Name() == "" {
		name += "anonymous"
	} else {
		name += "." + t.Name()
	}

	parts := []string{}
	part := []rune{}
	for _, c := range name {
		if unicode.IsLetter(c) || unicode.IsDigit(c) {
			part = append(part, c)
		} else if len(part) > 0 {
			parts = append(parts, string(part))
			part = []rune{}
		}
	}
	return joinFunctionNameParts(false, parts...)
}
491228
func (p *printer) EnumValue(v *descriptor.EnumValueDescriptorProto) {
	p.MaybeLeadingComments(v)
	p.Printf("%s = %d;\n", v.GetName(), v.GetNumber())
}
794063
func compileEnum(file string, src *ast.Enum) (*EnumSpec, error) {
	enumNS := newNamespace(caseInsensitive)
	prev := -1

	var items []EnumItem
	for _, astItem := range src.Items {
		if err := enumNS.claim(astItem.Name, astItem.Line); err != nil {
			return nil, compileError{
				Target: src.Name + "." + astItem.Name,
				Line:   astItem.Line,
				Reason: err,
			}
		}
		value := prev + 1
		if astItem.Value != nil {
			value = *astItem.Value
		}
		prev = value

		itemAnnotations, err := compileAnnotations(astItem.Annotations)
		if err != nil {
			return nil, compileError{
				Target: src.Name + "." + astItem.Name,
				Line:   astItem.Line,
				Reason: err,
			}
		}
		// TODO bounds check for value
		item := EnumItem{
			Name:        astItem.Name,
			Value:       int32(value),
			Doc:         astItem.Doc,
			Annotations: itemAnnotations,
		}
		items = append(items, item)
	}

	annotations, err := compileAnnotations(src.Annotations)
	if err != nil {
		return nil, compileError{
			Target: src.Name,
			Line:   src.Line,
			Reason: err,
		}
	}
	return &EnumSpec{
		Name:        src.Name,
		File:        file,
		Doc:         src.Doc,
		Items:       items,
		Annotations: annotations,
	}, nil
}
66914
func Enum(path, in string, data interface{}, enum interface{}) *errors.Validation {
	val := reflect.ValueOf(enum)
	if val.Kind() != reflect.Slice {
		return nil
	}

	var values []interface{}
	for i := 0; i < val.Len(); i++ {
		ele := val.Index(i)
		enumValue := ele.Interface()
		if data != nil {
			if reflect.DeepEqual(data, enumValue) {
				return nil
			}
			actualType := reflect.TypeOf(enumValue)
			if actualType == nil { // Safeguard. Frankly, I don't know how we may get a nil
				continue
			}
			expectedValue := reflect.ValueOf(data)
			if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) {
				// Attempt comparison after type conversion
				if reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), enumValue) {
					return nil
				}
			}
		}
		values = append(values, enumValue)
	}
	return errors.EnumFail(path, in, data, values)
}
308915
func EncodeName(buf []byte, name string) ([]byte, error) {
	return Encode(buf, Names[name])
}
959541
func (b *Builder) ResourceNames(resource string, names ...string) *Builder {
	for _, name := range names {
		// See if this input string is of type/name format
		tuple, ok, err := splitResourceTypeName(name)
		if err != nil {
			b.errs = append(b.errs, err)
			return b
		}

		if ok {
			b.resourceTuples = append(b.resourceTuples, tuple)
			continue
		}
		if len(resource) == 0 {
			b.errs = append(b.errs, fmt.Errorf("the argument %q must be RESOURCE/NAME", name))
			continue
		}

		// Use the given default type to create a resource tuple
		b.resourceTuples = append(b.resourceTuples, resourceTuple{Resource: resource, Name: name})
	}
	return b
}
313417
func (c *ModelCommandBase) ModelName() (string, error) {
	c.assertRunStarted()
	if err := c.maybeInitModel(); err != nil {
		return "", errors.Trace(err)
	}
	return c._modelName, nil
}
118950
func (item *OrderItem) ColorName() string {
	item.loadSizeVariation()
	return item.SizeVariation.ColorVariation.Color.Name
}
1215475
func ToJSONName(name string) string {
	in := split(name)
	out := make([]string, 0, len(in))

	for i, w := range in {
		if i == 0 {
			out = append(out, lower(w))
			continue
		}
		out = append(out, Camelize(w))
	}
	return strings.Join(out, "")
}