Skip to content

Commit 0a53fd5

Browse files
committed
chore: use add all to make code simpler
Signed-off-by: He-Pin <[email protected]>
1 parent 79ec5b5 commit 0a53fd5

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

mcp/src/main/java/io/modelcontextprotocol/server/McpServer.java

+5-17
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
package io.modelcontextprotocol.server;
66

7-
import java.util.ArrayList;
8-
import java.util.Arrays;
9-
import java.util.HashMap;
10-
import java.util.List;
11-
import java.util.Map;
7+
import java.util.*;
128
import java.util.function.BiConsumer;
139
import java.util.function.BiFunction;
1410

@@ -315,9 +311,7 @@ public AsyncSpecification tools(List<McpServerFeatures.AsyncToolSpecification> t
315311
*/
316312
public AsyncSpecification tools(McpServerFeatures.AsyncToolSpecification... toolSpecifications) {
317313
Assert.notNull(toolSpecifications, "Tool handlers list must not be null");
318-
for (McpServerFeatures.AsyncToolSpecification tool : toolSpecifications) {
319-
this.tools.add(tool);
320-
}
314+
Collections.addAll(this.tools, toolSpecifications);
321315
return this;
322316
}
323317

@@ -413,9 +407,7 @@ public AsyncSpecification resourceTemplates(List<ResourceTemplate> resourceTempl
413407
*/
414408
public AsyncSpecification resourceTemplates(ResourceTemplate... resourceTemplates) {
415409
Assert.notNull(resourceTemplates, "Resource templates must not be null");
416-
for (ResourceTemplate resourceTemplate : resourceTemplates) {
417-
this.resourceTemplates.add(resourceTemplate);
418-
}
410+
Collections.addAll(this.resourceTemplates, resourceTemplates);
419411
return this;
420412
}
421413

@@ -726,9 +718,7 @@ public SyncSpecification tools(List<McpServerFeatures.SyncToolSpecification> too
726718
*/
727719
public SyncSpecification tools(McpServerFeatures.SyncToolSpecification... toolSpecifications) {
728720
Assert.notNull(toolSpecifications, "Tool handlers list must not be null");
729-
for (McpServerFeatures.SyncToolSpecification tool : toolSpecifications) {
730-
this.tools.add(tool);
731-
}
721+
Collections.addAll(this.tools, toolSpecifications);
732722
return this;
733723
}
734724

@@ -824,9 +814,7 @@ public SyncSpecification resourceTemplates(List<ResourceTemplate> resourceTempla
824814
*/
825815
public SyncSpecification resourceTemplates(ResourceTemplate... resourceTemplates) {
826816
Assert.notNull(resourceTemplates, "Resource templates must not be null");
827-
for (ResourceTemplate resourceTemplate : resourceTemplates) {
828-
this.resourceTemplates.add(resourceTemplate);
829-
}
817+
Collections.addAll(this.resourceTemplates, resourceTemplates);
830818
return this;
831819
}
832820

0 commit comments

Comments
 (0)