Добавил новый контейнер ContextKey
This commit is contained in:
parent
9ba77a2f04
commit
feaecf7a15
86
.gitignore
vendored
86
.gitignore
vendored
@ -1,14 +1,3 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
*.class
|
||||
*.log
|
||||
*.ctxt
|
||||
@ -21,31 +10,68 @@ buildNumber.properties
|
||||
*.tar.gz
|
||||
*.rar
|
||||
hs_err_pid*
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
.idea/**/contentModel.xml
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
replay_pid*
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.project
|
||||
.classpath
|
||||
.idea/
|
||||
cmake-build-*/
|
||||
.idea/**/mongoSettings.xml
|
||||
*.iws
|
||||
out/
|
||||
.idea_modules/
|
||||
atlassian-ide-plugin.xml
|
||||
.idea/replstate.xml
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
.idea/httpRequests
|
||||
.idea/caches/build_file_checksums.ser
|
||||
*~
|
||||
.fuse_hidden*
|
||||
.directory
|
||||
.Trash-*
|
||||
.nfs*
|
||||
.gradle
|
||||
**/build/
|
||||
!src/**/build/
|
||||
gradle-app.setting
|
||||
!gradle-wrapper.jar
|
||||
!gradle-wrapper.properties
|
||||
.gradletasknamecache
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
*.stackdump
|
||||
[Dd]esktop.ini
|
||||
$RECYCLE.BIN/
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
*.lnk
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Icon
|
||||
._*
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
@ -1,6 +1,6 @@
|
||||
package dev.struchkov.haiti.utils;
|
||||
|
||||
import dev.struchkov.haiti.utils.domain.CompositeUrl;
|
||||
import dev.struchkov.haiti.utils.container.CompositeUrl;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -1,9 +1,8 @@
|
||||
package dev.struchkov.haiti.utils;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static dev.struchkov.haiti.utils.Checker.checkNotNull;
|
||||
import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
|
||||
|
||||
/**
|
||||
@ -13,9 +12,9 @@ import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
|
||||
*/
|
||||
public final class Strings {
|
||||
|
||||
private static final Set<Character> MD_FORBIDDEN_SYMBOLS = Stream.of(
|
||||
private static final Set<Character> MD_FORBIDDEN_SYMBOLS = Set.of(
|
||||
'\\', '+', '`', '[', ']', '\"', '~', '*', '#', '=', '_', '>', '<'
|
||||
).collect(Collectors.toSet());
|
||||
);
|
||||
|
||||
private Strings() {
|
||||
utilityClass();
|
||||
@ -23,7 +22,6 @@ public final class Strings {
|
||||
|
||||
public static final String EMPTY = "";
|
||||
public static final String NEW_LINE = System.getProperty("line.separator");
|
||||
public static final String TWO_NEW_LINE = NEW_LINE + NEW_LINE;
|
||||
public static final String ERR_UTILITY_CLASS = "Нельзя создать объект утилитарного класса";
|
||||
public static final String ERR_OPERATION_NOT_SUPPORTED = "Операция не поддерживается";
|
||||
|
||||
@ -37,7 +35,7 @@ public final class Strings {
|
||||
* @return Обрезанная до length количества символов строка
|
||||
*/
|
||||
public static String cutoff(String string, int length) {
|
||||
if (string != null) {
|
||||
if (checkNotNull(string)) {
|
||||
return string.length() > length ? string.substring(0, length) + "..." : string;
|
||||
}
|
||||
return null;
|
||||
@ -50,7 +48,7 @@ public final class Strings {
|
||||
* @return Строка с экранированными символами
|
||||
*/
|
||||
public static String escapeMarkdown(String str) {
|
||||
if (str != null) {
|
||||
if (checkNotNull(str)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char c = str.charAt(i);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package dev.struchkov.haiti.utils.domain;
|
||||
package dev.struchkov.haiti.utils.container;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -0,0 +1,38 @@
|
||||
package dev.struchkov.haiti.utils.container;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public interface ContextKey<T> {
|
||||
|
||||
String getValue();
|
||||
|
||||
Class<T> getType();
|
||||
|
||||
static <T> ContextKey<T> of(String value, Class<T> type) {
|
||||
return new ContextKey<>() {
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ContextKey<?> contextKey = (ContextKey<?>) o;
|
||||
return Objects.equals(value, contextKey.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
package dev.struchkov.haiti.utils;
|
||||
package dev.struchkov.haiti.utils.container;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Адаптированная реализация Pair из пакета javafx.util. Реализация необходима, так как в некоторых сборках JDK этот
|
||||
@ -32,4 +34,17 @@ public class Pair<K, V> {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Pair<?, ?> pair = (Pair<?, ?>) o;
|
||||
return Objects.equals(key, pair.key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(key);
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
module haiti.utils {
|
||||
exports dev.struchkov.haiti.utils;
|
||||
exports dev.struchkov.haiti.utils.concurrent;
|
||||
exports dev.struchkov.haiti.utils.domain;
|
||||
exports dev.struchkov.haiti.utils.container;
|
||||
|
||||
requires haiti.exception;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user