
com.github.davidmoten.odata.client.ContextPath Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of odata-client-runtime Show documentation
Show all versions of odata-client-runtime Show documentation
OData client runtime for use with generated code
The newest version!
package com.github.davidmoten.odata.client;
import java.util.Map;
import java.util.Map.Entry;
public final class ContextPath {
private final Path path;
private final Context context;
public ContextPath(Context context, Path path) {
this.path = path;
this.context = context;
}
public ContextPath addSegment(String segment) {
return new ContextPath(context, path.addSegment(segment));
}
public ContextPath appendToSegment(String s) {
return new ContextPath(context, path.appendToSegment(s));
}
public ContextPath addActionOrFunctionSegment(String fullyQualifiedName) {
boolean useSimpleNameOnly = context.propertyIsTrue(Properties.ACTION_OR_FUNCTION_SEGMENT_SIMPLE_NAME);
if (useSimpleNameOnly) {
int i = fullyQualifiedName.lastIndexOf(".");
if (i == -1) {
return addSegment(fullyQualifiedName);
} else {
return addSegment(fullyQualifiedName.substring(i + 1));
}
} else {
return addSegment(fullyQualifiedName);
}
}
public ContextPath addKeys(NameValue... keys) {
return new ContextPath(context, path.addKeys(keys));
}
public ContextPath addQuery(String key, String value) {
return new ContextPath(context, path.addQuery(key, value));
}
public String toUrl() {
return path.toUrl();
}
public Context context() {
return context;
}
public Path path() {
return path;
}
public ContextPath addQueries(Map queries) {
Path p = path;
for (Entry entry : queries.entrySet()) {
p = p.addQuery(entry.getKey(), entry.getValue());
}
return new ContextPath(context, p);
}
public ContextPath clearQueries() {
Path p = path.clearQueries();
return new ContextPath(context, p);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy