-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCatalogo_Clientes.java
91 lines (83 loc) · 2.18 KB
/
Catalogo_Clientes.java
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
import java.util.Arrays;
import java.util.Iterator;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.io.Serializable;
public class Catalogo_Clientes implements Serializable {
/**
* Catálogo de clientes
*/
private HashSet<String> catClientes;
/**
* Construtor vazio
*/
public Catalogo_Clientes(){
catClientes = new HashSet<>();
}
/**
* Construtor por cópia
* @param c
*/
public Catalogo_Clientes(Catalogo_Clientes c){
catClientes = c.getCClientes();
}
/**
* Obter catálogo de clientes
* @re turn
*/
public HashSet<String> getCClientes(){
HashSet<String> copia = new HashSet<>();
catClientes.stream().forEach(x->copia.add(x));
return copia;
}
/**
* Substituir catálogo de clientes
* @param catalogo
*/
public void setCatClientes(HashSet<String> catalogo){
catalogo.stream().forEach(x->catClientes.add(x));
}
public void addCatClientes(String cliente){
if(catClientes==null) catClientes = new HashSet<>();
catClientes.add(cliente);
}
public boolean existe(String s){
return catClientes.contains(s);
}
/**
* Equals
*/
public boolean equals(Object o){
if(this == o) return true;
if(this == null || this.getClass() != o.getClass()) return false;
Catalogo_Clientes c = (Catalogo_Clientes) o;
return catClientes.retainAll(c.getCClientes());
}
/**
* Clone
*/
public Catalogo_Clientes clone(){
return new Catalogo_Clientes(this);
}
/**
* toString
*/
public String toString(){
StringBuilder sb = new StringBuilder();
Iterator<String> it = catClientes.iterator();
while(it.hasNext()){
String str = (String) it.next();
sb.append(str);
sb.append("\n");
}
return sb.toString();
}
/**
* hashCode
*/
public int hashCode(){
return Arrays.hashCode(new Object[]{catClientes});
}
}