Skip to content

Commit ac67237

Browse files
jayandran-SampathSrinivasanTarget
authored andcommitted
Lombok Library Update (#1193)
* Code changes for getting all session details * Revert "Code changes for getting all session details" This reverts commit 76159eb. * Updated the comments and recommitting the changes * Organised import statement as per comments * Updated as per comments * Code Changes for Lombok Plugin * Code Changes for introducing Lombok Library * as per comments, removed TestCompile & TestAnnotationProcessor
1 parent 891636a commit ac67237

File tree

10 files changed

+83
-285
lines changed

10 files changed

+83
-285
lines changed

build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,31 @@ apply plugin: 'com.github.johnrengelman.shadow'
2929

3030
configurations {
3131
ecj
32+
lombok
3233
}
3334

3435
dependencies {
3536
ecj 'org.eclipse.jdt:ecj:3.18.0'
37+
lombok 'org.projectlombok:lombok:1.18.8'
3638
}
3739

3840
compileJava {
3941
sourceCompatibility = 1.8
4042
targetCompatibility = 1.8
4143

4244
def ecjJar = configurations.ecj.singleFile
45+
def lombokjar = configurations.lombok.singleFile
4346

4447
options.fork = true
45-
options.fork executable: 'java', jvmArgs: [ '-cp', ecjJar.path, 'org.eclipse.jdt.internal.compiler.batch.Main' ]
48+
options.fork executable: 'java', jvmArgs: [ '-javaagent:'+lombokjar.path+'=ECJ', '-jar', ecjJar.path, '-cp', lombokjar.path]
4649
options.define compilerArgs: [
4750
'-encoding', 'utf-8'
4851
]
4952
}
5053

5154
dependencies {
55+
compileOnly('org.projectlombok:lombok:1.18.8')
56+
annotationProcessor('org.projectlombok:lombok:1.18.8')
5257
compile ("org.seleniumhq.selenium:selenium-java:${project.property('selenium.version')}") {
5358
force = true
5459

src/main/java/io/appium/java_client/AppiumCommandInfo.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616

1717
package io.appium.java_client;
1818

19+
import lombok.AccessLevel;
20+
import lombok.Getter;
1921
import org.openqa.selenium.remote.CommandInfo;
2022
import org.openqa.selenium.remote.http.HttpMethod;
2123

2224
public class AppiumCommandInfo extends CommandInfo {
23-
private final String url;
24-
private final HttpMethod method;
25+
@Getter(AccessLevel.PUBLIC) private final String url;
26+
@Getter(AccessLevel.PUBLIC) private final HttpMethod method;
2527

2628
/**
2729
* It conntains method and URL of the command.
@@ -34,12 +36,4 @@ public AppiumCommandInfo(String url, HttpMethod method) {
3436
this.url = url;
3537
this.method = method;
3638
}
37-
38-
public String getUrl() {
39-
return url;
40-
}
41-
42-
public HttpMethod getMethod() {
43-
return method;
44-
}
4539
}

src/main/java/io/appium/java_client/AppiumFluentWait.java

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import com.google.common.base.Throwables;
2020

21+
import lombok.AccessLevel;
22+
import lombok.Getter;
2123
import org.openqa.selenium.TimeoutException;
2224
import org.openqa.selenium.WebDriverException;
2325
import org.openqa.selenium.support.ui.FluentWait;
@@ -35,61 +37,45 @@ public class AppiumFluentWait<T> extends FluentWait<T> {
3537
private Function<IterationInfo, Duration> pollingStrategy = null;
3638

3739
public static class IterationInfo {
38-
private final long number;
39-
private final Duration elapsed;
40-
private final Duration total;
41-
private final Duration interval;
42-
43-
/**
44-
* The class is used to represent information about a single loop iteration in {@link #until(Function)}
45-
* method.
46-
*
47-
* @param number loop iteration number, starts from 1
48-
* @param elapsed the amount of elapsed time since the loop started
49-
* @param total the amount of total time to run the loop
50-
* @param interval the default time interval for each loop iteration
51-
*/
52-
public IterationInfo(long number, Duration elapsed, Duration total, Duration interval) {
53-
this.number = number;
54-
this.elapsed = elapsed;
55-
this.total = total;
56-
this.interval = interval;
57-
}
58-
5940
/**
6041
* The current iteration number.
6142
*
6243
* @return current iteration number. It starts from 1
6344
*/
64-
public long getNumber() {
65-
return number;
66-
}
67-
45+
@Getter(AccessLevel.PUBLIC) private final long number;
6846
/**
6947
* The amount of elapsed time.
7048
*
7149
* @return the amount of elapsed time
7250
*/
73-
public Duration getElapsed() {
74-
return elapsed;
75-
}
76-
51+
@Getter(AccessLevel.PUBLIC) private final Duration elapsed;
7752
/**
7853
* The amount of total time.
7954
*
8055
* @return the amount of total time
8156
*/
82-
public Duration getTotal() {
83-
return total;
84-
}
85-
57+
@Getter(AccessLevel.PUBLIC) private final Duration total;
8658
/**
8759
* The current interval.
8860
*
8961
* @return The actual value of current interval or the default one if it is not set
9062
*/
91-
public Duration getInterval() {
92-
return interval;
63+
@Getter(AccessLevel.PUBLIC) private final Duration interval;
64+
65+
/**
66+
* The class is used to represent information about a single loop iteration in {@link #until(Function)}
67+
* method.
68+
*
69+
* @param number loop iteration number, starts from 1
70+
* @param elapsed the amount of elapsed time since the loop started
71+
* @param total the amount of total time to run the loop
72+
* @param interval the default time interval for each loop iteration
73+
*/
74+
public IterationInfo(long number, Duration elapsed, Duration total, Duration interval) {
75+
this.number = number;
76+
this.elapsed = elapsed;
77+
this.total = total;
78+
this.interval = interval;
9379
}
9480
}
9581

src/main/java/io/appium/java_client/MobileBy.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.appium.java_client;
1818

19+
import lombok.AccessLevel;
20+
import lombok.Getter;
1921
import org.apache.commons.lang3.StringUtils;
2022
import org.openqa.selenium.By;
2123
import org.openqa.selenium.SearchContext;
@@ -31,7 +33,7 @@ public abstract class MobileBy extends By {
3133
private static final String ERROR_TEXT = "The class %s of the given context "
3234
+ "doesn't implement %s nor %s. Sorry. It is impossible to find something.";
3335

34-
private final String locatorString;
36+
@Getter(AccessLevel.PROTECTED) private final String locatorString;
3537
private final MobileSelector selector;
3638

3739
private static IllegalArgumentException formIllegalArgumentException(Class<?> givenClass,
@@ -48,19 +50,15 @@ protected MobileBy(MobileSelector selector, String locatorString) {
4850
this.selector = selector;
4951
}
5052

51-
protected String getLocatorString() {
52-
return locatorString;
53-
}
54-
5553
@SuppressWarnings("unchecked")
5654
@Override public List<WebElement> findElements(SearchContext context) {
5755
return (List<WebElement>) ((FindsByFluentSelector<?>) context)
58-
.findElements(selector.toString(), getLocatorString());
56+
.findElements(selector.toString(), getLocatorString());
5957
}
6058

6159
@Override public WebElement findElement(SearchContext context) {
6260
return ((FindsByFluentSelector<?>) context)
63-
.findElement(selector.toString(), getLocatorString());
61+
.findElement(selector.toString(), getLocatorString());
6462
}
6563

6664
/**

src/main/java/io/appium/java_client/ScreenshotState.java

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
package io.appium.java_client;
1818

19+
import lombok.AccessLevel;
20+
import lombok.Getter;
21+
import lombok.Setter;
22+
import lombok.experimental.Accessors;
23+
1924
import static com.google.common.base.Preconditions.checkNotNull;
2025
import static java.util.Optional.ofNullable;
2126

@@ -30,14 +35,20 @@
3035

3136
import javax.imageio.ImageIO;
3237

38+
@Accessors(chain = true)
3339
public class ScreenshotState {
3440
private static final Duration DEFAULT_INTERVAL_MS = Duration.ofMillis(500);
3541

3642
private BufferedImage previousScreenshot;
3743
private final Supplier<BufferedImage> stateProvider;
3844
private final ComparesImages comparator;
39-
40-
private Duration comparisonInterval = DEFAULT_INTERVAL_MS;
45+
/**
46+
* Gets the interval value in ms between similarity verification rounds in <em>verify*</em> methods.
47+
*
48+
* @param comparisonInterval interval value. 500 ms by default
49+
* @return current interval value in ms
50+
*/
51+
@Getter(AccessLevel.PUBLIC) @Setter(AccessLevel.PUBLIC) private Duration comparisonInterval = DEFAULT_INTERVAL_MS;
4152

4253
/**
4354
* The class constructor accepts two arguments. The first one is image comparator, the second
@@ -79,25 +90,6 @@ public ScreenshotState(ComparesImages comparator) {
7990
this(comparator, null);
8091
}
8192

82-
/**
83-
* Gets the interval value in ms between similarity verification rounds in <em>verify*</em> methods.
84-
*
85-
* @return current interval value in ms
86-
*/
87-
public Duration getComparisonInterval() {
88-
return comparisonInterval;
89-
}
90-
91-
/**
92-
* Sets the interval between similarity verification rounds in <em>verify*</em> methods.
93-
*
94-
* @param comparisonInterval interval value. 500 ms by default
95-
* @return self instance for chaining
96-
*/
97-
public ScreenshotState setComparisonInterval(Duration comparisonInterval) {
98-
this.comparisonInterval = comparisonInterval;
99-
return this;
100-
}
10193

10294
/**
10395
* Call this method to save the initial screenshot state.

0 commit comments

Comments
 (0)