Skip to content

Commit 4708bf2

Browse files
authored
chore: add checkstyle (#21)
1 parent 1a46d14 commit 4708bf2

36 files changed

Lines changed: 944 additions & 30 deletions

.github/workflows/checkstyle.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: checkstyle
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [ main ]
7+
8+
jobs:
9+
checkstyle:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v6
13+
- uses: actions/setup-java@v5
14+
with:
15+
distribution: 'temurin'
16+
java-version: '17'
17+
- name: Run Checkstyle
18+
run: ./gradlew checkstyleMain checkstyleTest

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
`java-library`
44
`maven-publish`
55
signing
6+
checkstyle
67
id("com.vanniktech.maven.publish") version "0.36.0"
78
}
89

config/checkstyle/checkstyle.xml

Lines changed: 436 additions & 0 deletions
Large diffs are not rendered by default.

config/checkstyle/suppressions.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
3+
<!--
4+
~ Copyright (c) 2022 Microsoft Corporation
5+
~
6+
~ This program and the accompanying materials are made available under the
7+
~ terms of the Apache License, Version 2.0 which is available at
8+
~ https://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ SPDX-License-Identifier: Apache-2.0
11+
~
12+
~ Contributors:
13+
~ Microsoft Corporation - initial API and implementation
14+
~
15+
-->
16+
17+
<!DOCTYPE suppressions PUBLIC
18+
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
19+
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
20+
<suppressions>
21+
<suppress files="package-info.java" checks="[a-zA-Z0-9]*"/>
22+
</suppressions>

