~ubuntu-branches/ubuntu/wily/gs-collections/wily

« back to all changes in this revision

Viewing changes to gs-collections-code-generator/src/main/resources/impl/list/immutable/immutablePrimitiveListFactoryImpl.stg

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2015-07-23 12:42:30 UTC
  • Revision ID: package-import@ubuntu.com-20150723124230-2rjvfv6elyn2m7d4
Tags: upstream-5.1.0
ImportĀ upstreamĀ versionĀ 5.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import "copyright.stg"
 
2
 
 
3
targetPath() ::= "com/gs/collections/impl/list/immutable/primitive"
 
4
 
 
5
fileName(primitive) ::= "Immutable<primitive.name>ListFactoryImpl"
 
6
 
 
7
class(primitive) ::= <<
 
8
<body(primitive.type, primitive.name)>
 
9
>>
 
10
 
 
11
body(type, name) ::= <<
 
12
<copyright()>
 
13
 
 
14
package com.gs.collections.impl.list.immutable.primitive;
 
15
 
 
16
import com.gs.collections.api.<name>Iterable;
 
17
import com.gs.collections.api.factory.list.primitive.Immutable<name>ListFactory;
 
18
import com.gs.collections.api.list.primitive.Immutable<name>List;
 
19
 
 
20
/**
 
21
 * Immutable<name>ListFactoryImpl is a factory implementation which creates instances of type {@link Immutable<name>List}.
 
22
 * This file was automatically generated from template file immutablePrimitiveListFactoryImpl.stg.
 
23
 *
 
24
 * @since 3.2.
 
25
 */
 
26
public class Immutable<name>ListFactoryImpl implements Immutable<name>ListFactory
 
27
{
 
28
    public Immutable<name>List of()
 
29
    {
 
30
        return this.with();
 
31
    }
 
32
 
 
33
    public Immutable<name>List with()
 
34
    {
 
35
        return Immutable<name>EmptyList.INSTANCE;
 
36
    }
 
37
 
 
38
    public Immutable<name>List of(<type> one)
 
39
    {
 
40
        return this.with(one);
 
41
    }
 
42
 
 
43
    public Immutable<name>List with(<type> one)
 
44
    {
 
45
        return new Immutable<name>SingletonList(one);
 
46
    }
 
47
 
 
48
    public Immutable<name>List of(<type>... items)
 
49
    {
 
50
        return this.with(items);
 
51
    }
 
52
 
 
53
    public Immutable<name>List with(<type>... items)
 
54
    {
 
55
        if (items == null || items.length == 0)
 
56
        {
 
57
            return this.with();
 
58
        }
 
59
        if (items.length == 1)
 
60
        {
 
61
            return this.with(items[0]);
 
62
        }
 
63
        return Immutable<name>ArrayList.newListWith(items);
 
64
    }
 
65
 
 
66
    public Immutable<name>List ofAll(<name>Iterable items)
 
67
    {
 
68
        return this.withAll(items);
 
69
    }
 
70
 
 
71
    public Immutable<name>List withAll(<name>Iterable items)
 
72
    {
 
73
        if (items instanceof Immutable<name>List)
 
74
        {
 
75
            return (Immutable<name>List) items;
 
76
        }
 
77
        return this.with(items.toArray());
 
78
    }
 
79
}
 
80
 
 
81
>>