// SingleItem returns the first config.Config in v's Items slice. If the Items
// slice is empty, SingleItem will return nil.
194829
func (v *Value) SingleItem() *config.Config {
	if len(v.Items) == 0 {
		return nil
	}
	return v.Items[0].ConfigItem()
}
103632
func (tc *TransCache) HasItem(chID, itmID string) (has bool) {
	tc.cacheMux.RLock()
	has = tc.cacheInstance(chID).HasItem(itmID)
	tc.cacheMux.RUnlock()
	return
}
419928
func (piType *PropertyItemType) UnmarshalJSON(data []byte) error {
	singleString := ""
	singleErr := json.Unmarshal(data, &singleString)
	if singleErr == nil {
		piType.Scalar = singleString
		return nil
	}
	var stringArray []string
	sliceErr := json.Unmarshal(data, &stringArray)
	if sliceErr == nil {
		piType.MultiValues = stringArray
		return nil
	}
	return fmt.Errorf("Failed to unmarshal type: " + sliceErr.Error())
}
834204
func (s *StoragePacker) PutItem(_ context.Context, item *Item) error {
	if item == nil {
		return fmt.Errorf("nil item")
	}

	if item.ID == "" {
		return fmt.Errorf("missing ID in item")
	}

	var err error
	bucketKey := s.BucketKey(item.ID)
	bucketPath := s.BucketPath(bucketKey)

	bucket := &Bucket{
		Key: bucketPath,
	}

	// In this case, we persist the storage entry regardless of the read
	// storageEntry below is nil or not. Hence, directly acquire write lock
	// even to read the entry.
	lock := locksutil.LockForKey(s.storageLocks, bucketPath)
	lock.Lock()
	defer lock.Unlock()

	// Check if there is an existing bucket for a given key
	storageEntry, err := s.view.Get(context.Background(), bucketPath)
	if err != nil {
		return errwrap.Wrapf("failed to read packed storage bucket entry: {{err}}", err)
	}

	if storageEntry == nil {
		// If the bucket entry does not exist, this will be the only item the
		// bucket that is going to be persisted.
		bucket.Items = []*Item{
			item,
		}
	} else {
		uncompressedData, notCompressed, err := compressutil.Decompress(storageEntry.Value)
		if err != nil {
			return errwrap.Wrapf("failed to decompress packed storage entry: {{err}}", err)
		}
		if notCompressed {
			uncompressedData = storageEntry.Value
		}

		err = proto.Unmarshal(uncompressedData, bucket)
		if err != nil {
			return errwrap.Wrapf("failed to decode packed storage entry: {{err}}", err)
		}

		err = bucket.upsert(item)
		if err != nil {
			return errwrap.Wrapf("failed to update entry in packed storage entry: {{err}}", err)
		}
	}

	// Persist the result
	return s.PutBucket(bucket)
}
510369
func (s *iniSection) rmItem(key string, flag bool) bool {
	if s == nil {
		return false
	}
	key = ident(flag, key)
	for i, item := range s.Data {
		if item == nil {
			continue
		}
		if ident(flag, item.Key) == key {
			n := len(s.Data) - 1
			skip := 1
			// Remove newline if the key was the last one in the block.
			if (i > 0 && s.Data[i-1] == nil && i < n && s.Data[i+1] == nil) ||
				(i == 0 && n > 0 && s.Data[1] == nil) {
				// Removed key is not the first key and previous and next keys are newlines.
				// Removed key is the first key and next key is a newline.
				skip++
				n--
			}
			copy(s.Data[i:], s.Data[i+skip:])
			s.Data[n] = nil
			s.Data = s.Data[:n]
			return true
		}
	}
	return false
}
164243
func (r *GormWorkItemRepository) FindFirstItem(ctx context.Context, spaceID uuid.UUID, id uuid.UUID) (*float64, error) {
	res := WorkItemStorage{}
	tx := r.db.Model(WorkItemStorage{}).Where("id=? and space_id=?", id, spaceID).First(&res)
	if tx.RecordNotFound() {
		return nil, errors.NewNotFoundError("work item", id.String())
	}
	if tx.Error != nil {
		return nil, errors.NewInternalError(ctx, tx.Error)
	}
	return &res.ExecutionOrder, nil
}
924636
func (d *DataBagService) GetItem(databagName, databagItem string) (item DataBagItem, err error) {
	path := fmt.Sprintf("data/%s/%s", databagName, databagItem)
	err = d.client.magicRequestDecoder("GET", path, nil, &item)
	return
}
1021882
func (o *Operation) initExample(config *Config) {
	path := o.Type.Name + ".yaml"
	path = filepath.Join(*ConfigDir, config.ExampleLocation, o.Definition.Name, path)
	path = strings.Replace(path, " ", "_", -1)
	path = strings.ToLower(path)
	content, err := ioutil.ReadFile(path)
	if err != nil {
		return
	}
	err = yaml.Unmarshal(content, &o.ExampleConfig)
	if err != nil {
		panic(fmt.Sprintf("Could not Unmarshal ExampleConfig yaml: %s\n", content))
	}
}
591831
func (s *GetItemOutput) SetItem(v map[string]*AttributeValue) *GetItemOutput {
	s.Item = v
	return s
}
1067869
func (vi *ValueItem) ConfigItem() *config.Config {
	return &config.Config{
		Meta: config.Meta{
			ConfigSet:   config.Set(vi.ConfigSet),
			Path:        vi.Path,
			ContentHash: vi.ContentHash,
			Revision:    vi.Revision,
			ViewURL:     vi.ViewURL,
		},
		Content:    string(vi.Content),
		FormatSpec: config.FormatSpec{vi.Formatter, string(vi.FormatData)},
	}
}
750405
func (s *SegmentsResponse) SetItem(v []*SegmentResponse) *SegmentsResponse {
	s.Item = v
	return s
}
1246838
func (s *SecretService) CreateItem(collection dbus.BusObject, label string, attributes map[string]string, secret Secret) error {
	properties := map[string]dbus.Variant{
		itemInterface + ".Label":      dbus.MakeVariant(label),
		itemInterface + ".Attributes": dbus.MakeVariant(attributes),
	}

	var item, prompt dbus.ObjectPath
	err := collection.Call(collectionInterface+".CreateItem", 0,
		properties, secret, true).Store(&item, &prompt)
	if err != nil {
		return err
	}

	_, _, err = s.handlePrompt(prompt)
	if err != nil {
		return err
	}

	return nil
}
986161
func (g *Grid) RemoveItem(p Primitive) *Grid {
	for index := len(g.items) - 1; index >= 0; index-- {
		if g.items[index].Item == p {
			g.items = append(g.items[:index], g.items[index+1:]...)
		}
	}
	return g
}
167324
func RandomItem(items ...string) string {
	var bytes = make([]byte, 1)
	rand.Read(bytes)
	return items[bytes[0]%byte(len(items))]
}
450689
func (f *Flex) ResizeItem(p Primitive, fixedSize, proportion int) *Flex {
	for _, item := range f.items {
		if item.Item == p {
			item.FixedSize = fixedSize
			item.Proportion = proportion
		}
	}
	return f
}
327439
func (menu *Menu) AddItem(commandID uint, label string) {
	command := Command{
		Method: "add_item",
		Args: CommandArguments{
			CommandID: commandID,
			Label:     label,
		},
	}
	menuItem := MenuItem{
		CommandID: commandID,
		Label:     label,
		Parent:    menu,
		Type:      "item",
	}
	menu.Items = append(menu.Items, &menuItem)

	menu.CallWhenReady(&command)
}
662109
func (s *EndpointsResponse) SetItem(v []*EndpointResponse) *EndpointsResponse {
	s.Item = v
	return s
}