src/main/java/org/eclipse/dataplane/Dataplane.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public class Dataplane {
5858
private final Set<String> transferTypes = new HashSet<>();
5959
private final Set<String> labels = new HashSet<>();
6060

61-
private OnPrepare onPrepare = _m -> Result.failure(new UnsupportedOperationException("onPrepare is not implemented"));
62-
private OnStart onStart = _m -> Result.failure(new UnsupportedOperationException("onStart is not implemented"));
63-
private OnTerminate onTerminate = _m -> Result.failure(new UnsupportedOperationException("onTerminate is not implemented"));
64-
private OnSuspend onSuspend = _m -> Result.failure(new UnsupportedOperationException("onSuspend is not implemented"));
65-
private OnStarted onStarted = _m -> Result.failure(new UnsupportedOperationException("onStarted is not implemented"));;
66-
private OnCompleted onCompleted = _m -> Result.failure(new UnsupportedOperationException("onCompleted is not implemented"));
61+
private OnPrepare onPrepare = dataFlow -> Result.failure(new UnsupportedOperationException("onPrepare is not implemented"));
62+
private OnStart onStart = dataFlow -> Result.failure(new UnsupportedOperationException("onStart is not implemented"));
63+
private OnTerminate onTerminate = dataFlow -> Result.failure(new UnsupportedOperationException("onTerminate is not implemented"));
64+
private OnSuspend onSuspend = dataFlow -> Result.failure(new UnsupportedOperationException("onSuspend is not implemented"));
65+
private OnStarted onStarted = dataFlow -> Result.failure(new UnsupportedOperationException("onStarted is not implemented"));
66+
private OnCompleted onCompleted = dataFlow -> Result.failure(new UnsupportedOperationException("onCompleted is not implemented"));
6767

6868
private final HttpClient httpClient = HttpClient.newHttpClient();
6969
private final ObjectMapper objectMapper = new ObjectMapper();
@@ -177,7 +177,7 @@ public Result<Void> terminate(String dataFlowId, DataFlowTerminateMessage messag
177177
/**
178178
* Notify the control plane that the data flow has been completed.
179179
*
180-
* @param dataFlowId
180+
* @param dataFlowId id of the data flow
181181
*/
182182
public Result<Void> notifyCompleted(String dataFlowId) {
183183
return store.findById(dataFlowId)
@@ -205,8 +205,8 @@ public Result<Void> notifyCompleted(String dataFlowId) {
205205
/**
206206
* Notify the control plane that the data flow failed for some reason
207207
*
208-
* @param dataFlowId
209-
* @param throwable
208+
* @param dataFlowId id of the data flow
209+
* @param throwable the error
210210
*/
211211
public Result<Void> notifyErrored(String dataFlowId, Throwable throwable) {
212212
return store.findById(dataFlowId)
@@ -247,8 +247,8 @@ public Result<Void> started(String flowId, DataFlowStartedNotificationMessage st
247247
/**
248248
* Received notification that the flow has been completed
249249
*
250-
* @param flowId
251-
* @return
250+
* @param flowId id of the data flow
251+
* @return result indicating whether data flow was completed successfully
252252
*/
253253
public Result<Void> completed(String flowId) {
254254
return store.findById(flowId).compose(onCompleted::action)

src/main/java/org/eclipse/dataplane/domain/DataAddress.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 Think-it GmbH
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Think-it GmbH - initial API and implementation
12+
*
13+
*/
14+
115
package org.eclipse.dataplane.domain;
216

317
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -15,10 +29,10 @@ public DataAddress(String endpointType, String endpoint, List<EndpointProperty>
1529
this("DataAddress", endpointType, endpoint, endpointProperties);
1630
}
1731

18-
public record EndpointProperty (
19-
String type,
20-
String name,
21-
String value
32+
public record EndpointProperty(
33+
String type,
34+
String name,
35+
String value
2236
) {
2337

2438
}

src/main/java/org/eclipse/dataplane/domain/Result.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 Think-it GmbH
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Think-it GmbH - initial API and implementation
12+
*
13+
*/
14+
115
package org.eclipse.dataplane.domain;
216

317
import java.util.NoSuchElementException;
@@ -13,13 +27,15 @@ public static <C> Result<C> success(C content) {
1327
return new Success<>(content);
1428
}
1529

16-
public static <R> Result<R> failure(Exception e){ return new Failure<>(e); }
30+
public static <R> Result<R> failure(Exception e) {
31+
return new Failure<>(e);
32+
}
1733

1834
public static <R> Result<R> attempt(ExceptionThrowingSupplier<R> resultSupplier) {
1935
try {
2036
var resultValue = resultSupplier.get();
2137
return Result.success(resultValue);
22-
} catch (Exception exception){
38+
} catch (Exception exception) {
2339
return Result.failure(exception);
2440
}
2541
}
@@ -32,7 +48,7 @@ public static <R> Result<R> attempt(ExceptionThrowingSupplier<R> resultSupplier)
3248

3349
public abstract <X extends Throwable> C orElseThrow(Function<Exception, X> exceptionSupplier) throws X;
3450

35-
public abstract <T> Result<T> map(ExceptionThrowingFunction<C,T> transformValue);
51+
public abstract <T> Result<T> map(ExceptionThrowingFunction<C, T> transformValue);
3652

3753
public abstract <T> Result<T> compose(ExceptionThrowingFunction<C, Result<T>> transformValue);
3854

@@ -48,7 +64,7 @@ private static class Success<C> extends Result<C> {
4864

4965
private final C content;
5066

51-
public Success(C content) {
67+
Success(C content) {
5268
this.content = content;
5369
}
5470

@@ -81,7 +97,7 @@ public <T> Result<T> map(ExceptionThrowingFunction<C, T> transformValue) {
8197
public <T> Result<T> compose(ExceptionThrowingFunction<C, Result<T>> transformValue) {
8298
try {
8399
return transformValue.apply(this.content);
84-
} catch(Exception e) {
100+
} catch (Exception e) {
85101
return Result.failure(e);
86102
}
87103
}
@@ -90,6 +106,7 @@ public <T> Result<T> compose(ExceptionThrowingFunction<C, Result<T>> transformVa
90106
private static class Failure<C> extends Result<C> {
91107

92108
private final Exception exception;
109+
93110
private Failure(Exception exception) {
94111
this.exception = exception;
95112
}
@@ -126,7 +143,7 @@ public <T> Result<T> compose(ExceptionThrowingFunction<C, Result<T>> transformVa
126143
}
127144

128145
@FunctionalInterface
129-
public interface ExceptionThrowingFunction<T,R> {
146+
public interface ExceptionThrowingFunction<T, R> {
130147
R apply(T t) throws Exception;
131148
}
132149

src/main/java/org/eclipse/dataplane/domain/dataflow/DataFlowPrepareMessage.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 Think-it GmbH
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Think-it GmbH - initial API and implementation
12+
*
13+
*/
14+
115
package org.eclipse.dataplane.domain.dataflow;
216

317
import java.util.List;

src/main/java/org/eclipse/dataplane/domain/dataflow/DataFlowResponseMessage.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 Think-it GmbH
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Think-it GmbH - initial API and implementation
12+
*
13+
*/
14+
115
package org.eclipse.dataplane.domain.dataflow;
216

317
import org.eclipse.dataplane.domain.DataAddress;

src/main/java/org/eclipse/dataplane/domain/dataflow/DataFlowStartMessage.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 Think-it GmbH
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Think-it GmbH - initial API and implementation
12+
*
13+
*/
14+
115
package org.eclipse.dataplane.domain.dataflow;
216

317
import org.eclipse.dataplane.domain.DataAddress;

0 commit comments

Comments
 (0)