/
immutablePrimitiveSetFactoryImpl.stg
96 lines (80 loc) · 2.23 KB
/
immutablePrimitiveSetFactoryImpl.stg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import "copyright.stg"
targetPath() ::= "org/eclipse/collections/impl/set/immutable/primitive"
fileName(primitive) ::= "Immutable<primitive.name>SetFactoryImpl"
class(primitive) ::= <<
<body(primitive.type, primitive.name)>
>>
body(type, name) ::= <<
<copyright()>
package org.eclipse.collections.impl.set.immutable.primitive;
import org.eclipse.collections.api.<name>Iterable;
import org.eclipse.collections.api.factory.set.primitive.Immutable<name>SetFactory;
import org.eclipse.collections.api.set.primitive.Immutable<name>Set;
import org.eclipse.collections.impl.set.mutable.primitive.<name>HashSet;
/**
* Immutable<name>SetFactoryImpl is a factory implementation which creates instances of type {@link Immutable<name>Set}.
* This file was automatically generated from template file immutablePrimitiveSetFactoryImpl.stg.
*
* @since 4.0.
*/
public class Immutable<name>SetFactoryImpl implements Immutable<name>SetFactory
{
@Override
public Immutable<name>Set empty()
{
return Immutable<name>EmptySet.INSTANCE;
}
@Override
public Immutable<name>Set of()
{
return this.empty();
}
@Override
public Immutable<name>Set with()
{
return this.empty();
}
@Override
public Immutable<name>Set of(<type> one)
{
return this.with(one);
}
@Override
public Immutable<name>Set with(<type> one)
{
return new Immutable<name>SingletonSet(one);
}
@Override
public Immutable<name>Set of(<type>... items)
{
return this.with(items);
}
@Override
public Immutable<name>Set with(<type>... items)
{
if (items == null || items.length == 0)
{
return this.with();
}
if (items.length == 1)
{
return this.with(items[0]);
}
return <name>HashSet.newSetWith(items).toImmutable();
}
@Override
public Immutable<name>Set ofAll(<name>Iterable items)
{
return this.withAll(items);
}
@Override
public Immutable<name>Set withAll(<name>Iterable items)
{
if (items instanceof Immutable<name>Set)
{
return (Immutable<name>Set) items;
}
return this.with(items.toArray());
}
}
>>