Skip to content

Commit 8662d36

Browse files
authored
Merge pull request #129 from tsurdilo/addformatter
Adding Google code style guide plugin
2 parents a8ff9b8 + d7b13cd commit 8662d36

File tree

95 files changed

+4362
-4264
lines changed

Some content is hidden

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

95 files changed

+4362
-4264
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ git clone https://github.com/serverlessworkflow/sdk-java.git
3434
mvn clean install
3535
```
3636

37+
The project uses [Google's code styleguide](https://google.github.io/styleguide/javaguide.html).
38+
Your changes should be automatically formatted during the build.
39+
3740
To use it in your projects you can:
3841

3942
#### Maven projects:

api/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,26 @@
152152
</execution>
153153
</executions>
154154
</plugin>
155+
<plugin>
156+
<groupId>com.coveo</groupId>
157+
<artifactId>fmt-maven-plugin</artifactId>
158+
<configuration>
159+
<sourceDirectory>src/main/java</sourceDirectory>
160+
<testSourceDirectory>src/test/java</testSourceDirectory>
161+
<verbose>false</verbose>
162+
<filesNamePattern>.*\.java</filesNamePattern>
163+
<skip>false</skip>
164+
<skipSortingImports>false</skipSortingImports>
165+
<style>google</style>
166+
</configuration>
167+
<executions>
168+
<execution>
169+
<goals>
170+
<goal>format</goal>
171+
</goals>
172+
</execution>
173+
</executions>
174+
</plugin>
155175
</plugins>
156176
</build>
157177
</project>

api/src/main/java/io/serverlessworkflow/api/deserializers/AuthDefinitionDeserializer.java

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,58 +25,56 @@
2525
import io.serverlessworkflow.api.auth.BearerAuthDefinition;
2626
import io.serverlessworkflow.api.auth.OauthDefinition;
2727
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
28-
2928
import java.io.IOException;
3029

3130
public class AuthDefinitionDeserializer extends StdDeserializer<AuthDefinition> {
3231

33-
private static final long serialVersionUID = 510l;
34-
35-
@SuppressWarnings("unused")
36-
private WorkflowPropertySource context;
32+
private static final long serialVersionUID = 510l;
3733

38-
public AuthDefinitionDeserializer() {
39-
this(AuthDefinition.class);
40-
}
34+
@SuppressWarnings("unused")
35+
private WorkflowPropertySource context;
4136

42-
public AuthDefinitionDeserializer(Class<?> vc) {
43-
super(vc);
44-
}
37+
public AuthDefinitionDeserializer() {
38+
this(AuthDefinition.class);
39+
}
4540

46-
public AuthDefinitionDeserializer(WorkflowPropertySource context) {
47-
this(AuthDefinition.class);
48-
this.context = context;
49-
}
41+
public AuthDefinitionDeserializer(Class<?> vc) {
42+
super(vc);
43+
}
5044

51-
@Override
52-
public AuthDefinition deserialize(JsonParser jp,
53-
DeserializationContext ctxt) throws IOException {
45+
public AuthDefinitionDeserializer(WorkflowPropertySource context) {
46+
this(AuthDefinition.class);
47+
this.context = context;
48+
}
5449

55-
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
56-
JsonNode node = jp.getCodec().readTree(jp);
50+
@Override
51+
public AuthDefinition deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
5752

58-
AuthDefinition authDefinition = new AuthDefinition();
53+
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
54+
JsonNode node = jp.getCodec().readTree(jp);
5955

60-
if(node.get("name") != null) {
61-
authDefinition.setName(node.get("name").asText());
62-
}
56+
AuthDefinition authDefinition = new AuthDefinition();
6357

64-
if(node.get("scheme") != null) {
65-
authDefinition.setScheme(AuthDefinition.Scheme.fromValue(node.get("scheme").asText()));
66-
}
58+
if (node.get("name") != null) {
59+
authDefinition.setName(node.get("name").asText());
60+
}
6761

68-
if(node.get("properties") != null) {
69-
JsonNode propsNode = node.get("properties");
62+
if (node.get("scheme") != null) {
63+
authDefinition.setScheme(AuthDefinition.Scheme.fromValue(node.get("scheme").asText()));
64+
}
7065

71-
if(propsNode.get("grantType") != null) {
72-
authDefinition.setOauth(mapper.treeToValue(propsNode, OauthDefinition.class));
73-
} else if(propsNode.get("token") != null) {
74-
authDefinition.setBearerauth(mapper.treeToValue(propsNode, BearerAuthDefinition.class));
75-
} else {
76-
authDefinition.setBasicauth(mapper.treeToValue(propsNode, BasicAuthDefinition.class));
77-
}
78-
}
66+
if (node.get("properties") != null) {
67+
JsonNode propsNode = node.get("properties");
7968

80-
return authDefinition;
69+
if (propsNode.get("grantType") != null) {
70+
authDefinition.setOauth(mapper.treeToValue(propsNode, OauthDefinition.class));
71+
} else if (propsNode.get("token") != null) {
72+
authDefinition.setBearerauth(mapper.treeToValue(propsNode, BearerAuthDefinition.class));
73+
} else {
74+
authDefinition.setBasicauth(mapper.treeToValue(propsNode, BasicAuthDefinition.class));
75+
}
8176
}
77+
78+
return authDefinition;
79+
}
8280
}

api/src/main/java/io/serverlessworkflow/api/deserializers/ConstantsDeserializer.java

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,78 +24,74 @@
2424
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
2525
import io.serverlessworkflow.api.utils.Utils;
2626
import io.serverlessworkflow.api.workflow.Constants;
27+
import java.io.IOException;
2728
import org.json.JSONObject;
2829
import org.slf4j.Logger;
2930
import org.slf4j.LoggerFactory;
3031

31-
import java.io.IOException;
32-
import java.util.ArrayList;
33-
import java.util.List;
32+
public class ConstantsDeserializer extends StdDeserializer<Constants> {
3433

35-
public class ConstantsDeserializer extends StdDeserializer<Constants> {
34+
private static final long serialVersionUID = 510l;
35+
private static Logger logger = LoggerFactory.getLogger(ConstantsDeserializer.class);
3636

37-
private static final long serialVersionUID = 510l;
38-
private static Logger logger = LoggerFactory.getLogger(ConstantsDeserializer.class);
37+
@SuppressWarnings("unused")
38+
private WorkflowPropertySource context;
3939

40-
@SuppressWarnings("unused")
41-
private WorkflowPropertySource context;
40+
public ConstantsDeserializer() {
41+
this(Constants.class);
42+
}
4243

43-
public ConstantsDeserializer() {
44-
this(Constants.class);
45-
}
44+
public ConstantsDeserializer(Class<?> vc) {
45+
super(vc);
46+
}
4647

47-
public ConstantsDeserializer(Class<?> vc) {
48-
super(vc);
49-
}
48+
public ConstantsDeserializer(WorkflowPropertySource context) {
49+
this(Constants.class);
50+
this.context = context;
51+
}
5052

51-
public ConstantsDeserializer(WorkflowPropertySource context) {
52-
this(Constants.class);
53-
this.context = context;
54-
}
53+
@Override
54+
public Constants deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
5555

56-
@Override
57-
public Constants deserialize(JsonParser jp,
58-
DeserializationContext ctxt) throws IOException {
56+
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
57+
JsonNode node = jp.getCodec().readTree(jp);
5958

60-
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
61-
JsonNode node = jp.getCodec().readTree(jp);
59+
Constants constants = new Constants();
60+
JsonNode constantsDefinition = null;
6261

63-
Constants constants = new Constants();
64-
JsonNode constantsDefinition = null;
62+
if (node.isObject()) {
63+
constantsDefinition = node;
64+
} else {
65+
String constantsFileDef = node.asText();
66+
String constantsFileSrc = Utils.getResourceFileAsString(constantsFileDef);
67+
JsonNode constantsRefNode;
68+
ObjectMapper jsonWriter = new ObjectMapper();
69+
if (constantsFileSrc != null && constantsFileSrc.trim().length() > 0) {
70+
// if its a yaml def convert to json first
71+
if (!constantsFileSrc.trim().startsWith("{")) {
72+
// convert yaml to json to validate
73+
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
74+
Object obj = yamlReader.readValue(constantsFileSrc, Object.class);
6575

66-
if (node.isObject()) {
67-
constantsDefinition = node;
76+
constantsRefNode =
77+
jsonWriter.readTree(new JSONObject(jsonWriter.writeValueAsString(obj)).toString());
6878
} else {
69-
String constantsFileDef = node.asText();
70-
String constantsFileSrc = Utils.getResourceFileAsString(constantsFileDef);
71-
JsonNode constantsRefNode;
72-
ObjectMapper jsonWriter = new ObjectMapper();
73-
if (constantsFileSrc != null && constantsFileSrc.trim().length() > 0) {
74-
// if its a yaml def convert to json first
75-
if (!constantsFileSrc.trim().startsWith("{")) {
76-
// convert yaml to json to validate
77-
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
78-
Object obj = yamlReader.readValue(constantsFileSrc, Object.class);
79-
80-
constantsRefNode = jsonWriter.readTree(new JSONObject(jsonWriter.writeValueAsString(obj)).toString());
81-
} else {
82-
constantsRefNode = jsonWriter.readTree(new JSONObject(constantsFileSrc).toString());
83-
}
84-
85-
JsonNode refConstants = constantsRefNode.get("constants");
86-
if (refConstants != null) {
87-
constantsDefinition = refConstants;
88-
} else {
89-
logger.error("Unable to find constants definitions in reference file: {}", constantsFileSrc);
90-
}
91-
92-
} else {
93-
logger.error("Unable to load constants defs reference file: {}", constantsFileSrc);
94-
}
79+
constantsRefNode = jsonWriter.readTree(new JSONObject(constantsFileSrc).toString());
80+
}
9581

82+
JsonNode refConstants = constantsRefNode.get("constants");
83+
if (refConstants != null) {
84+
constantsDefinition = refConstants;
85+
} else {
86+
logger.error(
87+
"Unable to find constants definitions in reference file: {}", constantsFileSrc);
9688
}
97-
constants.setConstantsDef(constantsDefinition);
98-
return constants;
9989

90+
} else {
91+
logger.error("Unable to load constants defs reference file: {}", constantsFileSrc);
92+
}
10093
}
101-
}
94+
constants.setConstantsDef(constantsDefinition);
95+
return constants;
96+
}
97+
}

api/src/main/java/io/serverlessworkflow/api/deserializers/ContinueAsDeserializer.java

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,63 +23,61 @@
2323
import io.serverlessworkflow.api.end.ContinueAs;
2424
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
2525
import io.serverlessworkflow.api.timeouts.WorkflowExecTimeout;
26-
2726
import java.io.IOException;
2827

2928
public class ContinueAsDeserializer extends StdDeserializer<ContinueAs> {
3029

31-
private static final long serialVersionUID = 510l;
30+
private static final long serialVersionUID = 510l;
3231

33-
@SuppressWarnings("unused")
34-
private WorkflowPropertySource context;
32+
@SuppressWarnings("unused")
33+
private WorkflowPropertySource context;
3534

36-
public ContinueAsDeserializer() {
37-
this(ContinueAs.class);
38-
}
35+
public ContinueAsDeserializer() {
36+
this(ContinueAs.class);
37+
}
3938

40-
public ContinueAsDeserializer(Class<?> vc) {
41-
super(vc);
42-
}
39+
public ContinueAsDeserializer(Class<?> vc) {
40+
super(vc);
41+
}
4342

44-
public ContinueAsDeserializer(WorkflowPropertySource context) {
45-
this(ContinueAs.class);
46-
this.context = context;
47-
}
43+
public ContinueAsDeserializer(WorkflowPropertySource context) {
44+
this(ContinueAs.class);
45+
this.context = context;
46+
}
4847

49-
@Override
50-
public ContinueAs deserialize(JsonParser jp,
51-
DeserializationContext ctxt) throws IOException {
48+
@Override
49+
public ContinueAs deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
5250

53-
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
54-
JsonNode node = jp.getCodec().readTree(jp);
51+
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
52+
JsonNode node = jp.getCodec().readTree(jp);
5553

56-
ContinueAs continueAs = new ContinueAs();
54+
ContinueAs continueAs = new ContinueAs();
5755

58-
if (!node.isObject()) {
59-
continueAs.setWorkflowId(node.asText());
60-
continueAs.setVersion(null);
61-
continueAs.setData(null);
62-
continueAs.setWorkflowExecTimeout(null);
63-
return continueAs;
64-
} else {
65-
if (node.get("workflowId") != null) {
66-
continueAs.setWorkflowId(node.get("workflowId").asText());
67-
}
56+
if (!node.isObject()) {
57+
continueAs.setWorkflowId(node.asText());
58+
continueAs.setVersion(null);
59+
continueAs.setData(null);
60+
continueAs.setWorkflowExecTimeout(null);
61+
return continueAs;
62+
} else {
63+
if (node.get("workflowId") != null) {
64+
continueAs.setWorkflowId(node.get("workflowId").asText());
65+
}
6866

69-
if (node.get("version") != null) {
70-
continueAs.setVersion(node.get("version").asText());
71-
}
67+
if (node.get("version") != null) {
68+
continueAs.setVersion(node.get("version").asText());
69+
}
7270

73-
if (node.get("data") != null) {
74-
continueAs.setData(node.get("data").asText());
75-
}
71+
if (node.get("data") != null) {
72+
continueAs.setData(node.get("data").asText());
73+
}
7674

77-
if (node.get("workflowExecTimeout") != null) {
78-
continueAs.setWorkflowExecTimeout(mapper.treeToValue(node.get("workflowExecTimeout"), WorkflowExecTimeout.class));
79-
}
75+
if (node.get("workflowExecTimeout") != null) {
76+
continueAs.setWorkflowExecTimeout(
77+
mapper.treeToValue(node.get("workflowExecTimeout"), WorkflowExecTimeout.class));
78+
}
8079

81-
return continueAs;
82-
}
80+
return continueAs;
8381
}
82+
}
8483
}
85-

0 commit comments

Comments
 (0)