File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1818import software .amazon .smithy .model .node .*;
1919import software .amazon .smithy .utils .SmithyBuilder ;
2020
21+ import java .util .stream .Stream ;
22+ import java .util .Objects ;
23+
2124public final class ProtoReservedFieldsTraitValue {
2225
2326 public static final String NUMBER = "number" ;
@@ -29,6 +32,13 @@ public final class ProtoReservedFieldsTraitValue {
2932 public final Range range ;
3033
3134 public ProtoReservedFieldsTraitValue (Builder builder ) {
35+ if (Stream .of (
36+ builder .number ,
37+ builder .name ,
38+ builder .range
39+ ).filter (Objects ::nonNull ).count () != 1 ) {
40+ throw new IllegalArgumentException ("ProtoReservedFieldsTraitValue must be of exactly one type" );
41+ }
3242 this .number = builder .number ;
3343 this .name = builder .name ;
3444 this .range = builder .range ;
Original file line number Diff line number Diff line change 1+ /* Copyright 2022 Disney Streaming
2+ *
3+ * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * https://disneystreaming.github.io/TOST-1.0.txt
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+
16+ package alloy .proto
17+
18+ final class ProtoReservedFieldsTraitValueSpec extends munit.FunSuite {
19+
20+ test(" cannot instantiate invalid ProtoReservedFieldsTraitValue" ) {
21+ intercept[IllegalArgumentException ](
22+ ProtoReservedFieldsTraitValue .builder().build()
23+ )
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments