-
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.
- Loading branch information
Showing
11 changed files
with
72 additions
and
23 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is a part of 1c-syntax utils. | ||
* | ||
* Copyright (c) 2018-2024 | ||
* Copyright (c) 2018-2025 | ||
* Alexey Sosnoviy <[email protected]>, Nikita Fedkin <[email protected]> and contributors | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
@@ -40,6 +40,12 @@ | |
@UtilityClass | ||
public final class Absolute { | ||
|
||
/** | ||
* Получение URI из строки | ||
* | ||
* @param uri - строковое представление URI | ||
* @return - полученное значение | ||
*/ | ||
public static URI uri(@NonNull String uri) { | ||
try { | ||
var url = new URL(uri); | ||
|
@@ -60,28 +66,64 @@ public static URI uri(@NonNull String uri) { | |
} | ||
} | ||
|
||
/** | ||
* Получение абсолютного URI из URI с валидацией | ||
* | ||
* @param uri - исходный URI | ||
* @return - полученное значение | ||
*/ | ||
public static URI uri(@NonNull URI uri) { | ||
var decodedUri = URI.create(uri.getScheme() + ":" + encodePath(uri.getSchemeSpecificPart())); | ||
|
||
return checkFileAuthorityAndReturnURI(decodedUri); | ||
} | ||
|
||
/** | ||
* Получение URI файла | ||
* | ||
* @param file - исходный файл | ||
* @return - полученное значение | ||
*/ | ||
public static URI uri(@NonNull File file) { | ||
return uri(path(file).toUri()); | ||
} | ||
|
||
/** | ||
* Получение пути (path) из строки | ||
* | ||
* @param path - строковое представление пути | ||
* @return - полученное значение | ||
*/ | ||
public static Path path(@NonNull String path) { | ||
return path(Path.of(path)); | ||
} | ||
|
||
/** | ||
* Получение пути (path) из URI | ||
* | ||
* @param uri - исходное значение URI | ||
* @return - полученное значение | ||
*/ | ||
public static Path path(@NonNull URI uri) { | ||
return path(Path.of(uri(uri))); | ||
} | ||
|
||
/** | ||
* Получение абсолютного пути (path) из Path | ||
* | ||
* @param path - исходное значение пути | ||
* @return - полученное значение | ||
*/ | ||
public static Path path(@NonNull Path path) { | ||
return path(path.toFile()); | ||
} | ||
|
||
/** | ||
* Получение пути файла | ||
* | ||
* @param file - исходный файл | ||
* @return - полученное значение | ||
*/ | ||
@SneakyThrows | ||
public static Path path(@NonNull File file) { | ||
return file.getCanonicalFile().toPath().toAbsolutePath(); | ||
|
2 changes: 1 addition & 1 deletion
2
src/main/java/com/github/_1c_syntax/utils/CaseInsensitivePattern.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is a part of 1c-syntax utils. | ||
* | ||
* Copyright (c) 2018-2024 | ||
* Copyright (c) 2018-2025 | ||
* Alexey Sosnoviy <[email protected]>, Nikita Fedkin <[email protected]> and contributors | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is a part of 1c-syntax utils. | ||
* | ||
* Copyright (c) 2018-2024 | ||
* Copyright (c) 2018-2025 | ||
* Alexey Sosnoviy <[email protected]>, Nikita Fedkin <[email protected]> and contributors | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
@@ -25,17 +25,26 @@ | |
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* Реализация интернера | ||
* Реализация универсального интернера | ||
*/ | ||
public class GenericInterner<T> { | ||
|
||
private final Map<T, T> map = new ConcurrentHashMap<>(); | ||
|
||
/** | ||
* Метод интернирования значения | ||
* | ||
* @param object Интернируемый объект | ||
* @return значение из кеша | ||
*/ | ||
public T intern(T object) { | ||
var exist = map.putIfAbsent(object, object); | ||
return (exist == null) ? object : exist; | ||
} | ||
|
||
/** | ||
* Очистка кеша интернера | ||
*/ | ||
public void clear() { | ||
map.clear(); | ||
} | ||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is a part of 1c-syntax utils. | ||
* | ||
* Copyright (c) 2018-2024 | ||
* Copyright (c) 2018-2025 | ||
* Alexey Sosnoviy <[email protected]>, Nikita Fedkin <[email protected]> and contributors | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is a part of 1c-syntax utils. | ||
* | ||
* Copyright (c) 2018-2024 | ||
* Copyright (c) 2018-2025 | ||
* Alexey Sosnoviy <[email protected]>, Nikita Fedkin <[email protected]> and contributors | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is a part of 1c-syntax utils. | ||
* | ||
* Copyright (c) 2018-2024 | ||
* Copyright (c) 2018-2025 | ||
* Alexey Sosnoviy <[email protected]>, Nikita Fedkin <[email protected]> and contributors | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
2 changes: 1 addition & 1 deletion
2
src/test/java/com/github/_1c_syntax/utils/StringInternerTest.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This file is a part of 1c-syntax utils. | ||
* | ||
* Copyright (c) 2018-2024 | ||
* Copyright (c) 2018-2025 | ||
* Alexey Sosnoviy <[email protected]>, Nikita Fedkin <[email protected]> and contributors | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
|