Skip to content

Commit a6a92fd

Browse files
authored
Apply google-java-format to codebase
2 parents d19ed6a + 40d9175 commit a6a92fd

File tree

2,379 files changed

+531124
-360458
lines changed

Some content is hidden

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

2,379 files changed

+531124
-360458
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# google-java-format
2+
38459f0d42dfc6de2b74de6d784017b5f38fa763
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: check google-java-format
2+
3+
on:
4+
push:
5+
branches:
6+
- 'dev/1.0'
7+
pull_request:
8+
branches:
9+
- 'dev/1.0'
10+
11+
jobs:
12+
formatting:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: axel-op/[email protected]
17+
with:
18+
args: "--set-exit-if-changed"

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ You can find all the details in the [Contributing via Git](http://wiki.eclipse.o
4848
* Make sure you include test cases for non-trivial features
4949
* Make sure the test suite passes after your changes
5050
* Make sure checkstyle passes after your changes
51+
* Apply `google-java-format` (see https://github.com/google/google-java-format)
5152
* Commit your changes into that branch
5253
* Use descriptive and meaningful commit messages
5354
* If you have a lot of commits squash them into a single commit
@@ -68,7 +69,7 @@ Please make sure new source files have license header like this:
6869

6970
````
7071
/*
71-
* Copyright (c) 2019 the Eclipse Milo Authors
72+
* Copyright (c) 2025 the Eclipse Milo Authors
7273
*
7374
* This program and the accompanying materials are made
7475
* available under the terms of the Eclipse Public License 2.0

config/checkstyle/checkstyle.xml

Lines changed: 450 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
~ Copyright (c) 2022 the Eclipse Milo Authors
3+
~ Copyright (c) 2024 the Eclipse Milo Authors
44
~
55
~ This program and the accompanying materials are made
66
~ available under the terms of the Eclipse Public License 2.0
@@ -9,71 +9,72 @@
99
~ SPDX-License-Identifier: EPL-2.0
1010
-->
1111

12-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
14-
<modelVersion>4.0.0</modelVersion>
12+
<project xmlns="http://maven.apache.org/POM/4.0.0"
13+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
14+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
15+
<modelVersion>4.0.0</modelVersion>
1516

16-
<parent>
17-
<groupId>org.eclipse.milo</groupId>
18-
<artifactId>milo-examples</artifactId>
19-
<version>1.0.0-SNAPSHOT</version>
20-
</parent>
17+
<parent>
18+
<groupId>org.eclipse.milo</groupId>
19+
<artifactId>milo-examples</artifactId>
20+
<version>1.0.0-SNAPSHOT</version>
21+
</parent>
2122

22-
<artifactId>milo-client-examples</artifactId>
23+
<artifactId>milo-client-examples</artifactId>
2324

24-
<properties>
25-
<javaModuleName>org.eclipse.milo.examples.client</javaModuleName>
26-
</properties>
25+
<properties>
26+
<javaModuleName>org.eclipse.milo.examples.client</javaModuleName>
27+
</properties>
2728

28-
<dependencies>
29-
<dependency>
30-
<groupId>org.eclipse.milo</groupId>
31-
<artifactId>milo-sdk-client</artifactId>
32-
<version>${project.version}</version>
33-
</dependency>
34-
<dependency>
35-
<groupId>org.eclipse.milo</groupId>
36-
<artifactId>milo-codec-json</artifactId>
37-
<version>${project.version}</version>
38-
</dependency>
39-
<dependency>
40-
<groupId>org.eclipse.milo</groupId>
41-
<artifactId>milo-dtd-reader</artifactId>
42-
<version>${project.version}</version>
43-
</dependency>
44-
<dependency>
45-
<groupId>org.eclipse.milo</groupId>
46-
<artifactId>milo-server-examples</artifactId>
47-
<version>${project.version}</version>
48-
</dependency>
49-
<dependency>
50-
<groupId>org.slf4j</groupId>
51-
<artifactId>slf4j-simple</artifactId>
52-
<version>${slf4j.version}</version>
53-
</dependency>
54-
<dependency>
55-
<groupId>org.jetbrains</groupId>
56-
<artifactId>annotations</artifactId>
57-
<version>${jetbrains-annotations.version}</version>
58-
<scope>provided</scope>
59-
</dependency>
60-
</dependencies>
29+
<dependencies>
30+
<dependency>
31+
<groupId>org.eclipse.milo</groupId>
32+
<artifactId>milo-sdk-client</artifactId>
33+
<version>${project.version}</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.eclipse.milo</groupId>
37+
<artifactId>milo-codec-json</artifactId>
38+
<version>${project.version}</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.eclipse.milo</groupId>
42+
<artifactId>milo-dtd-reader</artifactId>
43+
<version>${project.version}</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.eclipse.milo</groupId>
47+
<artifactId>milo-server-examples</artifactId>
48+
<version>${project.version}</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.slf4j</groupId>
52+
<artifactId>slf4j-simple</artifactId>
53+
<version>${slf4j.version}</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.jetbrains</groupId>
57+
<artifactId>annotations</artifactId>
58+
<version>${jetbrains-annotations.version}</version>
59+
<scope>provided</scope>
60+
</dependency>
61+
</dependencies>
6162

6263

63-
<build>
64-
<plugins>
65-
<plugin>
66-
<groupId>org.apache.maven.plugins</groupId>
67-
<artifactId>maven-deploy-plugin</artifactId>
68-
<configuration>
69-
<skip>true</skip>
70-
</configuration>
71-
</plugin>
72-
<plugin>
73-
<groupId>org.apache.maven.plugins</groupId>
74-
<artifactId>maven-shade-plugin</artifactId>
75-
</plugin>
76-
</plugins>
77-
</build>
64+
<build>
65+
<plugins>
66+
<plugin>
67+
<groupId>org.apache.maven.plugins</groupId>
68+
<artifactId>maven-deploy-plugin</artifactId>
69+
<configuration>
70+
<skip>true</skip>
71+
</configuration>
72+
</plugin>
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-shade-plugin</artifactId>
76+
</plugin>
77+
</plugins>
78+
</build>
7879

7980
</project>
Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 the Eclipse Milo Authors
2+
* Copyright (c) 2024 the Eclipse Milo Authors
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -10,14 +10,13 @@
1010

1111
package org.eclipse.milo.examples.client;
1212

13+
import com.google.common.base.MoreObjects;
1314
import java.util.List;
1415
import java.util.concurrent.CompletableFuture;
1516
import java.util.concurrent.CopyOnWriteArrayList;
1617
import java.util.concurrent.TimeUnit;
1718
import java.util.function.BiConsumer;
1819
import java.util.stream.Stream;
19-
20-
import com.google.common.base.MoreObjects;
2120
import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
2221
import org.eclipse.milo.opcua.sdk.client.nodes.UaNode;
2322
import org.eclipse.milo.opcua.stack.core.NodeIds;
@@ -26,82 +25,84 @@
2625

2726
public class BrowseAsyncExample implements ClientExample {
2827

29-
public static void main(String[] args) throws Exception {
30-
BrowseAsyncExample example = new BrowseAsyncExample();
28+
public static void main(String[] args) throws Exception {
29+
BrowseAsyncExample example = new BrowseAsyncExample();
3130

32-
new ClientExampleRunner(example).run();
33-
}
34-
35-
private final Logger logger = LoggerFactory.getLogger(getClass());
36-
37-
@Override
38-
public void run(OpcUaClient client, CompletableFuture<OpcUaClient> future) throws Exception {
39-
client.connect();
31+
new ClientExampleRunner(example).run();
32+
}
4033

41-
// start browsing at root folder
42-
UaNode rootNode = client.getAddressSpace().getNode(NodeIds.RootFolder);
34+
private final Logger logger = LoggerFactory.getLogger(getClass());
4335

44-
Tree<UaNode> tree = new Tree<>(rootNode);
36+
@Override
37+
public void run(OpcUaClient client, CompletableFuture<OpcUaClient> future) throws Exception {
38+
client.connect();
4539

46-
long startTime = System.nanoTime();
47-
browseRecursive(client, tree).get();
48-
long endTime = System.nanoTime();
40+
// start browsing at root folder
41+
UaNode rootNode = client.getAddressSpace().getNode(NodeIds.RootFolder);
4942

50-
traverse(tree, 0, (depth, n) -> logger.info(indent(depth) + n.getBrowseName().getName()));
43+
Tree<UaNode> tree = new Tree<>(rootNode);
5144

52-
logger.info(
53-
"Browse took {}ms",
54-
TimeUnit.MILLISECONDS.convert(endTime - startTime, TimeUnit.NANOSECONDS));
45+
long startTime = System.nanoTime();
46+
browseRecursive(client, tree).get();
47+
long endTime = System.nanoTime();
5548

56-
future.complete(client);
57-
}
49+
traverse(tree, 0, (depth, n) -> logger.info(indent(depth) + n.getBrowseName().getName()));
5850

59-
private CompletableFuture<Void> browseRecursive(OpcUaClient client, Tree<UaNode> tree) {
60-
return client.getAddressSpace().browseNodesAsync(tree.node).thenCompose(nodes -> {
61-
// Add each child node to the tree
62-
nodes.forEach(tree::addChild);
51+
logger.info(
52+
"Browse took {}ms",
53+
TimeUnit.MILLISECONDS.convert(endTime - startTime, TimeUnit.NANOSECONDS));
6354

64-
// For each child node browse for its children
65-
Stream<CompletableFuture<Void>> futures =
66-
tree.children.stream().map(child -> browseRecursive(client, child));
55+
future.complete(client);
56+
}
6757

68-
// Return a CompletableFuture that completes when the child browses complete
69-
return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
70-
});
71-
}
58+
private CompletableFuture<Void> browseRecursive(OpcUaClient client, Tree<UaNode> tree) {
59+
return client
60+
.getAddressSpace()
61+
.browseNodesAsync(tree.node)
62+
.thenCompose(
63+
nodes -> {
64+
// Add each child node to the tree
65+
nodes.forEach(tree::addChild);
7266

73-
private static String indent(int depth) {
74-
return " ".repeat(Math.max(0, depth));
75-
}
67+
// For each child node browse for its children
68+
Stream<CompletableFuture<Void>> futures =
69+
tree.children.stream().map(child -> browseRecursive(client, child));
7670

77-
private static <T> void traverse(Tree<T> tree, int depth, BiConsumer<Integer, T> consumer) {
78-
consumer.accept(depth, tree.node);
71+
// Return a CompletableFuture that completes when the child browses complete
72+
return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
73+
});
74+
}
7975

80-
tree.children.forEach(child -> traverse(child, depth + 1, consumer));
81-
}
76+
private static String indent(int depth) {
77+
return " ".repeat(Math.max(0, depth));
78+
}
8279

83-
private static class Tree<T> {
80+
private static <T> void traverse(Tree<T> tree, int depth, BiConsumer<Integer, T> consumer) {
81+
consumer.accept(depth, tree.node);
8482

85-
final List<Tree<T>> children = new CopyOnWriteArrayList<>();
83+
tree.children.forEach(child -> traverse(child, depth + 1, consumer));
84+
}
8685

87-
final T node;
86+
private static class Tree<T> {
8887

89-
Tree(T node) {
90-
this.node = node;
91-
}
88+
final List<Tree<T>> children = new CopyOnWriteArrayList<>();
9289

93-
void addChild(T child) {
94-
children.add(new Tree<>(child));
95-
}
90+
final T node;
9691

97-
@Override
98-
public String toString() {
99-
return MoreObjects.toStringHelper(this)
100-
.add("node", node)
101-
.add("children", children)
102-
.toString();
103-
}
92+
Tree(T node) {
93+
this.node = node;
94+
}
10495

96+
void addChild(T child) {
97+
children.add(new Tree<>(child));
10598
}
10699

100+
@Override
101+
public String toString() {
102+
return MoreObjects.toStringHelper(this)
103+
.add("node", node)
104+
.add("children", children)
105+
.toString();
106+
}
107+
}
107108
}

0 commit comments

Comments
 (0)