• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

smartsheet / smartsheet-java-sdk / #55

02 Oct 2024 07:40PM UTC coverage: 60.548% (+0.7%) from 59.836%
#55

push

github

web-flow
Release prep for 3.2.1 (#103)

4156 of 6864 relevant lines covered (60.55%)

0.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/smartsheet/api/models/ListBuilder.java
1
/*
2
 * Copyright (C) 2024 Smartsheet
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.smartsheet.api.models;
18

19
import java.util.ArrayList;
20
import java.util.Collection;
21
import java.util.Collections;
22
import java.util.List;
23

24
/**
25
 * Simple class that makes creating type safe lists of object easier
26
 */
27
public class ListBuilder<T> {
28
    private List<T> list;
29

30
    /**
31
     * Default constructor
32
     */
33
    public ListBuilder() {
×
34
    }
×
35

36
    /**
37
     * Constructor
38
     *
39
     * @param initialCapacity Initial capacity of the internal storage of the list.
40
     */
41
    public ListBuilder(int initialCapacity) {
×
42
        this.list = new ArrayList<>(initialCapacity);
×
43
    }
×
44

45
    /**
46
     * Adds a single element to the list
47
     *
48
     * @param element element to add
49
     * @return ListBuilder
50
     */
51
    public ListBuilder<T> add(T element) {
52
        list.add(element);
×
53
        return this;
×
54
    }
55

56
    /**
57
     * Adds multiple elements to the list
58
     *
59
     * @param elements elements to add
60
     * @return ListBuilder
61
     */
62
    public ListBuilder<T> add(T... elements) {
63
        Collections.addAll(list, elements);
×
64
        return this;
×
65
    }
66

67
    /**
68
     * Adds multiple elements to the list
69
     *
70
     * @param elements elements to add
71
     * @return ListBuilder
72
     */
73
    public ListBuilder<T> add(Collection<T> elements) {
74
        list.addAll(elements);
×
75
        return this;
×
76
    }
77

78
    /**
79
     * Retrieves the built up list of objects
80
     *
81
     * @return The build up list of objects
82
     */
83
    public List<T> build() {
84
        return list;
×
85
    }
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc