-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#4: Implement draft of search mechanism
- Loading branch information
Showing
21 changed files
with
646 additions
and
145 deletions.
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
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
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
56 changes: 56 additions & 0 deletions
56
src/main/java/io/github/dgroup/mbox4j/inbox/javax/search/Range.java
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2019 Yurii Dubinka | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom | ||
* the Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE | ||
* OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package io.github.dgroup.mbox4j.inbox.javax.search; | ||
|
||
import io.github.dgroup.mbox4j.query.Mode; | ||
import org.cactoos.iterable.IterableOf; | ||
|
||
/** | ||
* Search mode within the email folder which is fetching emails | ||
* based on their indexes using {@link javax.mail}. | ||
* | ||
* The indexing starts from <em>1</em>. | ||
* | ||
* @since 0.1.0 | ||
* @todo #/DEV Range#search - add integration test | ||
*/ | ||
public final class Range extends SearchOf { | ||
|
||
/** | ||
* Ctor. | ||
*/ | ||
public Range() { | ||
super( | ||
(query, folder) -> { | ||
final String zero = "0"; | ||
final int start = Integer.parseInt(query.mode().argument("start", zero)); | ||
final int end = Integer.parseInt(query.mode().argument("end", zero)); | ||
return new IterableOf<>(folder.getMessages(start, end)); | ||
}, | ||
Mode.RANGE | ||
); | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/io/github/dgroup/mbox4j/inbox/javax/search/Recent.java
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2019 Yurii Dubinka | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom | ||
* the Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE | ||
* OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package io.github.dgroup.mbox4j.inbox.javax.search; | ||
|
||
import io.github.dgroup.mbox4j.query.Mode; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import javax.mail.Flags.Flag; | ||
import org.cactoos.iterable.Filtered; | ||
|
||
/** | ||
* Search mode within the email folder which is fetching all recent email. | ||
* using {@link javax.mail}. | ||
* | ||
* @since 0.1.0 | ||
* @todo #/DEV Recent#search - add integration test | ||
*/ | ||
public final class Recent extends SearchOf { | ||
|
||
/** | ||
* Ctor. | ||
*/ | ||
public Recent() { | ||
super( | ||
(query, folder) -> { | ||
final int quantity = folder.getNewMessageCount(); | ||
final AtomicInteger added = new AtomicInteger(0); | ||
return new Filtered<>( | ||
msg -> msg.isSet(Flag.RECENT) && added.incrementAndGet() < quantity, | ||
folder.getMessages() | ||
); | ||
}, | ||
Mode.RECENT | ||
); | ||
} | ||
|
||
} |
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
Oops, something went wrong.
83f816c
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.
Puzzle
DEV-eca9a629
disappeared fromsrc/main/java/io/github/dgroup/mbox4j/inbox/func/javax/JavaxMailInbox.java
, that's why I closed #4. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.83f816c
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.
Puzzle
DEV-647b5960
discovered insrc/main/java/io/github/dgroup/mbox4j/query/mode/package-info.java
and submitted as #27. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.83f816c
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.
Puzzle
DEV-743d9b92
discovered insrc/main/java/io/github/dgroup/mbox4j/inbox/javax/search/All.java
and submitted as #28. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.83f816c
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.
Puzzle
DEV-6736be7e
discovered insrc/main/java/io/github/dgroup/mbox4j/inbox/javax/search/Range.java
and submitted as #29. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.83f816c
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.
Puzzle
DEV-89560df8
discovered insrc/main/java/io/github/dgroup/mbox4j/inbox/javax/search/package-info.java
and submitted as #30. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.83f816c
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.
Puzzle
DEV-8e29838e
discovered insrc/main/java/io/github/dgroup/mbox4j/inbox/javax/search/package-info.java
and submitted as #31. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.83f816c
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.
Puzzle
DEV-5f34ad4c
discovered insrc/main/java/io/github/dgroup/mbox4j/inbox/javax/search/package-info.java
and submitted as #32. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.83f816c
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.
Puzzle
DEV-d12d997b
discovered insrc/main/java/io/github/dgroup/mbox4j/inbox/javax/search/package-info.java
and submitted as #33. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.83f816c
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.
Puzzle
DEV-2451da39
discovered insrc/main/java/io/github/dgroup/mbox4j/inbox/javax/search/Recent.java
and submitted as #34. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.83f816c
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.
Puzzle
DEV-9e3d01ad
discovered insrc/main/java/io/github/dgroup/mbox4j/inbox/javax/search/Search.java
and submitted as #35. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.83f816c
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.
Puzzle
DEV-75afffcf
discovered insrc/main/java/io/github/dgroup/mbox4j/inbox/javax/search/Unread.java
and submitted as #36. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.