• 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

80.0
/SpiNNaker-comms/src/main/java/uk/ac/manchester/spinnaker/spalloc/messages/Connection.java
1
/*
2
 * Copyright (c) 2018 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.spalloc.messages;
17

18
import static com.fasterxml.jackson.annotation.JsonFormat.Shape.ARRAY;
19
import static java.util.Objects.isNull;
20

21
import javax.validation.Valid;
22

23
import com.fasterxml.jackson.annotation.JsonFormat;
24
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
25
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
26
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
27
import com.google.errorprone.annotations.CanIgnoreReturnValue;
28
import com.google.errorprone.annotations.Immutable;
29

30
import uk.ac.manchester.spinnaker.machine.ChipLocation;
31
import uk.ac.manchester.spinnaker.machine.HasChipLocation;
32
import uk.ac.manchester.spinnaker.utils.validation.IPAddress;
33

34
/**
35
 * Describes a connection by its chip and hostname.
36
 *
37
 * @param chip
38
 *            The chip for the connection.
39
 * @param hostname
40
 *            Where to connect to to talk to the chip.
41
 */
42
@JsonPropertyOrder({ "chip", "hostname" })
43
@JsonFormat(shape = ARRAY)
44
@JsonDeserialize(builder = Connection.Builder.class)
45
@Immutable
46
public record Connection(@Valid ChipLocation chip,
1✔
47
                @IPAddress String hostname) {
48
        /**
49
         * Create.
50
         *
51
         * @param chip
52
         *            the chip
53
         * @param hostname
54
         *            the host
55
         */
56
        public Connection(HasChipLocation chip, String hostname) {
57
                this(isNull(chip) ? null : chip.asChipLocation(), hostname);
×
58
        }
×
59

60
        @Override
61
        public String toString() {
62
                return "Connection(" + chip + "@" + hostname + ")";
1✔
63
        }
64

65
        @JsonPropertyOrder({ "chip", "hostname" })
66
        @JsonFormat(shape = ARRAY)
67
        @JsonPOJOBuilder
68
        static class Builder {
1✔
69
                private ChipLocation chip;
70

71
                private String hostname;
72

73
                @CanIgnoreReturnValue
74
                public Builder withChip(ChipLocation chip) {
75
                        this.chip = chip;
1✔
76
                        return this;
1✔
77
                }
78

79
                @CanIgnoreReturnValue
80
                public Builder withHostname(String hostname) {
81
                        this.hostname = hostname;
1✔
82
                        return this;
1✔
83
                }
84

85
                public Connection build() {
86
                        return new Connection(chip, hostname);
1✔
87
                }
88
        }
89
}
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