-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListSection.java
More file actions
46 lines (38 loc) · 1.3 KB
/
ListSection.java
File metadata and controls
46 lines (38 loc) · 1.3 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
package com.urise.webapp.model;
import com.urise.webapp.exception.StorageException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@XmlAccessorType(XmlAccessType.FIELD)
public class ListSection extends AbstractSection {
private static final long serialVersionUID = 1L;
private List<String> listSection = new ArrayList<>();
public ListSection() {}
public ListSection(List<String> listSection) {
this.listSection = listSection;
}
public ListSection(String text) {
this.listSection.add(text);
}
public List<String> getListSection() {
return listSection;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ListSection that = (ListSection) o;
return Objects.equals(getListSection(), that.getListSection());
}
@Override
public int hashCode() {
return Objects.hash(getListSection());
}
@Override
public String toString() {
return listSection.stream().reduce((s1, s2) -> (s1 + "\n") + s2 )
.orElseThrow(() -> new StorageException("Wrong ListSection"));
}
}