Skip to content

Commit cf87520

Browse files
feat: Shorten builder names in Java (box/box-codegen#742) (#334)
1 parent 8cbb3dc commit cf87520

File tree

1,162 files changed

+7024
-8210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,162 files changed

+7024
-8210
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "7d9efe7", "specHash": "630fc85", "version": "0.7.0" }
1+
{ "engineHash": "f5a9cc9", "specHash": "630fc85", "version": "0.7.0" }

docs/Authentication.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ BoxClient client = new BoxClient(auth);
7878
Otherwise, you'll need to provide the necessary configuration fields directly to the `JWTConfig` constructor:
7979

8080
```java
81-
JWTConfig config = new JWTConfig.JWTConfigBuilder("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "JWT_KEY_ID", "PRIVATE_KEY", "PRIVATE_KEY_PASSWORD")
81+
JWTConfig config = new JWTConfig.Builder("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "JWT_KEY_ID", "PRIVATE_KEY", "PRIVATE_KEY_PASSWORD")
8282
.enterpriseId("123456")
8383
.build();
8484
BoxJWTAuth auth = new BoxJWTAuth(config);
@@ -110,7 +110,7 @@ constructor as in the above examples, similarly to creating a Service Account cl
110110
`userId` instead of `enterpriseId` when constructing the auth config instance:
111111

112112
```java
113-
JWTConfig config = new JWTConfig.JWTConfigBuilder("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "JWT_KEY_ID", "PRIVATE_KEY", "PRIVATE_KEY_PASSWORD")
113+
JWTConfig config = new JWTConfig.Builder("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "JWT_KEY_ID", "PRIVATE_KEY", "PRIVATE_KEY_PASSWORD")
114114
.userId("123456")
115115
.build();
116116
BoxJWTAuth auth = new BoxJWTAuth(config);
@@ -132,7 +132,7 @@ and secret with enterprise or user ID, which allows you to work using service or
132132
You can use `CCGAuth` to initialize a client object the same way as for other authentication types:
133133

134134
```java
135-
CCGConfig config = new CCGConfig.CCGConfigBuilder("YOUR_CLIENT", "YOUR_CLIENT_SECRET")
135+
CCGConfig config = new CCGConfig.Builder("YOUR_CLIENT", "YOUR_CLIENT_SECRET")
136136
.userId("USER_ID")
137137
.build();
138138
BoxCCGAuth auth = new BoxCCGAuth(config);
@@ -153,7 +153,7 @@ are not accessible in any other account by default, and vice versa.
153153
To obtain service account you will have to provide enterprise ID with client id and secret:
154154

155155
```java
156-
CCGConfig config = new CCGConfig.CCGConfigBuilder("YOUR_CLIENT", "YOUR_CLIENT_SECRET")
156+
CCGConfig config = new CCGConfig.Builder("YOUR_CLIENT", "YOUR_CLIENT_SECRET")
157157
.enterpriseId("ENTERPRISE_ID")
158158
.build();
159159
BoxCCGAuth auth = new BoxCCGAuth(config);
@@ -169,7 +169,7 @@ select `Generate user access tokens`. Do not forget to re-authorize application
169169
To obtain user account you will have to provide user ID with client id and secret.
170170

171171
```java
172-
CCGConfig config = new CCGConfig.CCGConfigBuilder("YOUR_CLIENT", "YOUR_CLIENT_SECRET")
172+
CCGConfig config = new CCGConfig.Builder("YOUR_CLIENT", "YOUR_CLIENT_SECRET")
173173
.userId("USER_ID")
174174
.build();
175175
BoxCCGAuth auth = new BoxCCGAuth(config);
@@ -242,7 +242,7 @@ to avoid repeating the authentication process. This can be useful when you want
242242
between runs of your application.
243243

244244
```java
245-
AccessToken accessToken = new AccessToken.AccessTokenBuilder()
245+
AccessToken accessToken = new AccessToken.Builder()
246246
.accessToken("ACCESS_TOKEN")
247247
.refreshToken("REFRESH_TOKEN")
248248
.build();
@@ -358,7 +358,7 @@ TokenStorage customTokenStorage = new TokenStorage() {
358358
}
359359
};
360360

361-
OAuthConfig config = new OAuthConfig.OAuthConfigBuilder("CLIENT_ID", "CLIENT_SECRET")
361+
OAuthConfig config = new OAuthConfig.Builder("CLIENT_ID", "CLIENT_SECRET")
362362
.tokenStorage(customTokenStorage)
363363
.build();
364364
BoxOAuth auth = new BoxOAuth(config);

docs/Client.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The method accepts a `FetchOptions` object as an argument and returns a `FetchRe
3232
The following example demonstrates how to make a custom POST request to create a new folder in the root folder.
3333

3434
```java
35-
FetchOptions fetchOptions = new FetchOptions.FetchOptionsBuilder("https://api.box.com/2.0/users/me", "GET")
35+
FetchOptions fetchOptions = new FetchOptions.Builder("https://api.box.com/2.0/users/me", "GET")
3636
.params(new HashMap<>() {{
3737
put("fields", "name");
3838
}})
@@ -48,14 +48,14 @@ The following example demonstrates how to make a custom multipart request that u
4848

4949
```java
5050
List<MultipartItem> multipartItems = List.of(
51-
new MultipartItem.MultipartItemBuilder("attributes")
51+
new MultipartItem.Builder("attributes")
5252
.data(JsonManager.serialize("{\"name\": \"newFileName\", \"parent\": { \"id\": \"0\" }}"))
5353
.build(),
54-
new MultipartItem.MultipartItemBuilder("file")
54+
new MultipartItem.Builder("file")
5555
.fileStream(new FileInputStream(new File("file.txt")))
5656
.build()
5757
);
58-
FetchOptions fetchOptions = new FetchOptions.FetchOptionsBuilder("https://upload.box.com/api/2.0/files/content", "POST")
58+
FetchOptions fetchOptions = new FetchOptions.Builder("https://upload.box.com/api/2.0/files/content", "POST")
5959
.contentType("multipart/form-data")
6060
.multipartData(multipartItems)
6161
.build();
@@ -71,7 +71,7 @@ The following example demonstrates how to make a custom request that expects a b
7171
It is required to specify the `responseFormat` parameter in the `FetchOptions` object to "binary".
7272

7373
```java
74-
FetchOptions fetchOptions = new FetchOptions.FetchOptionsBuilder("https://upload.box.com/api/2.0/files/12345/content", "GET")
74+
FetchOptions fetchOptions = new FetchOptions.Builder("https://upload.box.com/api/2.0/files/12345/content", "GET")
7575
.responseFormat(ResponseFormat.BINARY)
7676
.build();
7777
FetchResponse response = client.makeRequest(fetchOptions);
@@ -136,7 +136,7 @@ You can also specify the custom base URLs, which will be used for API calls made
136136
Calling the `client.withCustomBaseUrls()` method creates a new client, leaving the original client unmodified.
137137

138138
```java
139-
BaseUrls baseUrls = new BaseUrls.BaseUrlsBuilder()
139+
BaseUrls baseUrls = new BaseUrls.Builder()
140140
.baseUrl("https://new-base-url.com")
141141
.uploadUrl("https://my-company-upload-url.com")
142142
.oauth2Url("https://my-company.com/oauth2")

docs/Configuration.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ To change this number you should initialize `BoxRetryStrategy` with the new valu
1616

1717
```java
1818
BoxDeveloperTokenAuth auth = new BoxDeveloperTokenAuth("DEVELOPER_TOKEN");
19-
NetworkSession session = new NetworkSession.NetworkSessionBuilder()
20-
.retryStrategy(new BoxRetryStrategy.BoxRetryStrategyBuilder().maxAttempts(3).build())
19+
NetworkSession session = new NetworkSession.Builder()
20+
.retryStrategy(new BoxRetryStrategy.Builder().maxAttempts(3).build())
2121
.build();
22-
BoxClient client = new BoxClient.BoxClientBuilder(auth)
22+
BoxClient client = new BoxClient.Builder(auth)
2323
.networkSession(session)
2424
.build();
2525
```
@@ -42,10 +42,10 @@ RetryStrategy customRetryStrategy = new RetryStrategy() {
4242
return 1.0;
4343
}
4444
};
45-
NetworkSession session = new NetworkSession.NetworkSessionBuilder()
45+
NetworkSession session = new NetworkSession.Builder()
4646
.retryStrategy(customRetryStrategy)
4747
.build();
48-
BoxClient client = new BoxClient.BoxClientBuilder(auth)
48+
BoxClient client = new BoxClient.Builder(auth)
4949
.networkSession(session)
5050
.build();
5151
```

docs/ai.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ See the endpoint docs at
1818

1919
<!-- sample post_ai_ask -->
2020
```
21-
client.getAi().createAiAsk(new AiAsk(AiAskModeField.SINGLE_ITEM_QA, "which direction sun rises", Arrays.asList(new AiItemAsk.AiItemAskBuilder(fileToAsk.getId(), AiItemAskTypeField.FILE).content("Sun rises in the East").build())))
21+
client.getAi().createAiAsk(new AiAsk(AiAskModeField.SINGLE_ITEM_QA, "which direction sun rises", Arrays.asList(new AiItemAsk.Builder(fileToAsk.getId(), AiItemAskTypeField.FILE).content("Sun rises in the East").build())))
2222
```
2323

2424
### Arguments
@@ -47,7 +47,7 @@ See the endpoint docs at
4747

4848
<!-- sample post_ai_text_gen -->
4949
```
50-
client.getAi().createAiTextGen(new AiTextGen.AiTextGenBuilder("Parapharse the document.s", Arrays.asList(new AiTextGenItemsField.AiTextGenItemsFieldBuilder(fileToAsk.getId()).type(AiTextGenItemsTypeField.FILE).content("The Earth goes around the sun. Sun rises in the East in the morning.").build())).dialogueHistory(Arrays.asList(new AiDialogueHistory.AiDialogueHistoryBuilder().prompt("What does the earth go around?").answer("The sun").createdAt(dateTimeFromString("2021-01-01T00:00:00Z")).build(), new AiDialogueHistory.AiDialogueHistoryBuilder().prompt("On Earth, where does the sun rise?").answer("East").createdAt(dateTimeFromString("2021-01-01T00:00:00Z")).build())).build())
50+
client.getAi().createAiTextGen(new AiTextGen.Builder("Parapharse the document.s", Arrays.asList(new AiTextGenItemsField.Builder(fileToAsk.getId()).type(AiTextGenItemsTypeField.FILE).content("The Earth goes around the sun. Sun rises in the East in the morning.").build())).dialogueHistory(Arrays.asList(new AiDialogueHistory.Builder().prompt("What does the earth go around?").answer("The sun").createdAt(dateTimeFromString("2021-01-01T00:00:00Z")).build(), new AiDialogueHistory.Builder().prompt("On Earth, where does the sun rise?").answer("East").createdAt(dateTimeFromString("2021-01-01T00:00:00Z")).build())).build())
5151
```
5252

5353
### Arguments
@@ -76,7 +76,7 @@ See the endpoint docs at
7676

7777
<!-- sample get_ai_agent_default -->
7878
```
79-
client.getAi().getAiAgentDefaultConfig(new GetAiAgentDefaultConfigQueryParams.GetAiAgentDefaultConfigQueryParamsBuilder(GetAiAgentDefaultConfigQueryParamsModeField.ASK).language("en-US").build())
79+
client.getAi().getAiAgentDefaultConfig(new GetAiAgentDefaultConfigQueryParams.Builder(GetAiAgentDefaultConfigQueryParamsModeField.ASK).language("en-US").build())
8080
```
8181

8282
### Arguments
@@ -146,7 +146,7 @@ See the endpoint docs at
146146

147147
<!-- sample post_ai_extract_structured -->
148148
```
149-
client.getAi().createAiExtractStructured(new AiExtractStructured.AiExtractStructuredBuilder(Arrays.asList(new AiItemBase(file.getId()))).fields(Arrays.asList(new AiExtractStructuredFieldsField.AiExtractStructuredFieldsFieldBuilder("firstName").description("Person first name").displayName("First name").prompt("What is the your first name?").type("string").build(), new AiExtractStructuredFieldsField.AiExtractStructuredFieldsFieldBuilder("lastName").description("Person last name").displayName("Last name").prompt("What is the your last name?").type("string").build(), new AiExtractStructuredFieldsField.AiExtractStructuredFieldsFieldBuilder("dateOfBirth").description("Person date of birth").displayName("Birth date").prompt("What is the date of your birth?").type("date").build(), new AiExtractStructuredFieldsField.AiExtractStructuredFieldsFieldBuilder("age").description("Person age").displayName("Age").prompt("How old are you?").type("float").build(), new AiExtractStructuredFieldsField.AiExtractStructuredFieldsFieldBuilder("hobby").description("Person hobby").displayName("Hobby").prompt("What is your hobby?").type("multiSelect").options(Arrays.asList(new AiExtractStructuredFieldsOptionsField("guitar"), new AiExtractStructuredFieldsOptionsField("books"))).build())).build())
149+
client.getAi().createAiExtractStructured(new AiExtractStructured.Builder(Arrays.asList(new AiItemBase(file.getId()))).fields(Arrays.asList(new AiExtractStructuredFieldsField.Builder("firstName").description("Person first name").displayName("First name").prompt("What is the your first name?").type("string").build(), new AiExtractStructuredFieldsField.Builder("lastName").description("Person last name").displayName("Last name").prompt("What is the your last name?").type("string").build(), new AiExtractStructuredFieldsField.Builder("dateOfBirth").description("Person date of birth").displayName("Birth date").prompt("What is the date of your birth?").type("date").build(), new AiExtractStructuredFieldsField.Builder("age").description("Person age").displayName("Age").prompt("How old are you?").type("float").build(), new AiExtractStructuredFieldsField.Builder("hobby").description("Person hobby").displayName("Hobby").prompt("What is your hobby?").type("multiSelect").options(Arrays.asList(new AiExtractStructuredFieldsOptionsField("guitar"), new AiExtractStructuredFieldsOptionsField("books"))).build())).build())
150150
```
151151

152152
### Arguments

docs/aistudio.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ See the endpoint docs at
4747

4848
<!-- sample post_ai_agents -->
4949
```
50-
client.getAiStudio().createAiAgent(new CreateAiAgent.CreateAiAgentBuilder(agentName, "enabled").ask(new AiStudioAgentAsk("enabled", "desc1")).build())
50+
client.getAiStudio().createAiAgent(new CreateAiAgent.Builder(agentName, "enabled").ask(new AiStudioAgentAsk("enabled", "desc1")).build())
5151
```
5252

5353
### Arguments
@@ -76,7 +76,7 @@ See the endpoint docs at
7676

7777
<!-- sample put_ai_agents_id -->
7878
```
79-
client.getAiStudio().updateAiAgentById(createdAgent.getId(), new CreateAiAgent.CreateAiAgentBuilder(agentName, "enabled").ask(new AiStudioAgentAsk("disabled", "desc2")).build())
79+
client.getAiStudio().updateAiAgentById(createdAgent.getId(), new CreateAiAgent.Builder(agentName, "enabled").ask(new AiStudioAgentAsk("disabled", "desc2")).build())
8080
```
8181

8282
### Arguments
@@ -107,7 +107,7 @@ See the endpoint docs at
107107

108108
<!-- sample get_ai_agents_id -->
109109
```
110-
client.getAiStudio().getAiAgentById(createdAgent.getId(), new GetAiAgentByIdQueryParams.GetAiAgentByIdQueryParamsBuilder().fields(Arrays.asList("ask")).build())
110+
client.getAiStudio().getAiAgentById(createdAgent.getId(), new GetAiAgentByIdQueryParams.Builder().fields(Arrays.asList("ask")).build())
111111
```
112112

113113
### Arguments

docs/avatars.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ See the endpoint docs at
4747

4848
<!-- sample post_users_id_avatar -->
4949
```
50-
client.getAvatars().createUserAvatar(user.getId(), new CreateUserAvatarRequestBody.CreateUserAvatarRequestBodyBuilder(decodeBase64ByteStream("iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEW10NBjBBbqAAAAH0lEQVRoge3BAQ0AAADCoPdPbQ43oAAAAAAAAAAAvg0hAAABmmDh1QAAAABJRU5ErkJggg==")).picFileName("avatar.png").picContentType("image/png").build())
50+
client.getAvatars().createUserAvatar(user.getId(), new CreateUserAvatarRequestBody.Builder(decodeBase64ByteStream("iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEW10NBjBBbqAAAAH0lEQVRoge3BAQ0AAADCoPdPbQ43oAAAAAAAAAAAvg0hAAABmmDh1QAAAABJRU5ErkJggg==")).picFileName("avatar.png").picContentType("image/png").build())
5151
```
5252

5353
### Arguments

docs/classifications.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ See the endpoint docs at
5656

5757
<!-- sample put_metadata_templates_enterprise_securityClassification-6VMVochwUWo_schema#add -->
5858
```
59-
client.getClassifications().addClassification(Arrays.asList(new AddClassificationRequestBody(new AddClassificationRequestBodyDataField.AddClassificationRequestBodyDataFieldBuilder(getUuid()).staticConfig(new AddClassificationRequestBodyDataStaticConfigField.AddClassificationRequestBodyDataStaticConfigFieldBuilder().classification(new AddClassificationRequestBodyDataStaticConfigClassificationField.AddClassificationRequestBodyDataStaticConfigClassificationFieldBuilder().classificationDefinition("Other description").colorId(4L).build()).build()).build())))
59+
client.getClassifications().addClassification(Arrays.asList(new AddClassificationRequestBody(new AddClassificationRequestBodyDataField.Builder(getUuid()).staticConfig(new AddClassificationRequestBodyDataStaticConfigField.Builder().classification(new AddClassificationRequestBodyDataStaticConfigClassificationField.Builder().classificationDefinition("Other description").colorId(4L).build()).build()).build())))
6060
```
6161

6262
### Arguments
@@ -92,7 +92,7 @@ See the endpoint docs at
9292

9393
<!-- sample put_metadata_templates_enterprise_securityClassification-6VMVochwUWo_schema#update -->
9494
```
95-
client.getClassifications().updateClassification(Arrays.asList(new UpdateClassificationRequestBody(classification.getKey(), new UpdateClassificationRequestBodyDataField.UpdateClassificationRequestBodyDataFieldBuilder(updatedClassificationName).staticConfig(new UpdateClassificationRequestBodyDataStaticConfigField.UpdateClassificationRequestBodyDataStaticConfigFieldBuilder().classification(new UpdateClassificationRequestBodyDataStaticConfigClassificationField.UpdateClassificationRequestBodyDataStaticConfigClassificationFieldBuilder().classificationDefinition(updatedClassificationDescription).colorId(2L).build()).build()).build())))
95+
client.getClassifications().updateClassification(Arrays.asList(new UpdateClassificationRequestBody(classification.getKey(), new UpdateClassificationRequestBodyDataField.Builder(updatedClassificationName).staticConfig(new UpdateClassificationRequestBodyDataStaticConfigField.Builder().classification(new UpdateClassificationRequestBodyDataStaticConfigClassificationField.Builder().classificationDefinition(updatedClassificationDescription).colorId(2L).build()).build()).build())))
9696
```
9797

9898
### Arguments

docs/comments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ See the endpoint docs at
8282

8383
<!-- sample put_comments_id -->
8484
```
85-
client.getComments().updateCommentById(newReplyComment.getId(), new UpdateCommentByIdRequestBody.UpdateCommentByIdRequestBodyBuilder().message(newMessage).build())
85+
client.getComments().updateCommentById(newReplyComment.getId(), new UpdateCommentByIdRequestBody.Builder().message(newMessage).build())
8686
```
8787

8888
### Arguments

docs/docgen.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ See the endpoint docs at
4646

4747
<!-- sample get_docgen_jobs_v2025.0 -->
4848
```
49-
client.getDocgen().getDocgenJobsV2025R0(new GetDocgenJobsV2025R0QueryParams.GetDocgenJobsV2025R0QueryParamsBuilder().limit(500L).build())
49+
client.getDocgen().getDocgenJobsV2025R0(new GetDocgenJobsV2025R0QueryParams.Builder().limit(500L).build())
5050
```
5151

5252
### Arguments

0 commit comments

Comments
 (0)