-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test: hadoopfs tests remove the use of @Value.Immutable #8572
Changes from 2 commits
3658399
987294e
939d812
c958ede
f113246
fcaab56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package io.lakefs; | ||
|
||
import com.google.common.base.Optional; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use the standard java.util.Optional instead? (Maybe not if code is generated with a different Optional...) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I thought the code prefered Google's package so we left it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is used in a single location - and already used 'if' to check the optional value. So I've updarted to check for null. |
||
|
||
public final class ImmutablePagination implements FSTestBase.Pagination { | ||
private final Optional<Integer> amount; | ||
private final Optional<String> after; | ||
private final Optional<String> prefix; | ||
|
||
private ImmutablePagination(Optional<Integer> amount, Optional<String> after, Optional<String> prefix) { | ||
this.amount = amount; | ||
this.after = after; | ||
this.prefix = prefix; | ||
} | ||
|
||
public Optional<Integer> amount() { | ||
return this.amount; | ||
} | ||
|
||
public Optional<String> after() { | ||
return this.after; | ||
} | ||
|
||
public Optional<String> prefix() { | ||
return this.prefix; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
private Optional<Integer> amount = Optional.absent(); | ||
private Optional<String> after = Optional.absent(); | ||
private Optional<String> prefix = Optional.absent(); | ||
|
||
public Builder amount(Integer amount) { | ||
this.amount = Optional.fromNullable(amount); | ||
return this; | ||
} | ||
|
||
public Builder after(String after) { | ||
this.after = Optional.fromNullable(after); | ||
return this; | ||
} | ||
|
||
public Builder prefix(String prefix) { | ||
this.prefix = Optional.fromNullable(prefix); | ||
return this; | ||
} | ||
|
||
public ImmutablePagination build() { | ||
return new ImmutablePagination(amount, after, prefix); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand: this used to be auto-generated; is this now manually written?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used the common builder pattern to implement the Pagination class.
This class is used by the test code to pass pagination argumens (some optional).
If Java add optional field initialization I'm sure we didn't had this class in the first place. We do not use the generated code in non-test.