-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSupplierList.java
More file actions
60 lines (52 loc) · 1.65 KB
/
Copy pathSupplierList.java
File metadata and controls
60 lines (52 loc) · 1.65 KB
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
import java.util.*;
import java.io.*;
public class SupplierList implements Serializable {
private static final long serialVersionUID = 1L;
private List<Supplier> suppliers = new LinkedList<Supplier>(); // Linked list of suppliers
private static SupplierList SupplierList;
private SupplierList() {
}
public static SupplierList instance() { // check if an instance exists (singleton)
if (SupplierList == null) {
return (SupplierList = new SupplierList());
} else {
return SupplierList;
}
}
public boolean insertSupplier(Supplier supplier) {
suppliers.add(supplier);
return true;
}
public Iterator<Supplier> getSuppliers() {
return suppliers.iterator();
}
private void writeObject(java.io.ObjectOutputStream output) {
try {
output.defaultWriteObject();
output.writeObject(SupplierList);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
private void readObject(java.io.ObjectInputStream input) {
try {
if (SupplierList != null) {
return;
} else {
input.defaultReadObject();
if (SupplierList == null) {
SupplierList = (SupplierList) input.readObject();
} else {
input.readObject();
}
}
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}
}
public String toString() {
return suppliers.toString();
}
}