-
Notifications
You must be signed in to change notification settings - Fork 146
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
Reduce code duplication down to 15 lines per piece #2916
Merged
rultor
merged 23 commits into
objectionary:master
from
c71n93:2863-reduce-code-duplication-15
May 2, 2024
Merged
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
72632f2
#2863 add extra object to reduce code duplication
c71n93 4e872b4
#2863 make Home abstract class to reduce code duplication
c71n93 67606b9
#2863 create extra function to reduce code duplication in UnplaceMojo…
c71n93 34f68ad
#2863 get rid of ugly method using parametrized test
c71n93 31572d1
#2863 supress UnusedPrivateMethod warning
c71n93 0a6fa6f
#2863 add PhDecorator abstract class to reduce code duplication
c71n93 adee12e
#2863 delete some unnecessary methods overriding
c71n93 3842823
Merge branch 'master' into 2863-reduce-code-duplication-15
c71n93 74c589c
#2863 fix qulice warnings
c71n93 7c77831
Merge branch 'master' into 2863-reduce-code-duplication-15
c71n93 03e7d15
#2863 remove unnecessary test
c71n93 be129c9
Merge branch 'master' into 2863-reduce-code-duplication-15
c71n93 8b58618
#2863 remove duplicated test
c71n93 5be5468
#2863 remove sudden groovy libs
c71n93 cc49278
#2863 new line at the end of the file
c71n93 76f06cd
#2863 get rid of Home abstract class
c71n93 725d9b1
#2863 rollback to current master
c71n93 daaee28
#2863 remove PhDecorator
c71n93 c73be94
#2863 remove newline at the end of file
c71n93 9a959ae
#2863 try to get rid of default methods in Home interface
c71n93 bc09cd0
Merge branch 'master' into 2863-reduce-code-duplication-15
c71n93 3258acd
#2863 fix namings and qulice violations
c71n93 e422a9c
#2863 fix threshold
c71n93 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
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
91 changes: 91 additions & 0 deletions
91
eo-maven-plugin/src/main/java/org/eolang/maven/util/DataSaved.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,91 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2016-2024 Objectionary.com | ||
* | ||
* 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 org.eolang.maven.util; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Path; | ||
import org.cactoos.Input; | ||
import org.cactoos.Text; | ||
import org.cactoos.io.InputOf; | ||
|
||
/** | ||
* The data is saved to a file. | ||
* @since 0.32.0 | ||
*/ | ||
public interface DataSaved { | ||
/** | ||
* Saving string. | ||
* | ||
* @param str String | ||
* @param path Cwd-relative path to file | ||
* @throws IOException If fails | ||
*/ | ||
default void save(final String str, final Path path) throws IOException { | ||
this.save(new InputOf(str), path); | ||
} | ||
|
||
/** | ||
* Saving text. | ||
* | ||
* @param txt Text | ||
* @param path Cwd-relative path to file | ||
* @throws IOException If fails | ||
*/ | ||
default void save(final Text txt, final Path path) throws IOException { | ||
this.save(new InputOf(txt), path); | ||
} | ||
|
||
/** | ||
* Saving stream. | ||
* | ||
* @param stream Input stream | ||
* @param path Cwd-relative path to file | ||
* @throws IOException If fails | ||
*/ | ||
default void save(final InputStream stream, final Path path) throws IOException { | ||
this.save(new InputOf(stream), path); | ||
} | ||
|
||
/** | ||
* Saving bytes. | ||
* | ||
* @param bytes Byte array | ||
* @param path Cwd-relative path to file | ||
* @throws IOException If fails | ||
*/ | ||
default void save(final byte[] bytes, final Path path) throws IOException { | ||
this.save(new InputOf(bytes), path); | ||
} | ||
|
||
/** | ||
* Saving input. | ||
* | ||
* @param input Input | ||
* @param path Cwd-relative path to file | ||
* @throws IOException If fails | ||
* @throws IllegalArgumentException If given path is absolute | ||
*/ | ||
void save(Input input, Path path) throws IOException; | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
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.
@c71n93 interface with default methods - it's almost the same as abstract class. You split the logic and keep it in different places.