Skip to content

Commit 1a9b92d

Browse files
authored
Added Google java formatter (#120)
* Added google-java-format to build.gradle * Reformatted by google java formatter
1 parent f3c96d7 commit 1a9b92d

File tree

162 files changed

+18007
-16960
lines changed

Some content is hidden

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

162 files changed

+18007
-16960
lines changed

build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ buildscript {
66

77
plugins {
88
id 'net.minecrell.licenser' version '0.3'
9+
id "com.github.sherter.google-java-format" version "0.6"
910
}
1011

1112
repositories {
@@ -19,6 +20,13 @@ apply plugin: 'java'
1920
apply plugin: 'maven'
2021
apply plugin: "org.jruyi.thrift"
2122
apply plugin: 'maven-publish'
23+
apply plugin: 'com.github.sherter.google-java-format'
24+
25+
googleJavaFormat {
26+
toolVersion '1.3'
27+
include '**/*.java'
28+
exclude '**/generated-sources/*'
29+
}
2230

2331
group = 'com.uber'
2432
version = '0.2.0-SNAPSHOT'

src/main/java/com/uber/cadence/activity/Activity.java

Lines changed: 85 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -22,108 +22,103 @@
2222
import com.uber.cadence.internal.sync.WorkflowInternal;
2323
import com.uber.cadence.workflow.ActivityException;
2424
import com.uber.cadence.workflow.ActivityTimeoutException;
25-
2625
import java.util.concurrent.CancellationException;
2726

2827
/**
29-
* Use this method from within activity implementation to get information about activity task
30-
* and heartbeat.
28+
* Use this method from within activity implementation to get information about activity task and
29+
* heartbeat.
3130
*/
3231
public final class Activity {
3332

34-
/**
35-
* If this method is called during an activity execution then activity is not going to complete
36-
* when its method returns. It is expected to be completed asynchronously using
37-
* {@link com.uber.cadence.client.ActivityCompletionClient}.
38-
*/
39-
public static void doNotCompleteOnReturn() {
40-
ActivityInternal.doNotCompleteOnReturn();
41-
}
33+
/**
34+
* If this method is called during an activity execution then activity is not going to complete
35+
* when its method returns. It is expected to be completed asynchronously using {@link
36+
* com.uber.cadence.client.ActivityCompletionClient}.
37+
*/
38+
public static void doNotCompleteOnReturn() {
39+
ActivityInternal.doNotCompleteOnReturn();
40+
}
4241

43-
/**
44-
* @return task token that is required to report task completion when
45-
* manual activity completion is used.
46-
*/
47-
public static byte[] getTaskToken() {
48-
return ActivityInternal.getTask().getTaskToken();
49-
}
42+
/**
43+
* @return task token that is required to report task completion when manual activity completion
44+
* is used.
45+
*/
46+
public static byte[] getTaskToken() {
47+
return ActivityInternal.getTask().getTaskToken();
48+
}
5049

51-
/**
52-
* @return workfow execution that requested the activity execution
53-
*/
54-
public static com.uber.cadence.WorkflowExecution getWorkflowExecution() {
55-
return ActivityInternal.getTask().getWorkflowExecution();
56-
}
50+
/** @return workfow execution that requested the activity execution */
51+
public static com.uber.cadence.WorkflowExecution getWorkflowExecution() {
52+
return ActivityInternal.getTask().getWorkflowExecution();
53+
}
5754

58-
/**
59-
* @return task that caused activity execution
60-
*/
61-
public static ActivityTask getTask() {
62-
return ActivityInternal.getTask();
63-
}
55+
/** @return task that caused activity execution */
56+
public static ActivityTask getTask() {
57+
return ActivityInternal.getTask();
58+
}
6459

65-
/**
66-
* Use to notify Cadence service that activity execution is alive.
67-
*
68-
* @param details In case of activity timeout can be accessed through
69-
* {@link ActivityTimeoutException#getDetails(Class)} method.
70-
* @throws CancellationException Indicates that activity cancellation was requested by the
71-
* workflow.Should be rethrown from activity implementation to
72-
* indicate successful cancellation.
73-
*/
74-
public static void heartbeat(Object details) throws CancellationException {
75-
ActivityInternal.recordActivityHeartbeat(details);
76-
}
60+
/**
61+
* Use to notify Cadence service that activity execution is alive.
62+
*
63+
* @param details In case of activity timeout can be accessed through {@link
64+
* ActivityTimeoutException#getDetails(Class)} method.
65+
* @throws CancellationException Indicates that activity cancellation was requested by the
66+
* workflow.Should be rethrown from activity implementation to indicate successful
67+
* cancellation.
68+
*/
69+
public static void heartbeat(Object details) throws CancellationException {
70+
ActivityInternal.recordActivityHeartbeat(details);
71+
}
7772

78-
/**
79-
* @return an instance of the Simple Workflow Java client that is the same
80-
* used by the invoked activity worker. It can be useful if activity wants to use WorkflowClient for
81-
* some operations like sending signal to its parent workflow.
82-
* @TODO getWorkflowClient method to hide the service.
83-
*/
84-
public static WorkflowService.Iface getService() {
85-
return ActivityInternal.getService();
86-
}
73+
/**
74+
* @return an instance of the Simple Workflow Java client that is the same used by the invoked
75+
* activity worker. It can be useful if activity wants to use WorkflowClient for some
76+
* operations like sending signal to its parent workflow. @TODO getWorkflowClient method to
77+
* hide the service.
78+
*/
79+
public static WorkflowService.Iface getService() {
80+
return ActivityInternal.getService();
81+
}
8782

88-
public static String getDomain() {
89-
return ActivityInternal.getDomain();
90-
}
83+
public static String getDomain() {
84+
return ActivityInternal.getDomain();
85+
}
9186

92-
/**
93-
* If there is a need to return a checked exception from an activity
94-
* do not add the exception to a method signature but rethrow it using this method.
95-
* The library code will unwrap it automatically when propagating exception to the caller.
96-
* There is no need to wrap unchecked exceptions, but it is safe to call this method on them.
97-
* <p>
98-
* The reason for such design is that returning originally thrown exception from a remote call
99-
* (which child workflow and activity invocations are ) would not allow adding context information about
100-
* a failure, like activity and child workflow id. So stubs always throw a subclass of
101-
* {@link ActivityException} from calls to an activity and subclass of
102-
* {@link com.uber.cadence.workflow.ChildWorkflowException} from calls to a child workflow.
103-
* The original exception is attached as a cause to these wrapper exceptions. So as exceptions are always wrapped
104-
* adding checked ones to method signature causes more pain than benefit.
105-
* </p>
106-
* Throws original exception if e is {@link RuntimeException} or {@link Error}.
107-
* Never returns. But return type is not empty to be able to use it as:
108-
* <pre>
109-
* try {
110-
* return someCall();
111-
* } catch (Exception e) {
112-
* throw CheckedExceptionWrapper.throwWrapped(e);
113-
* }
114-
* </pre>
115-
* If throwWrapped returned void it wouldn't be possible to write <code>throw CheckedExceptionWrapper.throwWrapped</code>
116-
* and compiler would complain about missing return.
117-
*
118-
* @return never returns as always throws.
119-
*/
120-
public static RuntimeException wrap(Exception e) {
121-
return WorkflowInternal.wrap(e);
122-
}
87+
/**
88+
* If there is a need to return a checked exception from an activity do not add the exception to a
89+
* method signature but rethrow it using this method. The library code will unwrap it
90+
* automatically when propagating exception to the caller. There is no need to wrap unchecked
91+
* exceptions, but it is safe to call this method on them.
92+
*
93+
* <p>The reason for such design is that returning originally thrown exception from a remote call
94+
* (which child workflow and activity invocations are ) would not allow adding context information
95+
* about a failure, like activity and child workflow id. So stubs always throw a subclass of
96+
* {@link ActivityException} from calls to an activity and subclass of {@link
97+
* com.uber.cadence.workflow.ChildWorkflowException} from calls to a child workflow. The original
98+
* exception is attached as a cause to these wrapper exceptions. So as exceptions are always
99+
* wrapped adding checked ones to method signature causes more pain than benefit.
100+
*
101+
* <p>Throws original exception if e is {@link RuntimeException} or {@link Error}. Never returns.
102+
* But return type is not empty to be able to use it as:
103+
*
104+
* <pre>
105+
* try {
106+
* return someCall();
107+
* } catch (Exception e) {
108+
* throw CheckedExceptionWrapper.throwWrapped(e);
109+
* }
110+
* </pre>
111+
*
112+
* If throwWrapped returned void it wouldn't be possible to write <code>
113+
* throw CheckedExceptionWrapper.throwWrapped</code> and compiler would complain about missing
114+
* return.
115+
*
116+
* @return never returns as always throws.
117+
*/
118+
public static RuntimeException wrap(Exception e) {
119+
return WorkflowInternal.wrap(e);
120+
}
123121

124-
/**
125-
* Prohibit instantiation
126-
*/
127-
private Activity() {
128-
}
122+
/** Prohibit instantiation */
123+
private Activity() {}
129124
}

src/main/java/com/uber/cadence/activity/ActivityMethod.java

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,50 +23,47 @@
2323
import java.lang.annotation.Target;
2424

2525
/**
26-
* Indicates that the method is an activity method.
27-
* This annotation applies only to activity interface methods.
28-
* Not required. Use it to override default activity type name or other options.
29-
* When both {@link ActivityOptions} and {@link ActivityMethod} have non default value
30-
* for some parameter the {@link ActivityOptions} one takes precedence.
26+
* Indicates that the method is an activity method. This annotation applies only to activity
27+
* interface methods. Not required. Use it to override default activity type name or other options.
28+
* When both {@link ActivityOptions} and {@link ActivityMethod} have non default value for some
29+
* parameter the {@link ActivityOptions} one takes precedence.
3130
*/
3231
@Retention(RetentionPolicy.RUNTIME)
3332
@Target(ElementType.METHOD)
3433
public @interface ActivityMethod {
3534

36-
/**
37-
* Name of the workflow type. Default is {short class name}::{method name}
38-
*/
39-
String name() default "";
35+
/** Name of the workflow type. Default is {short class name}::{method name} */
36+
String name() default "";
4037

41-
/**
42-
* Overall timeout workflow is willing to wait for activity to complete.
43-
* It includes time in a task list (use {@link #scheduleToStartTimeoutSeconds()} to limit it)
44-
* plus activity execution time (use {@link #startToCloseTimeoutSeconds()} to limit it).
45-
* Either this option or both schedule to start and start to close are required.
46-
*/
47-
int scheduleToCloseTimeoutSeconds() default 0;
38+
/**
39+
* Overall timeout workflow is willing to wait for activity to complete. It includes time in a
40+
* task list (use {@link #scheduleToStartTimeoutSeconds()} to limit it) plus activity execution
41+
* time (use {@link #startToCloseTimeoutSeconds()} to limit it). Either this option or both
42+
* schedule to start and start to close are required.
43+
*/
44+
int scheduleToCloseTimeoutSeconds() default 0;
4845

49-
/**
50-
* Time activity can stay in task list before it is picked up by a worker.
51-
* If schedule to close is not provided then both this and start to close are required.
52-
*/
53-
int scheduleToStartTimeoutSeconds() default 0;
46+
/**
47+
* Time activity can stay in task list before it is picked up by a worker. If schedule to close is
48+
* not provided then both this and start to close are required.
49+
*/
50+
int scheduleToStartTimeoutSeconds() default 0;
5451

55-
/**
56-
* Maximum activity execution time after it was sent to a worker.
57-
* If schedule to close is not provided then both this and schedule to start are required.
58-
*/
59-
int startToCloseTimeoutSeconds() default 0;
52+
/**
53+
* Maximum activity execution time after it was sent to a worker. If schedule to close is not
54+
* provided then both this and schedule to start are required.
55+
*/
56+
int startToCloseTimeoutSeconds() default 0;
6057

61-
/**
62-
* Heartbeat interval. Activity must heartbeat before this interval passes after a last heartbeat
63-
* or activity start.
64-
*/
65-
int heartbeatTimeoutSeconds() default 0;
58+
/**
59+
* Heartbeat interval. Activity must heartbeat before this interval passes after a last heartbeat
60+
* or activity start.
61+
*/
62+
int heartbeatTimeoutSeconds() default 0;
6663

67-
/**
68-
* Task list to use when dispatching activity task to a worker. By default it is the same task list name
69-
* the workflow was started with.
70-
*/
71-
String taskList() default "";
64+
/**
65+
* Task list to use when dispatching activity task to a worker. By default it is the same task
66+
* list name the workflow was started with.
67+
*/
68+
String taskList() default "";
7269
}

0 commit comments

Comments
 (0)