remove legacy structure
This commit is contained in:
parent
4333e2a996
commit
c906f144fa
@ -1,70 +0,0 @@
|
||||
package de.marhali.easyi18n.model;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
import de.marhali.easyi18n.settings.ProjectSettingsService;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Responsible for mapping {@link KeyPath} into single string and backwards.
|
||||
* If nesting is enabled the delimiter within a section is escaped otherwise the delimiter between the key sections.
|
||||
* @author marhali
|
||||
*/
|
||||
@Deprecated // Replacement moved to utils
|
||||
public class KeyPathConverter {
|
||||
|
||||
private final boolean nestKeys;
|
||||
|
||||
public KeyPathConverter(boolean nestKeys) {
|
||||
this.nestKeys = nestKeys;
|
||||
}
|
||||
|
||||
public KeyPathConverter(@NotNull Project project) {
|
||||
this(ProjectSettingsService.get(project).getState().isNestedKeys());
|
||||
}
|
||||
|
||||
public @NotNull String concat(@NotNull KeyPath path) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for(String section : path) {
|
||||
if(builder.length() > 0) {
|
||||
if(!this.nestKeys) {
|
||||
builder.append("\\\\");
|
||||
}
|
||||
|
||||
builder.append(KeyPath.DELIMITER);
|
||||
}
|
||||
|
||||
if(this.nestKeys) {
|
||||
builder.append(section.replace(KeyPath.DELIMITER, "\\\\" + KeyPath.DELIMITER));
|
||||
} else {
|
||||
builder.append(section);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public @NotNull KeyPath split(@NotNull String concatPath) {
|
||||
String[] sections = concatPath.split(this.nestKeys ?
|
||||
"(?<!\\\\)" + Pattern.quote(KeyPath.DELIMITER) : Pattern.quote("\\\\" + KeyPath.DELIMITER));
|
||||
|
||||
KeyPath path = new KeyPath();
|
||||
|
||||
for(String section : sections) {
|
||||
path.add(section.replace("\\\\" + KeyPath.DELIMITER, KeyPath.DELIMITER));
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KeyPathConverter{" +
|
||||
"nestKeys=" + nestKeys +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package de.marhali.easyi18n.model.translation;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents the absolute key path for a desired translation.
|
||||
* The key could be based one or many sections.
|
||||
* Classes implementing this structure need to take care on how to layer translations paths.
|
||||
* @author marhali
|
||||
*/
|
||||
public class KeyPath extends ArrayList<String> {
|
||||
|
||||
public KeyPath() {}
|
||||
|
||||
public KeyPath(@Nullable String... path) {
|
||||
super.addAll(List.of(path));
|
||||
}
|
||||
|
||||
public KeyPath(@NotNull List<String> path) {
|
||||
super(path);
|
||||
}
|
||||
|
||||
public KeyPath(@NotNull KeyPath path, @Nullable String... pathToAppend) {
|
||||
this(path);
|
||||
super.addAll(List.of(pathToAppend));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// Just a simple array view (e.g. [first, second]) - use KeyPathConverter to properly convert a key path
|
||||
return super.toString();
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package de.marhali.easyi18n.model.translation;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a translation with defined key and locale values.
|
||||
*
|
||||
* @author marhali
|
||||
*/
|
||||
public class Translation {
|
||||
|
||||
private final @NotNull KeyPath key;
|
||||
private @Nullable TranslationValue value;
|
||||
|
||||
/**
|
||||
* Constructs a new translation instance.
|
||||
* @param key Absolute key path
|
||||
* @param value Values to set - nullable to indicate removal
|
||||
*/
|
||||
public Translation(@NotNull KeyPath key, @Nullable TranslationValue value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Absolute key path
|
||||
*/
|
||||
public @NotNull KeyPath getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return values - nullable to indicate removal
|
||||
*/
|
||||
public @Nullable TranslationValue getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value Values to set - nullable to indicate removal
|
||||
*/
|
||||
public void setValue(@Nullable TranslationValue value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Translation{" +
|
||||
"key=" + key +
|
||||
", value=" + value +
|
||||
'}';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user