-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConversion.java
More file actions
42 lines (34 loc) · 1010 Bytes
/
Conversion.java
File metadata and controls
42 lines (34 loc) · 1010 Bytes
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
package com.yurii.salimov.lesson08.task01;
import java.util.Arrays;
import java.util.Collection;
/**
* @author Yuriy Salimov (yuriy.alex.salimov@gmail.com)
* @version 1.0
*/
public final class Conversion<T> {
private final T[] elements;
private Collection<T> conversionElements;
public Conversion(final T[] elements) {
this.elements = elements;
}
@Override
public String toString() {
return "Conversion{" +
"elements=" + Arrays.toString(this.elements) +
", conversionElements=" + getConversionElements() +
'}';
}
public Collection<T> convert() {
this.conversionElements = Arrays.asList(this.elements);
return this.conversionElements;
}
public T[] getElements() {
return this.elements;
}
public Collection<T> getConversionElements() {
if (this.conversionElements == null) {
convert();
}
return this.conversionElements;
}
}