Skip to content

Commit 26f93f0

Browse files
committed
try to fix Java 25 abstract interface issue
1 parent 68ebdd2 commit 26f93f0

File tree

4 files changed

+97
-112
lines changed

4 files changed

+97
-112
lines changed

src/main/java/com/bandwidth/sdk/model/bxml/OutboundDestination.java

Lines changed: 82 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,97 @@
44

55
package com.bandwidth.sdk.model.bxml;
66

7-
import jakarta.xml.bind.annotation.XmlAccessType;
8-
import jakarta.xml.bind.annotation.XmlAccessorType;
9-
import jakarta.xml.bind.annotation.XmlType;
7+
import static com.bandwidth.sdk.model.bxml.utils.BxmlConstants.DEFAULT_CALLBACK_METHOD;
108

11-
@XmlAccessorType(XmlAccessType.FIELD)
12-
@XmlType
13-
public interface OutboundDestination {
14-
String getUsername();
9+
import jakarta.xml.bind.annotation.XmlAttribute;
10+
import jakarta.xml.bind.annotation.XmlTransient;
11+
import lombok.AllArgsConstructor;
12+
import lombok.Builder.Default;
13+
import lombok.experimental.SuperBuilder;
14+
import lombok.EqualsAndHashCode;
15+
import lombok.Getter;
16+
import lombok.NoArgsConstructor;
1517

16-
String getPassword();
18+
@NoArgsConstructor
19+
@AllArgsConstructor
20+
@SuperBuilder
21+
@Getter
22+
@EqualsAndHashCode(callSuper = false)
1723

18-
String getTransferAnswerUrl();
24+
@XmlTransient
25+
abstract public class OutboundDestination {
26+
@XmlAttribute
27+
protected String uui;
28+
public String getUui() {
29+
return uui;
30+
}
1931

20-
String getTransferAnswerMethod();
32+
@XmlAttribute
33+
protected String username;
34+
public String getUsername() {
35+
return username;
36+
}
2137

22-
String getTransferDisconnectUrl();
38+
@XmlAttribute
39+
protected String password;
40+
public String getPassword() {
41+
return password;
42+
}
2343

24-
String getTransferDisconnectMethod();
44+
@XmlAttribute
45+
protected String fallbackUsername;
46+
public String getFallbackUsername() {
47+
return fallbackUsername;
48+
}
2549

26-
String getFallbackUsername();
50+
@XmlAttribute
51+
protected String fallbackPassword;
52+
public String getFallbackPassword() {
53+
return fallbackPassword;
54+
}
2755

28-
String getFallbackPassword();
56+
@XmlAttribute
57+
protected String transferAnswerUrl;
58+
public String getTransferAnswerUrl() {
59+
return transferAnswerUrl;
60+
}
2961

30-
String getTransferAnswerFallbackUrl();
62+
@XmlAttribute
63+
@Default
64+
protected String transferAnswerMethod = DEFAULT_CALLBACK_METHOD;
65+
public String getTransferAnswerMethod() {
66+
return transferAnswerMethod;
67+
}
3168

32-
String getTransferAnswerFallbackMethod();
69+
@XmlAttribute
70+
protected String transferAnswerFallbackUrl;
71+
public String getTransferAnswerFallbackUrl() {
72+
return transferAnswerFallbackUrl;
73+
}
3374

34-
String getTag();
75+
@XmlAttribute
76+
@Default
77+
protected String transferAnswerFallbackMethod = DEFAULT_CALLBACK_METHOD;
78+
public String getTransferAnswerFallbackMethod() {
79+
return transferAnswerFallbackMethod;
80+
}
81+
82+
@XmlAttribute
83+
protected String transferDisconnectUrl;
84+
public String getTransferDisconnectUrl() {
85+
return transferDisconnectUrl;
86+
}
87+
88+
@XmlAttribute
89+
@Default
90+
protected String transferDisconnectMethod = DEFAULT_CALLBACK_METHOD;
91+
public String getTransferDisconnectMethod() {
92+
return transferDisconnectMethod;
93+
}
94+
95+
@XmlAttribute
96+
protected String tag;
97+
public String getTag() {
98+
return tag;
99+
}
35100
}

src/main/java/com/bandwidth/sdk/model/bxml/PhoneNumber.java

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44
*/
55
package com.bandwidth.sdk.model.bxml;
66

7-
import static com.bandwidth.sdk.model.bxml.utils.BxmlConstants.DEFAULT_CALLBACK_METHOD;
8-
97
import jakarta.xml.bind.annotation.XmlAccessType;
108
import jakarta.xml.bind.annotation.XmlAccessorType;
11-
import jakarta.xml.bind.annotation.XmlAttribute;
129
import jakarta.xml.bind.annotation.XmlType;
1310
import jakarta.xml.bind.annotation.XmlValue;
1411
import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter;
1512
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
1613
import lombok.AllArgsConstructor;
17-
import lombok.Builder;
18-
import lombok.Builder.Default;
14+
import lombok.experimental.SuperBuilder;
1915
import lombok.EqualsAndHashCode;
2016
import lombok.Getter;
2117
import lombok.NoArgsConstructor;
@@ -24,9 +20,9 @@
2420
@XmlType(name = PhoneNumber.TYPE_NAME)
2521
@NoArgsConstructor
2622
@AllArgsConstructor
27-
@Builder
23+
@SuperBuilder
2824
@Getter
29-
@EqualsAndHashCode
25+
@EqualsAndHashCode(callSuper = false)
3026
/**
3127
*
3228
* @param number (str): A phone number to transfer the call to. Value must be in E.164 format (e.g. +15555555555).
@@ -44,50 +40,14 @@
4440
* @param uui (str, optional): The value of the User-To-User header to send within the initial INVITE. Must include the encoding parameter as specified in RFC 7433. Only base64, jwt and hex encoding are currently allowed. This value, including the encoding specifier, may not exceed 256 characters.
4541
*
4642
*/
47-
public class PhoneNumber implements OutboundDestination {
43+
public class PhoneNumber extends OutboundDestination {
4844

4945
public static final String TYPE_NAME = "PhoneNumber";
5046

5147
@XmlValue
5248
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
5349
protected String number;
54-
55-
@XmlAttribute
56-
protected String username;
57-
58-
@XmlAttribute
59-
protected String password;
60-
61-
@XmlAttribute
62-
protected String fallbackUsername;
63-
64-
@XmlAttribute
65-
protected String fallbackPassword;
66-
67-
@XmlAttribute
68-
protected String transferAnswerUrl;
69-
70-
@XmlAttribute
71-
@Default
72-
protected String transferAnswerMethod = DEFAULT_CALLBACK_METHOD;
73-
74-
@XmlAttribute
75-
protected String transferAnswerFallbackUrl;
76-
77-
@XmlAttribute
78-
@Default
79-
protected String transferAnswerFallbackMethod = DEFAULT_CALLBACK_METHOD;
80-
81-
@XmlAttribute
82-
protected String transferDisconnectUrl;
83-
84-
@XmlAttribute
85-
@Default
86-
protected String transferDisconnectMethod = DEFAULT_CALLBACK_METHOD;
87-
88-
@XmlAttribute
89-
protected String tag;
90-
91-
@XmlAttribute
92-
protected String uui;
50+
public String getNumber() {
51+
return number;
52+
}
9353
}

src/main/java/com/bandwidth/sdk/model/bxml/SipUri.java

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@
55

66
package com.bandwidth.sdk.model.bxml;
77

8-
import static com.bandwidth.sdk.model.bxml.utils.BxmlConstants.DEFAULT_CALLBACK_METHOD;
9-
108
import jakarta.xml.bind.annotation.XmlAccessType;
119
import jakarta.xml.bind.annotation.XmlAccessorType;
12-
import jakarta.xml.bind.annotation.XmlAttribute;
1310
import jakarta.xml.bind.annotation.XmlType;
1411
import jakarta.xml.bind.annotation.XmlValue;
1512
import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter;
1613
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
1714
import lombok.AllArgsConstructor;
18-
import lombok.Builder;
19-
import lombok.Builder.Default;
15+
import lombok.experimental.SuperBuilder;
2016
import lombok.EqualsAndHashCode;
2117
import lombok.Getter;
2218
import lombok.NoArgsConstructor;
@@ -25,9 +21,9 @@
2521
@XmlType(name = SipUri.TYPE_NAME)
2622
@NoArgsConstructor
2723
@AllArgsConstructor
28-
@Builder
24+
@SuperBuilder
2925
@Getter
30-
@EqualsAndHashCode
26+
@EqualsAndHashCode(callSuper = false)
3127
/**
3228
*
3329
* @param uri (str): A SIP URI to transfer the call to (e.g. sip:user@server.com)
@@ -47,50 +43,14 @@
4743
* @param tag (str, optional): A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None.
4844
*
4945
*/
50-
public class SipUri implements OutboundDestination {
46+
public class SipUri extends OutboundDestination {
5147

5248
public static final String TYPE_NAME = "SipUri";
5349

5450
@XmlValue
5551
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
5652
protected String uri;
57-
58-
@XmlAttribute
59-
protected String uui;
60-
61-
@XmlAttribute
62-
protected String username;
63-
64-
@XmlAttribute
65-
protected String password;
66-
67-
@XmlAttribute
68-
protected String fallbackUsername;
69-
70-
@XmlAttribute
71-
protected String fallbackPassword;
72-
73-
@XmlAttribute
74-
protected String transferAnswerUrl;
75-
76-
@XmlAttribute
77-
@Default
78-
protected String transferAnswerMethod = DEFAULT_CALLBACK_METHOD;
79-
80-
@XmlAttribute
81-
protected String transferAnswerFallbackUrl;
82-
83-
@XmlAttribute
84-
@Default
85-
protected String transferAnswerFallbackMethod = DEFAULT_CALLBACK_METHOD;
86-
87-
@XmlAttribute
88-
protected String transferDisconnectUrl;
89-
90-
@XmlAttribute
91-
@Default
92-
protected String transferDisconnectMethod = DEFAULT_CALLBACK_METHOD;
93-
94-
@XmlAttribute
95-
protected String tag;
53+
public String getUri() {
54+
return uri;
55+
}
9656
}

src/test/java/com/bandwidth/sdk/unit/models/bxml/TransferVerbTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class TransferVerbTest {
5959
public void transferVerbWorks() throws JAXBException {
6060
JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class);
6161
String expectedSipUriBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Transfer transferCallerId=\"+19195554321\" callTimeout=\"15.0\" transferCompleteMethod=\"POST\" transferCompleteFallbackMethod=\"POST\" tag=\"test\" diversionTreatment=\"none\" diversionReason=\"unknown\"><SipUri uui=\"test\" transferAnswerUrl=\"https://example.com/webhooks/transfer_answer\" transferAnswerMethod=\"POST\" transferAnswerFallbackMethod=\"POST\" transferDisconnectMethod=\"POST\" tag=\"test\">sip@bw.com</SipUri></Transfer></Bxml>";
62-
String expectedPhoneNumberBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Transfer transferCallerId=\"+19195554321\" transferCallerDisplayName=\"Clark Kent\" callTimeout=\"15.0\" transferCompleteMethod=\"POST\" transferCompleteFallbackMethod=\"POST\" tag=\"test\" diversionTreatment=\"none\" diversionReason=\"unknown\"><PhoneNumber transferAnswerUrl=\"https://example.com/webhooks/transfer_answer\" transferAnswerMethod=\"POST\" transferAnswerFallbackMethod=\"POST\" transferDisconnectMethod=\"POST\" tag=\"test\" uui=\"test\">+19195551234</PhoneNumber></Transfer></Bxml>";
62+
String expectedPhoneNumberBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Transfer transferCallerId=\"+19195554321\" transferCallerDisplayName=\"Clark Kent\" callTimeout=\"15.0\" transferCompleteMethod=\"POST\" transferCompleteFallbackMethod=\"POST\" tag=\"test\" diversionTreatment=\"none\" diversionReason=\"unknown\"><PhoneNumber uui=\"test\" transferAnswerUrl=\"https://example.com/webhooks/transfer_answer\" transferAnswerMethod=\"POST\" transferAnswerFallbackMethod=\"POST\" transferDisconnectMethod=\"POST\" tag=\"test\">+19195551234</PhoneNumber></Transfer></Bxml>";
6363

6464
assertThat(new Bxml().with(transfer1).toBxml(jaxbContext), is(expectedSipUriBxml));
6565
assertThat(new Bxml().with(transfer2).toBxml(jaxbContext), is(expectedPhoneNumberBxml));

0 commit comments

Comments
 (0)