1 /*
2 * Copyright (c) &today.year Kaiserpfalz EDV-Service, Roland T. Lichti
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package de.kaiserpfalzedv.rpg.torg.data;
19
20 import de.kaiserpfalzedv.commons.core.resources.MetadataImpl;
21 import de.kaiserpfalzedv.commons.core.resources.PointerImpl;
22 import de.kaiserpfalzedv.rpg.core.Books.Publisher;
23 import de.kaiserpfalzedv.rpg.core.Books.PublisherData;
24 import de.kaiserpfalzedv.rpg.torg.About;
25
26 import java.util.Map;
27 import java.util.Optional;
28 import java.util.UUID;
29 import java.util.function.Function;
30 import java.util.stream.Collectors;
31 import java.util.stream.Stream;
32
33 /**
34 * Publishers -- A list of known publishers.
35 *
36 * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
37 * @since 1.2.0 2021-05-23
38 */
39 public interface Publishers {
40 Publisher ULISSES_SPIELE = Publisher.builder()
41 .metadata(MetadataImpl.builder()
42 .identity(PointerImpl.builder()
43 .kind(Publisher.KIND)
44 .apiVersion(Publisher.VERSION)
45 .nameSpace(About.TORG_NAMESPACE)
46 .name("Ulisses Spiele")
47 .build()
48 )
49 .created(About.DEFAULT_CREATION)
50 .uid(UUID.fromString("c6d3efb7-2c99-4ac3-8d9a-fa48b1a597c2"))
51 .generation(1)
52 .build()
53 )
54 .spec(
55 PublisherData.builder()
56 .driveThroughId(3444)
57 .build()
58 )
59 .build();
60
61 Publisher PALADINS_INN = Publisher.builder()
62 .metadata(MetadataImpl.builder()
63 .identity(PointerImpl.builder()
64 .kind(Publisher.KIND)
65 .apiVersion(Publisher.VERSION)
66 .nameSpace(About.TORG_NAMESPACE)
67 .name("Paladin's Inn")
68 .build()
69 )
70 .created(About.DEFAULT_CREATION)
71 .uid(UUID.fromString("a26b0214-2aca-4f78-bb34-e827319ec8c9"))
72 .generation(1)
73 .build()
74 )
75 .build();
76
77 Map<UUID, Publisher> PUBLISHERS = Stream.of(ULISSES_SPIELE, PALADINS_INN).collect(Collectors.toMap(Publisher::getUid, Function.identity()));
78
79 /**
80 * @param id The UUID of the publisher.
81 * @return The publisher with the given ID (if present).
82 */
83 default Optional<Publisher> findPublisherByUuid(final UUID id) {
84 return Optional.ofNullable(PUBLISHERS.get(id));
85 }
86 }