-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQueryRate.java
42 lines (35 loc) · 1.04 KB
/
QueryRate.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
package com.salimov.yurii.lesson07.task02;
import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@XmlRootElement(name = "query")
@XmlAccessorType(XmlAccessType.FIELD)
public final class QueryRate {
@XmlElementWrapper(name = "results")
@XmlElement(name = "rate")
private Collection<Rate> rateList = new ArrayList<>();
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
for (Rate rate : this.rateList) {
sb.append(rate).append("\n");
}
return sb.toString();
}
public void setRateList(final Collection<Rate> rateList) {
this.rateList = rateList;
}
public Collection<Rate> getRateList() {
return this.rateList;
}
public Rate getRate(final String id) {
Rate result = null;
for (Rate rate : this.rateList) {
if (rate.getXmlID().equalsIgnoreCase(id)) {
result = rate;
}
}
return result;
}
}