Skip to content

Commit 9ef4345

Browse files
Duncan McGregordmcg
authored andcommitted
methods-to-properties.0 : baseline
1 parent 1d281b0 commit 9ef4345

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

src/main/java/travelator/Address.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package travelator;
2+
3+
public class Address {
4+
private final String line1;
5+
private final String line2;
6+
private final String locality;
7+
private final String region;
8+
private final String postalCode;
9+
private final String countryCode;
10+
11+
public Address(String line1, String line2, String locality, String region, String postalCode, String countryCode) {
12+
this.line1 = line1;
13+
this.line2 = line2;
14+
this.locality = locality;
15+
this.region = region;
16+
this.postalCode = postalCode;
17+
this.countryCode = countryCode;
18+
}
19+
20+
public String getCountryCode() {
21+
return countryCode;
22+
}
23+
24+
public String getRegion() {
25+
return region;
26+
}
27+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package travelator;
2+
3+
public class CampSite {
4+
private final String id;
5+
private final String name;
6+
private final Address address;
7+
8+
public CampSite(
9+
String id,
10+
String name,
11+
Address address
12+
) {
13+
this.id = id;
14+
this.name = name;
15+
this.address = address;
16+
}
17+
18+
public String getId() {
19+
return id;
20+
}
21+
22+
public String getName() {
23+
return name;
24+
}
25+
26+
public String getCountryCode() {
27+
return address.getCountryCode();
28+
}
29+
30+
public String region() {
31+
return address.getRegion();
32+
}
33+
34+
public Address getAddress() {
35+
return address;
36+
}
37+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package travelator;
2+
3+
import java.util.Set;
4+
5+
import static java.util.stream.Collectors.toUnmodifiableSet;
6+
7+
public class CampSites {
8+
9+
public static Set<CampSite> sitesInRegion(
10+
Set<CampSite> sites,
11+
String countryISO,
12+
String region
13+
) {
14+
return sites.stream()
15+
.filter( campSite ->
16+
campSite.getCountryCode().equals(countryISO) &&
17+
campSite.region().equalsIgnoreCase(region)
18+
)
19+
.collect(toUnmodifiableSet());
20+
}
21+
}

0 commit comments

Comments
 (0)