Add default replacement tags for servers

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-05-20 10:55:11 -06:00
rodzic 7726f2aff2
commit b0193ac2e1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
1 zmienionych plików z 40 dodań i 4 usunięć

Wyświetl plik

@ -167,6 +167,7 @@ public class MapWithAIInfo extends TileSourceInfo implements Comparable<MapWithA
private MapWithAICategory category; private MapWithAICategory category;
private MapWithAIType type; private MapWithAIType type;
private JsonArray parameters; private JsonArray parameters;
private Map<String, String> replacementTags;
/** /**
* when adding a field, also adapt the: {@link #MapWithAIPreferenceEntry * when adding a field, also adapt the: {@link #MapWithAIPreferenceEntry
@ -223,6 +224,8 @@ public class MapWithAIInfo extends TileSourceInfo implements Comparable<MapWithA
String category; String category;
@StructEntry @StructEntry
String parameters; String parameters;
@StructEntry
Map<String, String> replacementTags;
/** /**
* Constructs a new empty {@MapWithAIPreferenceEntry} * Constructs a new empty {@MapWithAIPreferenceEntry}
@ -258,6 +261,9 @@ public class MapWithAIInfo extends TileSourceInfo implements Comparable<MapWithA
if (i.parameters != null) { if (i.parameters != null) {
parameters = i.parameters.toString(); parameters = i.parameters.toString();
} }
if (i.replacementTags != null) {
replacementTags = i.replacementTags;
}
category = i.category != null ? i.category.getCategoryString() : null; category = i.category != null ? i.category.getCategoryString() : null;
if (i.bounds != null) { if (i.bounds != null) {
bounds = i.bounds.encodeAsString(","); bounds = i.bounds.encodeAsString(",");
@ -302,9 +308,7 @@ public class MapWithAIInfo extends TileSourceInfo implements Comparable<MapWithA
this.name = name; this.name = name;
this.url = baseUrl; this.url = baseUrl;
this.id = id; this.id = id;
if (type == null) { this.type = MapWithAIType.THIRD_PARTY;
type = MapWithAIType.THIRD_PARTY;
}
} }
/** /**
@ -344,6 +348,9 @@ public class MapWithAIInfo extends TileSourceInfo implements Comparable<MapWithA
} }
} }
} }
if (e.replacementTags != null) {
replacementTags = e.replacementTags;
}
type = MapWithAIType.fromString(e.type); type = MapWithAIType.fromString(e.type);
if (type == null) { if (type == null) {
throw new IllegalArgumentException("unknown type"); throw new IllegalArgumentException("unknown type");
@ -392,11 +399,13 @@ public class MapWithAIInfo extends TileSourceInfo implements Comparable<MapWithA
this.attributionImageURL = i.attributionImageURL; this.attributionImageURL = i.attributionImageURL;
this.termsOfUseText = i.termsOfUseText; this.termsOfUseText = i.termsOfUseText;
this.termsOfUseURL = i.termsOfUseURL; this.termsOfUseURL = i.termsOfUseURL;
this.type = i.type;
this.countryCode = i.countryCode; this.countryCode = i.countryCode;
this.date = i.date; this.date = i.date;
this.icon = intern(i.icon); this.icon = intern(i.icon);
setCustomHttpHeaders(i.customHttpHeaders); setCustomHttpHeaders(i.customHttpHeaders);
this.category = i.category; this.category = i.category;
this.replacementTags = i.replacementTags;
} }
@Override @Override
@ -423,7 +432,8 @@ public class MapWithAIInfo extends TileSourceInfo implements Comparable<MapWithA
&& Objects.equals(this.termsOfUseURL, other.termsOfUseURL) && Objects.equals(this.termsOfUseURL, other.termsOfUseURL)
&& Objects.equals(this.countryCode, other.countryCode) && Objects.equals(this.date, other.date) && Objects.equals(this.countryCode, other.countryCode) && Objects.equals(this.date, other.date)
&& Objects.equals(this.icon, other.icon) && Objects.equals(this.description, other.description) && Objects.equals(this.icon, other.icon) && Objects.equals(this.description, other.description)
&& Objects.equals(this.category, other.category); && Objects.equals(this.category, other.category)
&& Objects.equals(this.replacementTags, other.replacementTags);
// CHECKSTYLE.ON: BooleanExpressionComplexity // CHECKSTYLE.ON: BooleanExpressionComplexity
} }
@ -732,8 +742,34 @@ public class MapWithAIInfo extends TileSourceInfo implements Comparable<MapWithA
return sb.toString(); return sb.toString();
} }
/**
* @param type Set the source type
*/
public void setSourceType(MapWithAIType type) { public void setSourceType(MapWithAIType type) {
this.type = type; this.type = type;
} }
/**
* @return The type of the source
*/
public MapWithAIType getSourceType() {
return this.type;
}
/**
* Set the required replacement tags
*
* @param replacementTags The tags to replace
*/
public void setReplacementTags(Map<String, String> replacementTags) {
this.replacementTags = replacementTags;
}
/**
* @return The required replacement tags (run first)
*/
public Map<String, String> getReplacementTags() {
return replacementTags;
}
} }