-
Notifications
You must be signed in to change notification settings - Fork 202
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
#160 let's get rid of List.add() #183
Closed
Closed
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
df558e0
Concat implementation commit
super132 2c0ea83
Committing unit test cases
super132 86739ff
Suppressing warnings for EMPTY_LIST usage
89db00c
Fixing code styling issues
super132 5956ed4
Another fixes to styling and refactoring
442eda3
Further styling fixes
super132 71641d8
Another fixes to styling.
f04c129
Minor style fixes.
super132 bc62609
Minor code styles fixes in unit test
super132 575fb86
Another minor code style fixes to unit test
super132 5eef73b
More minor updates to code stlyes
super132 202b6c7
Correct author name and since version.
super132 b666115
Code changes to address code review comments
super132 adf8469
Merge branch 'master' of https://github.com/yegor256/takes.git
super132 8ec1dd2
Fixing code style issues
super132 ad0dc65
Minor fixes to code style
super132 b416e3a
Code static analysis fix
super132 3d1abbc
Minor fix.
super132 97e42d2
Addressing code review comments
super132 cf1b7c1
Code styling changes as per advised in comments
super132 4bca084
Using Collection.emptyList() to avoid unchecked casting.
super132 a2b21e6
Select class is created for separating filtering and concatenation logic
a2a9dcf
Fixing code static analysis issues.
a06b488
Refactor according to code review comments
321ab09
Fixing compilation error in CI.
super132 a1e2dd7
Fixing static code analysis issues.
super132 a2d9672
Code refactor for PMD issues
super132 6a93539
minor Code style fixes
super132 36fcee6
Code static analysis fix.
super132 520fbe5
Code refactoring for addressing code review comments
super132 cc2de62
Merge branch 'master' of https://github.com/super132/takes.git
super132 6b016ef
Fixing code styling issues
super132 02f8612
Minor stlying fix
super132 a823694
Other minor code style fixes
super132 3f1d3ff
Further code refinements.
super132 c371d8a
Minor code refactoring.
super132 3537d5e
Revert "Minor code refactoring."
99eaf3d
Minor javadoc update
super132 d02c65a
Extracting out negation condition from LowerStartsWith
super132 546168d
Fixing code style issues
super132 299627a
Minor update to javadoc
super132 91d760b
Minor spacing update
super132 69ff934
Refactored SelectIterator to use Guava AbstractIterator
super132 45b2079
Updating POM to enable use of Guava
super132 1385aee
Fixing POM.xml
super132 76012c2
Fixing minor space problem.
super132 9750dc8
Adding super() call in constructor
super132 a3693bb
Refactoring LowerStartsWith condition into two to fulfill design needs
super132 6e25d5b
Fixing minor spacing issues
super132 1af3583
Removing Guava dependency
super132 08737a0
Refactoring case insensitive comparison to inline condition.
super132 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Merge branch 'master' of https://github.com/yegor256/takes.git
Conflicts: src/main/java/org/takes/rs/RsWithHeaders.java
- Loading branch information
commit adf846986362515ebcba632d8da39cbb0e633907
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,18 +28,18 @@ | |
import java.util.List; | ||
|
||
/** | ||
* Transform elements in an iterable into others. | ||
* Transform elements in an iterable (in type T) into others (in type K). | ||
* | ||
* @author Jason Wong ([email protected]) | ||
* @version $Id$ | ||
* @since 0.13.8 | ||
*/ | ||
public class Transformer<T> implements Iterable<T> { | ||
public class Transformer<T, K> implements Iterable<K> { | ||
|
||
/** | ||
* Internal storage. | ||
*/ | ||
private final transient List<T> storage = new LinkedList<T>(); | ||
private final transient List<K> storage = new LinkedList<K>(); | ||
|
||
/** | ||
* Transform elements in the supplied iterable by the action supplied. | ||
|
@@ -48,26 +48,26 @@ public class Transformer<T> implements Iterable<T> { | |
* @param action The actual transformation implementation | ||
*/ | ||
public Transformer(final Iterable<T> list, | ||
final Transformer.Action<T> action) { | ||
final Transformer.Action<T, K> action) { | ||
final Iterator<T> itr = list.iterator(); | ||
while (itr.hasNext()) { | ||
this.storage.add(action.transform(itr.next())); | ||
} | ||
} | ||
|
||
@Override | ||
public final Iterator<T> iterator() { | ||
public final Iterator<K> iterator() { | ||
return this.storage.iterator(); | ||
} | ||
|
||
public interface Action<T> { | ||
public interface Action<T, K> { | ||
/** | ||
* The transform action of the element. | ||
* The transform action of the element of type T to K. | ||
* | ||
* @param element Element of the iterable | ||
* @return Transformed element | ||
*/ | ||
T transform(T element); | ||
K transform(T element); | ||
} | ||
|
||
/** | ||
|
@@ -79,12 +79,29 @@ public interface Action<T> { | |
* | ||
*/ | ||
public static final class Trim implements | ||
Transformer.Action<String> { | ||
Transformer.Action<String, String> { | ||
|
||
@Override | ||
public String transform(final String element) { | ||
return element.trim(); | ||
} | ||
} | ||
|
||
/** | ||
* Convert CharSequence into String | ||
* | ||
* @author Jason Wong ([email protected]) | ||
* @version $Id$ | ||
* @since 0.13.8 | ||
* | ||
*/ | ||
public static final class ToString implements | ||
Transformer.Action<CharSequence, String> { | ||
|
||
} | ||
@Override | ||
public String transform(CharSequence element) { | ||
return element.toString(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You are viewing a condensed version of this merge commit. You can view the full changes here.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@super132 I think here we should do as with
Condition
, so please moveAction
to a separate class and place the implementers as inner classes there.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.
@krzyk , I missed this one. I will move it out as a separate class.