• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / JavaSpiNNaker / 6233274834

19 Sep 2023 08:46AM UTC coverage: 36.409% (-0.6%) from 36.982%
6233274834

Pull #658

github

dkfellows
Merge branch 'master' into java-17
Pull Request #658: Update Java version to 17

1656 of 1656 new or added lines in 260 files covered. (100.0%)

8373 of 22997 relevant lines covered (36.41%)

0.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/web/MachinesResponse.java
1
/*
2
 * Copyright (c) 2021 The University of Manchester
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package uk.ac.manchester.spinnaker.alloc.web;
17

18
import static java.util.stream.Collectors.toUnmodifiableList;
19
import static uk.ac.manchester.spinnaker.utils.CollectionUtils.copy;
20

21
import java.net.URI;
22
import java.util.List;
23
import java.util.Map;
24

25
import javax.ws.rs.core.UriInfo;
26

27
import uk.ac.manchester.spinnaker.alloc.allocator.SpallocAPI.Machine;
28
import uk.ac.manchester.spinnaker.alloc.model.BoardCoords;
29
import uk.ac.manchester.spinnaker.alloc.model.DownLink;
30

31
/**
32
 * The description of machines known to the service. A list of
33
 * {@link BriefMachineDescription}s.
34
 *
35
 * @author Donal Fellows
36
 * @param machines
37
 *            The list of machines known to the service.
38
 */
39
public record MachinesResponse(List<BriefMachineDescription> machines) {
×
40
        /**
41
         * A brief, summary description of a machine.
42
         *
43
         * @author Donal Fellows
44
         * @param name
45
         *            The name of the machine.
46
         * @param tags
47
         *            The tags of the machine.
48
         * @param uri
49
         *            The URI to the machine.
50
         * @param width
51
         *            The width of the machine, in triads.
52
         * @param height
53
         *            The height of the machine, in triads.
54
         * @param deadBoards
55
         *            The dead boards on the machine.
56
         * @param deadLinks
57
         *            The dead links on the machine.
58
         */
59
        public record BriefMachineDescription(String name, List<String> tags,
×
60
                        URI uri, int width, int height, List<BoardCoords> deadBoards,
61
                        List<DownLink> deadLinks) {
62
        }
63

64
        MachinesResponse(Map<String, Machine> machines, UriInfo ui) {
65
                this(makeBriefDescriptions(machines, ui));
×
66
        }
×
67

68
        private static List<BriefMachineDescription> makeBriefDescriptions(
69
                        Map<String, Machine> machines, UriInfo ui) {
70
                var ub = ui.getAbsolutePathBuilder().path("{name}");
×
71
                return machines.entrySet().stream()
×
72
                                .map(e -> new BriefMachineDescription(e.getKey(),
×
73
                                                List.copyOf(e.getValue().getTags()),
×
74
                                                ub.build(e.getKey()), e.getValue().getWidth(),
×
75
                                                e.getValue().getHeight(),
×
76
                                                copy(e.getValue().getDeadBoards()),
×
77
                                                copy(e.getValue().getDownLinks())))
×
78
                                .collect(toUnmodifiableList());
×
79
        }
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc