-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
455 additions
and
457 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
121 changes: 0 additions & 121 deletions
121
eo-maven-plugin/src/main/java/org/eolang/maven/name/OnDefault.java
This file was deleted.
Oops, something went wrong.
132 changes: 132 additions & 0 deletions
132
eo-maven-plugin/src/main/java/org/eolang/maven/name/OnReplaced.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,132 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2016-2023 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.name; | ||
|
||
import java.util.Map; | ||
import org.eolang.maven.hash.CommitHash; | ||
import org.eolang.maven.hash.CommitHashesMap; | ||
|
||
/** | ||
* Object name replaced. | ||
* This is object name that parses raw sting like: | ||
* - "org.eolang.text#0.1.0" into "org.eolang.text" | ||
* and "4b19944" | ||
* - "org.eolang.string#a1b2c3d" into "org.eolang.string" | ||
* and "be83d9a" | ||
* Pay attention to that versions transformed into narrow hashes. | ||
* If a version is not provided - behaves like {@link OnUnversioned}. | ||
* | ||
* @since 0.30 | ||
* @todo #2376:90min Frontend and backend delimiters differ. | ||
* I was confused with the delimiter '#' that we use in {@link OnReplaced} and delimiter which | ||
* we use in the frontend. For example: | ||
* - "org.eolang.text|0.1.0" - frontend | ||
* - "org.eolang.text#0.1.0" - backend | ||
* The problem here is that we use the '|' delimiter on the frontend and '#' in the backend, but | ||
* both of them mean the same thing - object name + version. | ||
* I believe that we need to use the same symbol in both places, because it will be easier to | ||
* understand the code. So, my suggestion to use '|' in both places. | ||
*/ | ||
public final class OnReplaced implements ObjectName { | ||
|
||
/** | ||
* Delimiter between name and hash in EO object name. | ||
*/ | ||
public static final String DELIMITER = "#"; | ||
|
||
/** | ||
* Default hashes. | ||
*/ | ||
private static final Map<String, CommitHash> DEFAULT = new CommitHashesMap(); | ||
|
||
/** | ||
* Raw string. | ||
* Examples: | ||
* - "org.eolang.text#0.1.0" | ||
* - "org.eolang.string#1.23.1" | ||
* - "org.eolang.math#3.3.3" | ||
*/ | ||
private final String raw; | ||
|
||
/** | ||
* All hashes. | ||
*/ | ||
private final Map<String, ? extends CommitHash> hashes; | ||
|
||
/** | ||
* Constructor. | ||
* @param origin Raw string. | ||
*/ | ||
public OnReplaced(final String origin) { | ||
this(origin, OnReplaced.DEFAULT); | ||
} | ||
|
||
/** | ||
* Constructor. | ||
* @param origin Raw string. | ||
* @param all All hashes. | ||
*/ | ||
public OnReplaced( | ||
final String origin, | ||
final Map<String, ? extends CommitHash> all | ||
) { | ||
this.raw = origin; | ||
this.hashes = all; | ||
} | ||
|
||
@Override | ||
public String value() { | ||
return this.split()[0]; | ||
} | ||
|
||
@Override | ||
public CommitHash hash() { | ||
return this.hashes.get(this.split()[1]); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final String result; | ||
if (this.raw.contains(OnReplaced.DELIMITER)) { | ||
result = String.join( | ||
"", | ||
this.value(), | ||
OnReplaced.DELIMITER, | ||
this.hash().value() | ||
); | ||
} else { | ||
result = this.value(); | ||
} | ||
return result; | ||
} | ||
|
||
/** | ||
* Split raw string into name and hash. | ||
* @return Array of two elements: name and hash. | ||
*/ | ||
private String[] split() { | ||
return this.raw.split(OnReplaced.DELIMITER); | ||
} | ||
} | ||
|
Oops, something went wrong.
c4087fa
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
2381-b6d409bc
disappeared fromeo-maven-plugin/src/main/java/org/eolang/maven/name/OnDefault.java
), that's why I closed #2389. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.c4087fa
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
2376-007b3f61
disappeared fromeo-maven-plugin/src/main/java/org/eolang/maven/name/OnVersioned.java
), that's why I closed #2382. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.c4087fa
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
2376-11b46788
discovered ineo-maven-plugin/src/main/java/org/eolang/maven/name/OnReplaced.java
) and submitted as #2394. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.