repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
camunda/camunda-spin | dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/util/DomXmlEnsure.java | DomXmlEnsure.ensureXPathNotNull | public static void ensureXPathNotNull(Node node, String expression) {
if (node == null) {
throw LOG.unableToFindXPathExpression(expression);
}
} | java | public static void ensureXPathNotNull(Node node, String expression) {
if (node == null) {
throw LOG.unableToFindXPathExpression(expression);
}
} | [
"public",
"static",
"void",
"ensureXPathNotNull",
"(",
"Node",
"node",
",",
"String",
"expression",
")",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"throw",
"LOG",
".",
"unableToFindXPathExpression",
"(",
"expression",
")",
";",
"}",
"}"
] | Ensure that the node is not null.
@param node the node to ensure to be not null
@param expression the expression was used to find the node
@throws SpinXPathException if the node is null | [
"Ensure",
"that",
"the",
"node",
"is",
"not",
"null",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/util/DomXmlEnsure.java#L72-L76 | train |
camunda/camunda-spin | dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/util/DomXmlEnsure.java | DomXmlEnsure.ensureXPathNotEmpty | public static void ensureXPathNotEmpty(NodeList nodeList, String expression) {
if (nodeList == null || nodeList.getLength() == 0) {
throw LOG.unableToFindXPathExpression(expression);
}
} | java | public static void ensureXPathNotEmpty(NodeList nodeList, String expression) {
if (nodeList == null || nodeList.getLength() == 0) {
throw LOG.unableToFindXPathExpression(expression);
}
} | [
"public",
"static",
"void",
"ensureXPathNotEmpty",
"(",
"NodeList",
"nodeList",
",",
"String",
"expression",
")",
"{",
"if",
"(",
"nodeList",
"==",
"null",
"||",
"nodeList",
".",
"getLength",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"LOG",
".",
"unableToFin... | Ensure that the nodeList is either null or empty.
@param nodeList the nodeList to ensure to be either null or empty
@param expression the expression was used to fine the nodeList
@throws SpinXPathException if the nodeList is either null or empty | [
"Ensure",
"that",
"the",
"nodeList",
"is",
"either",
"null",
"or",
"empty",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/util/DomXmlEnsure.java#L85-L89 | train |
camunda/camunda-spin | dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormat.java | JacksonJsonDataFormat.getCanonicalTypeName | public String getCanonicalTypeName(Object object) {
ensureNotNull("object", object);
for (TypeDetector typeDetector : typeDetectors) {
if (typeDetector.canHandle(object)) {
return typeDetector.detectType(object);
}
}
throw LOG.unableToDetectCanonicalType(object);
} | java | public String getCanonicalTypeName(Object object) {
ensureNotNull("object", object);
for (TypeDetector typeDetector : typeDetectors) {
if (typeDetector.canHandle(object)) {
return typeDetector.detectType(object);
}
}
throw LOG.unableToDetectCanonicalType(object);
} | [
"public",
"String",
"getCanonicalTypeName",
"(",
"Object",
"object",
")",
"{",
"ensureNotNull",
"(",
"\"object\"",
",",
"object",
")",
";",
"for",
"(",
"TypeDetector",
"typeDetector",
":",
"typeDetectors",
")",
"{",
"if",
"(",
"typeDetector",
".",
"canHandle",
... | Identifies the canonical type of an object heuristically.
@return the canonical type identifier of the object's class
according to Jackson's type format (see {@link TypeFactory#constructFromCanonical(String)}) | [
"Identifies",
"the",
"canonical",
"type",
"of",
"an",
"object",
"heuristically",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormat.java#L143-L153 | train |
camunda/camunda-spin | dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/format/DomXmlDataFormatWriter.java | DomXmlDataFormatWriter.getTransformer | protected Transformer getTransformer() {
TransformerFactory transformerFactory = domXmlDataFormat.getTransformerFactory();
try {
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
return transformer;
}
catch (TransformerConfigurationException e) {
throw LOG.unableToCreateTransformer(e);
}
} | java | protected Transformer getTransformer() {
TransformerFactory transformerFactory = domXmlDataFormat.getTransformerFactory();
try {
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
return transformer;
}
catch (TransformerConfigurationException e) {
throw LOG.unableToCreateTransformer(e);
}
} | [
"protected",
"Transformer",
"getTransformer",
"(",
")",
"{",
"TransformerFactory",
"transformerFactory",
"=",
"domXmlDataFormat",
".",
"getTransformerFactory",
"(",
")",
";",
"try",
"{",
"Transformer",
"transformer",
"=",
"transformerFactory",
".",
"newTransformer",
"("... | Returns a configured transformer to write XML.
@return the XML configured transformer
@throws SpinXmlElementException if no new transformer can be created | [
"Returns",
"a",
"configured",
"transformer",
"to",
"write",
"XML",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/format/DomXmlDataFormatWriter.java#L70-L82 | train |
camunda/camunda-spin | core/src/main/java/org/camunda/spin/impl/util/SpinReflectUtil.java | SpinReflectUtil.loadClass | public static Class<?> loadClass(String classname, DataFormat<?> dataFormat) {
// first try context classoader
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if(cl != null) {
LOG.tryLoadingClass(classname, cl);
try {
return cl.loadClass(classname);
}
catch(Exception e) {
// ignore
}
}
// else try the classloader which loaded the dataformat
cl = dataFormat.getClass().getClassLoader();
try {
LOG.tryLoadingClass(classname, cl);
return cl.loadClass(classname);
}
catch (ClassNotFoundException e) {
throw LOG.classNotFound(classname, e);
}
} | java | public static Class<?> loadClass(String classname, DataFormat<?> dataFormat) {
// first try context classoader
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if(cl != null) {
LOG.tryLoadingClass(classname, cl);
try {
return cl.loadClass(classname);
}
catch(Exception e) {
// ignore
}
}
// else try the classloader which loaded the dataformat
cl = dataFormat.getClass().getClassLoader();
try {
LOG.tryLoadingClass(classname, cl);
return cl.loadClass(classname);
}
catch (ClassNotFoundException e) {
throw LOG.classNotFound(classname, e);
}
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"loadClass",
"(",
"String",
"classname",
",",
"DataFormat",
"<",
"?",
">",
"dataFormat",
")",
"{",
"// first try context classoader",
"ClassLoader",
"cl",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getConte... | Used by dataformats if they need to load a class
@param classname the name of the
@param dataFormat
@return | [
"Used",
"by",
"dataformats",
"if",
"they",
"need",
"to",
"load",
"a",
"class"
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/core/src/main/java/org/camunda/spin/impl/util/SpinReflectUtil.java#L37-L61 | train |
camunda/camunda-spin | core/src/main/java/org/camunda/spin/scripting/SpinScriptEnv.java | SpinScriptEnv.getExtension | public static String getExtension(String language) {
language = language.toLowerCase();
if("ecmascript".equals(language)) {
language = "javascript";
}
return extensions.get(language);
} | java | public static String getExtension(String language) {
language = language.toLowerCase();
if("ecmascript".equals(language)) {
language = "javascript";
}
return extensions.get(language);
} | [
"public",
"static",
"String",
"getExtension",
"(",
"String",
"language",
")",
"{",
"language",
"=",
"language",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"\"ecmascript\"",
".",
"equals",
"(",
"language",
")",
")",
"{",
"language",
"=",
"\"javascript\"",
... | Get file extension for script language.
@param language the language name
@return the file extension as string or null if the language is not in the set of languages supported by spin | [
"Get",
"file",
"extension",
"for",
"script",
"language",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/core/src/main/java/org/camunda/spin/scripting/SpinScriptEnv.java#L62-L68 | train |
camunda/camunda-spin | core/src/main/java/org/camunda/spin/scripting/SpinScriptEnv.java | SpinScriptEnv.get | public static String get(String language) {
language = language.toLowerCase();
if("ecmascript".equals(language)) {
language = "javascript";
}
String extension = extensions.get(language);
if(extension == null) {
return null;
} else {
return loadScriptEnv(language, extension);
}
} | java | public static String get(String language) {
language = language.toLowerCase();
if("ecmascript".equals(language)) {
language = "javascript";
}
String extension = extensions.get(language);
if(extension == null) {
return null;
} else {
return loadScriptEnv(language, extension);
}
} | [
"public",
"static",
"String",
"get",
"(",
"String",
"language",
")",
"{",
"language",
"=",
"language",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"\"ecmascript\"",
".",
"equals",
"(",
"language",
")",
")",
"{",
"language",
"=",
"\"javascript\"",
";",
... | Get the spin scripting environment
@param language the language name
@return the environment script as string or null if the language is
not in the set of languages supported by spin. | [
"Get",
"the",
"spin",
"scripting",
"environment"
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/core/src/main/java/org/camunda/spin/scripting/SpinScriptEnv.java#L77-L91 | train |
camunda/camunda-spin | dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonNode.java | JacksonJsonNode.getCorrectIndex | protected Integer getCorrectIndex(Integer index) {
Integer size = jsonNode.size();
Integer newIndex = index;
// reverse walking through the array
if(index < 0) {
newIndex = size + index;
}
// the negative index would be greater than the size a second time!
if(newIndex < 0) {
throw LOG.indexOutOfBounds(index, size);
}
// the index is greater as the actual size
if(index > size) {
throw LOG.indexOutOfBounds(index, size);
}
return newIndex;
} | java | protected Integer getCorrectIndex(Integer index) {
Integer size = jsonNode.size();
Integer newIndex = index;
// reverse walking through the array
if(index < 0) {
newIndex = size + index;
}
// the negative index would be greater than the size a second time!
if(newIndex < 0) {
throw LOG.indexOutOfBounds(index, size);
}
// the index is greater as the actual size
if(index > size) {
throw LOG.indexOutOfBounds(index, size);
}
return newIndex;
} | [
"protected",
"Integer",
"getCorrectIndex",
"(",
"Integer",
"index",
")",
"{",
"Integer",
"size",
"=",
"jsonNode",
".",
"size",
"(",
")",
";",
"Integer",
"newIndex",
"=",
"index",
";",
"// reverse walking through the array",
"if",
"(",
"index",
"<",
"0",
")",
... | fetch correct array index if index is less than 0
ArrayNode will convert all negative integers into 0...
@param index wanted index
@return {@link Integer} new index | [
"fetch",
"correct",
"array",
"index",
"if",
"index",
"is",
"less",
"than",
"0"
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonNode.java#L92-L112 | train |
camunda/camunda-spin | dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/query/DomXPathNamespaceResolver.java | DomXPathNamespaceResolver.setNamespace | public void setNamespace(String prefix, String namespaceURI) {
ensureNotNull("Prefix", prefix);
ensureNotNull("Namespace URI", namespaceURI);
namespaces.put(prefix, namespaceURI);
} | java | public void setNamespace(String prefix, String namespaceURI) {
ensureNotNull("Prefix", prefix);
ensureNotNull("Namespace URI", namespaceURI);
namespaces.put(prefix, namespaceURI);
} | [
"public",
"void",
"setNamespace",
"(",
"String",
"prefix",
",",
"String",
"namespaceURI",
")",
"{",
"ensureNotNull",
"(",
"\"Prefix\"",
",",
"prefix",
")",
";",
"ensureNotNull",
"(",
"\"Namespace URI\"",
",",
"namespaceURI",
")",
";",
"namespaces",
".",
"put",
... | Maps a single prefix, uri pair as namespace.
@param prefix the prefix to use
@param namespaceURI the URI to use
@throws IllegalArgumentException if prefix or namespaceURI is null | [
"Maps",
"a",
"single",
"prefix",
"uri",
"pair",
"as",
"namespace",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/query/DomXPathNamespaceResolver.java#L144-L149 | train |
camunda/camunda-spin | core/src/main/java/org/camunda/spin/Spin.java | Spin.S | public static <T extends Spin<?>> T S(Object input, DataFormat<T> format) {
return SpinFactory.INSTANCE.createSpin(input, format);
} | java | public static <T extends Spin<?>> T S(Object input, DataFormat<T> format) {
return SpinFactory.INSTANCE.createSpin(input, format);
} | [
"public",
"static",
"<",
"T",
"extends",
"Spin",
"<",
"?",
">",
">",
"T",
"S",
"(",
"Object",
"input",
",",
"DataFormat",
"<",
"T",
">",
"format",
")",
"{",
"return",
"SpinFactory",
".",
"INSTANCE",
".",
"createSpin",
"(",
"input",
",",
"format",
")"... | Creates a spin wrapper for a data input of a given data format.
@param input the input to wrap
@param format the data format of the input
@return the spin wrapper for the input
@throws IllegalArgumentException in case an argument of illegal type is provided (such as 'null') | [
"Creates",
"a",
"spin",
"wrapper",
"for",
"a",
"data",
"input",
"of",
"a",
"given",
"data",
"format",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/core/src/main/java/org/camunda/spin/Spin.java#L41-L43 | train |
camunda/camunda-spin | core/src/main/java/org/camunda/spin/Spin.java | Spin.XML | public static SpinXmlElement XML(Object input) {
return SpinFactory.INSTANCE.createSpin(input, DataFormats.xml());
} | java | public static SpinXmlElement XML(Object input) {
return SpinFactory.INSTANCE.createSpin(input, DataFormats.xml());
} | [
"public",
"static",
"SpinXmlElement",
"XML",
"(",
"Object",
"input",
")",
"{",
"return",
"SpinFactory",
".",
"INSTANCE",
".",
"createSpin",
"(",
"input",
",",
"DataFormats",
".",
"xml",
"(",
")",
")",
";",
"}"
] | Creates a spin wrapper for a data input. The data format of the
input is assumed to be XML.
@param input the input to wrap
@return the spin wrapper for the input
@throws IllegalArgumentException in case an argument of illegal type is provided (such as 'null') | [
"Creates",
"a",
"spin",
"wrapper",
"for",
"a",
"data",
"input",
".",
"The",
"data",
"format",
"of",
"the",
"input",
"is",
"assumed",
"to",
"be",
"XML",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/core/src/main/java/org/camunda/spin/Spin.java#L80-L82 | train |
camunda/camunda-spin | core/src/main/java/org/camunda/spin/Spin.java | Spin.JSON | public static SpinJsonNode JSON(Object input) {
return SpinFactory.INSTANCE.createSpin(input, DataFormats.json());
} | java | public static SpinJsonNode JSON(Object input) {
return SpinFactory.INSTANCE.createSpin(input, DataFormats.json());
} | [
"public",
"static",
"SpinJsonNode",
"JSON",
"(",
"Object",
"input",
")",
"{",
"return",
"SpinFactory",
".",
"INSTANCE",
".",
"createSpin",
"(",
"input",
",",
"DataFormats",
".",
"json",
"(",
")",
")",
";",
"}"
] | Creates a spin wrapper for a data input. The data format of the
input is assumed to be JSON.
@param input the input to wrap
@return the spin wrapper for the input
@throws IllegalArgumentException in case an argument of illegal type is provided (such as 'null') | [
"Creates",
"a",
"spin",
"wrapper",
"for",
"a",
"data",
"input",
".",
"The",
"data",
"format",
"of",
"the",
"input",
"is",
"assumed",
"to",
"be",
"JSON",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/core/src/main/java/org/camunda/spin/Spin.java#L93-L95 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreEmulator.java | DatastoreEmulator.stop | public synchronized void stop() throws DatastoreEmulatorException {
// We intentionally don't check the internal state. If people want to try and stop the server
// multiple times that's fine.
stopEmulatorInternal();
if (state != State.STOPPED) {
state = State.STOPPED;
if (projectDirectory != null) {
try {
Process process =
new ProcessBuilder("rm", "-r", projectDirectory.getAbsolutePath()).start();
if (process.waitFor() != 0) {
throw new IOException(
"Temporary project directory deletion exited with " + process.exitValue());
}
} catch (IOException e) {
throw new IllegalStateException("Could not delete temporary project directory", e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Could not delete temporary project directory", e);
}
}
}
} | java | public synchronized void stop() throws DatastoreEmulatorException {
// We intentionally don't check the internal state. If people want to try and stop the server
// multiple times that's fine.
stopEmulatorInternal();
if (state != State.STOPPED) {
state = State.STOPPED;
if (projectDirectory != null) {
try {
Process process =
new ProcessBuilder("rm", "-r", projectDirectory.getAbsolutePath()).start();
if (process.waitFor() != 0) {
throw new IOException(
"Temporary project directory deletion exited with " + process.exitValue());
}
} catch (IOException e) {
throw new IllegalStateException("Could not delete temporary project directory", e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Could not delete temporary project directory", e);
}
}
}
} | [
"public",
"synchronized",
"void",
"stop",
"(",
")",
"throws",
"DatastoreEmulatorException",
"{",
"// We intentionally don't check the internal state. If people want to try and stop the server",
"// multiple times that's fine.",
"stopEmulatorInternal",
"(",
")",
";",
"if",
"(",
"sta... | Stops the emulator. Multiple calls are allowed.
@throws DatastoreEmulatorException if the emulator cannot be stopped | [
"Stops",
"the",
"emulator",
".",
"Multiple",
"calls",
"are",
"allowed",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreEmulator.java#L221-L243 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreEmulator.java | DatastoreEmulator.sendEmptyRequest | private void sendEmptyRequest(String path, String method) throws DatastoreEmulatorException {
HttpURLConnection connection = null;
try {
URL url = new URL(this.host + path);
connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod(method);
connection.getOutputStream().close();
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new DatastoreEmulatorException(
String.format(
"%s request to %s returned HTTP status %s",
method, path, connection.getResponseCode()));
}
} catch (IOException e) {
throw new DatastoreEmulatorException(
String.format("Exception connecting to emulator on %s request to %s", method, path), e);
} finally {
if (connection != null) {
connection.disconnect();
}
}
} | java | private void sendEmptyRequest(String path, String method) throws DatastoreEmulatorException {
HttpURLConnection connection = null;
try {
URL url = new URL(this.host + path);
connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod(method);
connection.getOutputStream().close();
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new DatastoreEmulatorException(
String.format(
"%s request to %s returned HTTP status %s",
method, path, connection.getResponseCode()));
}
} catch (IOException e) {
throw new DatastoreEmulatorException(
String.format("Exception connecting to emulator on %s request to %s", method, path), e);
} finally {
if (connection != null) {
connection.disconnect();
}
}
} | [
"private",
"void",
"sendEmptyRequest",
"(",
"String",
"path",
",",
"String",
"method",
")",
"throws",
"DatastoreEmulatorException",
"{",
"HttpURLConnection",
"connection",
"=",
"null",
";",
"try",
"{",
"URL",
"url",
"=",
"new",
"URL",
"(",
"this",
".",
"host",... | Send an empty request using a standard HTTP connection. | [
"Send",
"an",
"empty",
"request",
"using",
"a",
"standard",
"HTTP",
"connection",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreEmulator.java#L308-L330 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/RemoteRpc.java | RemoteRpc.call | public InputStream call(String methodName, MessageLite request) throws DatastoreException {
logger.fine("remote datastore call " + methodName);
long startTime = System.currentTimeMillis();
try {
HttpResponse httpResponse;
try {
rpcCount.incrementAndGet();
ProtoHttpContent payload = new ProtoHttpContent(request);
HttpRequest httpRequest = client.buildPostRequest(resolveURL(methodName), payload);
httpRequest.getHeaders().put(API_FORMAT_VERSION_HEADER, API_FORMAT_VERSION);
// Don't throw an HTTPResponseException on error. It converts the response to a String and
// throws away the original, whereas we need the raw bytes to parse it as a proto.
httpRequest.setThrowExceptionOnExecuteError(false);
// Datastore requests typically time out after 60s; set the read timeout to slightly longer
// than that by default (can be overridden via the HttpRequestInitializer).
httpRequest.setReadTimeout(65 * 1000);
if (initializer != null) {
initializer.initialize(httpRequest);
}
httpResponse = httpRequest.execute();
if (!httpResponse.isSuccessStatusCode()) {
try (InputStream content = GzipFixingInputStream.maybeWrap(httpResponse.getContent())) {
throw makeException(url, methodName, content,
httpResponse.getContentType(), httpResponse.getContentCharset(), null,
httpResponse.getStatusCode());
}
}
return GzipFixingInputStream.maybeWrap(httpResponse.getContent());
} catch (SocketTimeoutException e) {
throw makeException(url, methodName, Code.DEADLINE_EXCEEDED, "Deadline exceeded", e);
} catch (IOException e) {
throw makeException(url, methodName, Code.UNAVAILABLE, "I/O error", e);
}
} finally {
long elapsedTime = System.currentTimeMillis() - startTime;
logger.fine("remote datastore call " + methodName + " took " + elapsedTime + " ms");
}
} | java | public InputStream call(String methodName, MessageLite request) throws DatastoreException {
logger.fine("remote datastore call " + methodName);
long startTime = System.currentTimeMillis();
try {
HttpResponse httpResponse;
try {
rpcCount.incrementAndGet();
ProtoHttpContent payload = new ProtoHttpContent(request);
HttpRequest httpRequest = client.buildPostRequest(resolveURL(methodName), payload);
httpRequest.getHeaders().put(API_FORMAT_VERSION_HEADER, API_FORMAT_VERSION);
// Don't throw an HTTPResponseException on error. It converts the response to a String and
// throws away the original, whereas we need the raw bytes to parse it as a proto.
httpRequest.setThrowExceptionOnExecuteError(false);
// Datastore requests typically time out after 60s; set the read timeout to slightly longer
// than that by default (can be overridden via the HttpRequestInitializer).
httpRequest.setReadTimeout(65 * 1000);
if (initializer != null) {
initializer.initialize(httpRequest);
}
httpResponse = httpRequest.execute();
if (!httpResponse.isSuccessStatusCode()) {
try (InputStream content = GzipFixingInputStream.maybeWrap(httpResponse.getContent())) {
throw makeException(url, methodName, content,
httpResponse.getContentType(), httpResponse.getContentCharset(), null,
httpResponse.getStatusCode());
}
}
return GzipFixingInputStream.maybeWrap(httpResponse.getContent());
} catch (SocketTimeoutException e) {
throw makeException(url, methodName, Code.DEADLINE_EXCEEDED, "Deadline exceeded", e);
} catch (IOException e) {
throw makeException(url, methodName, Code.UNAVAILABLE, "I/O error", e);
}
} finally {
long elapsedTime = System.currentTimeMillis() - startTime;
logger.fine("remote datastore call " + methodName + " took " + elapsedTime + " ms");
}
} | [
"public",
"InputStream",
"call",
"(",
"String",
"methodName",
",",
"MessageLite",
"request",
")",
"throws",
"DatastoreException",
"{",
"logger",
".",
"fine",
"(",
"\"remote datastore call \"",
"+",
"methodName",
")",
";",
"long",
"startTime",
"=",
"System",
".",
... | Makes an RPC call using the client. Logs how long it took and any exceptions.
NOTE: The request could be an InputStream too, but the http client will need to
find its length, which will require buffering it anyways.
@throws DatastoreException if the RPC fails. | [
"Makes",
"an",
"RPC",
"call",
"using",
"the",
"client",
".",
"Logs",
"how",
"long",
"it",
"took",
"and",
"any",
"exceptions",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/RemoteRpc.java#L163-L201 | train |
GoogleCloudPlatform/google-cloud-datastore | java/demos/src/main/java/com/google/datastore/v1/demos/guestbook/Guestbook.java | Guestbook.addGreeting | private void addGreeting(String guestbookName, String user, String message)
throws DatastoreException {
Entity.Builder greeting = Entity.newBuilder();
greeting.setKey(makeKey(GUESTBOOK_KIND, guestbookName, GREETING_KIND));
greeting.getMutableProperties().put(USER_PROPERTY, makeValue(user).build());
greeting.getMutableProperties().put(MESSAGE_PROPERTY, makeValue(message).build());
greeting.getMutableProperties().put(DATE_PROPERTY, makeValue(new Date()).build());
Key greetingKey = insert(greeting.build());
System.out.println("greeting key is: " + greetingKey);
} | java | private void addGreeting(String guestbookName, String user, String message)
throws DatastoreException {
Entity.Builder greeting = Entity.newBuilder();
greeting.setKey(makeKey(GUESTBOOK_KIND, guestbookName, GREETING_KIND));
greeting.getMutableProperties().put(USER_PROPERTY, makeValue(user).build());
greeting.getMutableProperties().put(MESSAGE_PROPERTY, makeValue(message).build());
greeting.getMutableProperties().put(DATE_PROPERTY, makeValue(new Date()).build());
Key greetingKey = insert(greeting.build());
System.out.println("greeting key is: " + greetingKey);
} | [
"private",
"void",
"addGreeting",
"(",
"String",
"guestbookName",
",",
"String",
"user",
",",
"String",
"message",
")",
"throws",
"DatastoreException",
"{",
"Entity",
".",
"Builder",
"greeting",
"=",
"Entity",
".",
"newBuilder",
"(",
")",
";",
"greeting",
".",... | Add a greeting to the specified guestbook. | [
"Add",
"a",
"greeting",
"to",
"the",
"specified",
"guestbook",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/demos/src/main/java/com/google/datastore/v1/demos/guestbook/Guestbook.java#L112-L121 | train |
GoogleCloudPlatform/google-cloud-datastore | java/demos/src/main/java/com/google/datastore/v1/demos/guestbook/Guestbook.java | Guestbook.listGreetings | private void listGreetings(String guestbookName) throws DatastoreException {
Query.Builder query = Query.newBuilder();
query.addKindBuilder().setName(GREETING_KIND);
query.setFilter(makeFilter(KEY_PROPERTY, PropertyFilter.Operator.HAS_ANCESTOR,
makeValue(makeKey(GUESTBOOK_KIND, guestbookName))));
query.addOrder(makeOrder(DATE_PROPERTY, PropertyOrder.Direction.DESCENDING));
List<Entity> greetings = runQuery(query.build());
if (greetings.size() == 0) {
System.out.println("no greetings in " + guestbookName);
}
for (Entity greeting : greetings) {
Map<String, Value> propertyMap = greeting.getProperties();
System.out.println(
DatastoreHelper.toDate(propertyMap.get(DATE_PROPERTY)) + ": " +
DatastoreHelper.getString(propertyMap.get(USER_PROPERTY)) + " says " +
DatastoreHelper.getString(propertyMap.get(MESSAGE_PROPERTY)));
}
} | java | private void listGreetings(String guestbookName) throws DatastoreException {
Query.Builder query = Query.newBuilder();
query.addKindBuilder().setName(GREETING_KIND);
query.setFilter(makeFilter(KEY_PROPERTY, PropertyFilter.Operator.HAS_ANCESTOR,
makeValue(makeKey(GUESTBOOK_KIND, guestbookName))));
query.addOrder(makeOrder(DATE_PROPERTY, PropertyOrder.Direction.DESCENDING));
List<Entity> greetings = runQuery(query.build());
if (greetings.size() == 0) {
System.out.println("no greetings in " + guestbookName);
}
for (Entity greeting : greetings) {
Map<String, Value> propertyMap = greeting.getProperties();
System.out.println(
DatastoreHelper.toDate(propertyMap.get(DATE_PROPERTY)) + ": " +
DatastoreHelper.getString(propertyMap.get(USER_PROPERTY)) + " says " +
DatastoreHelper.getString(propertyMap.get(MESSAGE_PROPERTY)));
}
} | [
"private",
"void",
"listGreetings",
"(",
"String",
"guestbookName",
")",
"throws",
"DatastoreException",
"{",
"Query",
".",
"Builder",
"query",
"=",
"Query",
".",
"newBuilder",
"(",
")",
";",
"query",
".",
"addKindBuilder",
"(",
")",
".",
"setName",
"(",
"GR... | List the greetings in the specified guestbook. | [
"List",
"the",
"greetings",
"in",
"the",
"specified",
"guestbook",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/demos/src/main/java/com/google/datastore/v1/demos/guestbook/Guestbook.java#L126-L144 | train |
GoogleCloudPlatform/google-cloud-datastore | java/demos/src/main/java/com/google/datastore/v1/demos/guestbook/Guestbook.java | Guestbook.insert | private Key insert(Entity entity) throws DatastoreException {
CommitRequest req = CommitRequest.newBuilder()
.addMutations(Mutation.newBuilder()
.setInsert(entity))
.setMode(CommitRequest.Mode.NON_TRANSACTIONAL)
.build();
return datastore.commit(req).getMutationResults(0).getKey();
} | java | private Key insert(Entity entity) throws DatastoreException {
CommitRequest req = CommitRequest.newBuilder()
.addMutations(Mutation.newBuilder()
.setInsert(entity))
.setMode(CommitRequest.Mode.NON_TRANSACTIONAL)
.build();
return datastore.commit(req).getMutationResults(0).getKey();
} | [
"private",
"Key",
"insert",
"(",
"Entity",
"entity",
")",
"throws",
"DatastoreException",
"{",
"CommitRequest",
"req",
"=",
"CommitRequest",
".",
"newBuilder",
"(",
")",
".",
"addMutations",
"(",
"Mutation",
".",
"newBuilder",
"(",
")",
".",
"setInsert",
"(",
... | Insert an entity into the datastore.
The entity must have no ids.
@return The key for the inserted entity.
@throws DatastoreException on error | [
"Insert",
"an",
"entity",
"into",
"the",
"datastore",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/demos/src/main/java/com/google/datastore/v1/demos/guestbook/Guestbook.java#L154-L161 | train |
GoogleCloudPlatform/google-cloud-datastore | java/demos/src/main/java/com/google/datastore/v1/demos/guestbook/Guestbook.java | Guestbook.runQuery | private List<Entity> runQuery(Query query) throws DatastoreException {
RunQueryRequest.Builder request = RunQueryRequest.newBuilder();
request.setQuery(query);
RunQueryResponse response = datastore.runQuery(request.build());
if (response.getBatch().getMoreResults() == QueryResultBatch.MoreResultsType.NOT_FINISHED) {
System.err.println("WARNING: partial results\n");
}
List<EntityResult> results = response.getBatch().getEntityResultsList();
List<Entity> entities = new ArrayList<Entity>(results.size());
for (EntityResult result : results) {
entities.add(result.getEntity());
}
return entities;
} | java | private List<Entity> runQuery(Query query) throws DatastoreException {
RunQueryRequest.Builder request = RunQueryRequest.newBuilder();
request.setQuery(query);
RunQueryResponse response = datastore.runQuery(request.build());
if (response.getBatch().getMoreResults() == QueryResultBatch.MoreResultsType.NOT_FINISHED) {
System.err.println("WARNING: partial results\n");
}
List<EntityResult> results = response.getBatch().getEntityResultsList();
List<Entity> entities = new ArrayList<Entity>(results.size());
for (EntityResult result : results) {
entities.add(result.getEntity());
}
return entities;
} | [
"private",
"List",
"<",
"Entity",
">",
"runQuery",
"(",
"Query",
"query",
")",
"throws",
"DatastoreException",
"{",
"RunQueryRequest",
".",
"Builder",
"request",
"=",
"RunQueryRequest",
".",
"newBuilder",
"(",
")",
";",
"request",
".",
"setQuery",
"(",
"query"... | Run a query on the datastore.
@return The entities returned by the query.
@throws DatastoreException on error | [
"Run",
"a",
"query",
"on",
"the",
"datastore",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/demos/src/main/java/com/google/datastore/v1/demos/guestbook/Guestbook.java#L169-L183 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java | QuerySplitterImpl.validateFilter | private void validateFilter(Filter filter) throws IllegalArgumentException {
switch (filter.getFilterTypeCase()) {
case COMPOSITE_FILTER:
for (Filter subFilter : filter.getCompositeFilter().getFiltersList()) {
validateFilter(subFilter);
}
break;
case PROPERTY_FILTER:
if (UNSUPPORTED_OPERATORS.contains(filter.getPropertyFilter().getOp())) {
throw new IllegalArgumentException("Query cannot have any inequality filters.");
}
break;
default:
throw new IllegalArgumentException(
"Unsupported filter type: " + filter.getFilterTypeCase());
}
} | java | private void validateFilter(Filter filter) throws IllegalArgumentException {
switch (filter.getFilterTypeCase()) {
case COMPOSITE_FILTER:
for (Filter subFilter : filter.getCompositeFilter().getFiltersList()) {
validateFilter(subFilter);
}
break;
case PROPERTY_FILTER:
if (UNSUPPORTED_OPERATORS.contains(filter.getPropertyFilter().getOp())) {
throw new IllegalArgumentException("Query cannot have any inequality filters.");
}
break;
default:
throw new IllegalArgumentException(
"Unsupported filter type: " + filter.getFilterTypeCase());
}
} | [
"private",
"void",
"validateFilter",
"(",
"Filter",
"filter",
")",
"throws",
"IllegalArgumentException",
"{",
"switch",
"(",
"filter",
".",
"getFilterTypeCase",
"(",
")",
")",
"{",
"case",
"COMPOSITE_FILTER",
":",
"for",
"(",
"Filter",
"subFilter",
":",
"filter"... | Validates that we only have allowable filters.
<p>Note that equality and ancestor filters are allowed, however they may result in
inefficient sharding. | [
"Validates",
"that",
"we",
"only",
"have",
"allowable",
"filters",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java#L99-L115 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java | QuerySplitterImpl.validateQuery | private void validateQuery(Query query) throws IllegalArgumentException {
if (query.getKindCount() != 1) {
throw new IllegalArgumentException("Query must have exactly one kind.");
}
if (query.getOrderCount() != 0) {
throw new IllegalArgumentException("Query cannot have any sort orders.");
}
if (query.hasFilter()) {
validateFilter(query.getFilter());
}
} | java | private void validateQuery(Query query) throws IllegalArgumentException {
if (query.getKindCount() != 1) {
throw new IllegalArgumentException("Query must have exactly one kind.");
}
if (query.getOrderCount() != 0) {
throw new IllegalArgumentException("Query cannot have any sort orders.");
}
if (query.hasFilter()) {
validateFilter(query.getFilter());
}
} | [
"private",
"void",
"validateQuery",
"(",
"Query",
"query",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"query",
".",
"getKindCount",
"(",
")",
"!=",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Query must have exactly one kind.\"... | Verifies that the given query can be properly scattered.
@param query the query to verify
@throws IllegalArgumentException if the query is invalid. | [
"Verifies",
"that",
"the",
"given",
"query",
"can",
"be",
"properly",
"scattered",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java#L123-L133 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java | QuerySplitterImpl.getScatterKeys | private List<Key> getScatterKeys(
int numSplits, Query query, PartitionId partition, Datastore datastore)
throws DatastoreException {
Query.Builder scatterPointQuery = createScatterQuery(query, numSplits);
List<Key> keySplits = new ArrayList<Key>();
QueryResultBatch batch;
do {
RunQueryRequest scatterRequest =
RunQueryRequest.newBuilder()
.setPartitionId(partition)
.setQuery(scatterPointQuery)
.build();
batch = datastore.runQuery(scatterRequest).getBatch();
for (EntityResult result : batch.getEntityResultsList()) {
keySplits.add(result.getEntity().getKey());
}
scatterPointQuery.setStartCursor(batch.getEndCursor());
scatterPointQuery.getLimitBuilder().setValue(
scatterPointQuery.getLimit().getValue() - batch.getEntityResultsCount());
} while (batch.getMoreResults() == MoreResultsType.NOT_FINISHED);
Collections.sort(keySplits, DatastoreHelper.getKeyComparator());
return keySplits;
} | java | private List<Key> getScatterKeys(
int numSplits, Query query, PartitionId partition, Datastore datastore)
throws DatastoreException {
Query.Builder scatterPointQuery = createScatterQuery(query, numSplits);
List<Key> keySplits = new ArrayList<Key>();
QueryResultBatch batch;
do {
RunQueryRequest scatterRequest =
RunQueryRequest.newBuilder()
.setPartitionId(partition)
.setQuery(scatterPointQuery)
.build();
batch = datastore.runQuery(scatterRequest).getBatch();
for (EntityResult result : batch.getEntityResultsList()) {
keySplits.add(result.getEntity().getKey());
}
scatterPointQuery.setStartCursor(batch.getEndCursor());
scatterPointQuery.getLimitBuilder().setValue(
scatterPointQuery.getLimit().getValue() - batch.getEntityResultsCount());
} while (batch.getMoreResults() == MoreResultsType.NOT_FINISHED);
Collections.sort(keySplits, DatastoreHelper.getKeyComparator());
return keySplits;
} | [
"private",
"List",
"<",
"Key",
">",
"getScatterKeys",
"(",
"int",
"numSplits",
",",
"Query",
"query",
",",
"PartitionId",
"partition",
",",
"Datastore",
"datastore",
")",
"throws",
"DatastoreException",
"{",
"Query",
".",
"Builder",
"scatterPointQuery",
"=",
"cr... | Gets a list of split keys given a desired number of splits.
<p>This list will contain multiple split keys for each split. Only a single split key
will be chosen as the split point, however providing multiple keys allows for more uniform
sharding.
@param numSplits the number of desired splits.
@param query the user query.
@param partition the partition to run the query in.
@param datastore the datastore containing the data.
@throws DatastoreException if there was an error when executing the datastore query. | [
"Gets",
"a",
"list",
"of",
"split",
"keys",
"given",
"a",
"desired",
"number",
"of",
"splits",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java#L178-L202 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java | QuerySplitterImpl.createScatterQuery | private Query.Builder createScatterQuery(Query query, int numSplits) {
// TODO(pcostello): We can potentially support better splits with equality filters in our query
// if there exists a composite index on property, __scatter__, __key__. Until an API for
// metadata exists, this isn't possible. Note that ancestor and inequality queries fall into
// the same category.
Query.Builder scatterPointQuery = Query.newBuilder();
scatterPointQuery.addAllKind(query.getKindList());
scatterPointQuery.addOrder(DatastoreHelper.makeOrder(
DatastoreHelper.SCATTER_PROPERTY_NAME, Direction.ASCENDING));
// There is a split containing entities before and after each scatter entity:
// ||---*------*------*------*------*------*------*---|| = scatter entity
// If we represent each split as a region before a scatter entity, there is an extra region
// following the last scatter point. Thus, we do not need the scatter entities for the last
// region.
scatterPointQuery.getLimitBuilder().setValue((numSplits - 1) * KEYS_PER_SPLIT);
scatterPointQuery.addProjection(Projection.newBuilder().setProperty(
PropertyReference.newBuilder().setName("__key__")));
return scatterPointQuery;
} | java | private Query.Builder createScatterQuery(Query query, int numSplits) {
// TODO(pcostello): We can potentially support better splits with equality filters in our query
// if there exists a composite index on property, __scatter__, __key__. Until an API for
// metadata exists, this isn't possible. Note that ancestor and inequality queries fall into
// the same category.
Query.Builder scatterPointQuery = Query.newBuilder();
scatterPointQuery.addAllKind(query.getKindList());
scatterPointQuery.addOrder(DatastoreHelper.makeOrder(
DatastoreHelper.SCATTER_PROPERTY_NAME, Direction.ASCENDING));
// There is a split containing entities before and after each scatter entity:
// ||---*------*------*------*------*------*------*---|| = scatter entity
// If we represent each split as a region before a scatter entity, there is an extra region
// following the last scatter point. Thus, we do not need the scatter entities for the last
// region.
scatterPointQuery.getLimitBuilder().setValue((numSplits - 1) * KEYS_PER_SPLIT);
scatterPointQuery.addProjection(Projection.newBuilder().setProperty(
PropertyReference.newBuilder().setName("__key__")));
return scatterPointQuery;
} | [
"private",
"Query",
".",
"Builder",
"createScatterQuery",
"(",
"Query",
"query",
",",
"int",
"numSplits",
")",
"{",
"// TODO(pcostello): We can potentially support better splits with equality filters in our query",
"// if there exists a composite index on property, __scatter__, __key__. ... | Creates a scatter query from the given user query
@param query the user's query.
@param numSplits the number of splits to create. | [
"Creates",
"a",
"scatter",
"query",
"from",
"the",
"given",
"user",
"query"
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java#L210-L228 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java | QuerySplitterImpl.getSplitKey | private Iterable<Key> getSplitKey(List<Key> keys, int numSplits) {
// If the number of keys is less than the number of splits, we are limited in the number of
// splits we can make.
if (keys.size() < numSplits - 1) {
return keys;
}
// Calculate the number of keys per split. This should be KEYS_PER_SPLIT, but may
// be less if there are not KEYS_PER_SPLIT * (numSplits - 1) scatter entities.
//
// Consider the following dataset, where - represents an entity and * represents an entity
// that is returned as a scatter entity:
// ||---*-----*----*-----*-----*------*----*----||
// If we want 4 splits in this data, the optimal split would look like:
// ||---*-----*----*-----*-----*------*----*----||
// | | |
// The scatter keys in the last region are not useful to us, so we never request them:
// ||---*-----*----*-----*-----*------*---------||
// | | |
// With 6 scatter keys we want to set scatter points at indexes: 1, 3, 5.
//
// We keep this as a double so that any "fractional" keys per split get distributed throughout
// the splits and don't make the last split significantly larger than the rest.
double numKeysPerSplit = Math.max(1.0, ((double) keys.size()) / (numSplits - 1));
List<Key> keysList = new ArrayList<Key>(numSplits - 1);
// Grab the last sample for each split, otherwise the first split will be too small.
for (int i = 1; i < numSplits; i++) {
int splitIndex = (int) Math.round(i * numKeysPerSplit) - 1;
keysList.add(keys.get(splitIndex));
}
return keysList;
} | java | private Iterable<Key> getSplitKey(List<Key> keys, int numSplits) {
// If the number of keys is less than the number of splits, we are limited in the number of
// splits we can make.
if (keys.size() < numSplits - 1) {
return keys;
}
// Calculate the number of keys per split. This should be KEYS_PER_SPLIT, but may
// be less if there are not KEYS_PER_SPLIT * (numSplits - 1) scatter entities.
//
// Consider the following dataset, where - represents an entity and * represents an entity
// that is returned as a scatter entity:
// ||---*-----*----*-----*-----*------*----*----||
// If we want 4 splits in this data, the optimal split would look like:
// ||---*-----*----*-----*-----*------*----*----||
// | | |
// The scatter keys in the last region are not useful to us, so we never request them:
// ||---*-----*----*-----*-----*------*---------||
// | | |
// With 6 scatter keys we want to set scatter points at indexes: 1, 3, 5.
//
// We keep this as a double so that any "fractional" keys per split get distributed throughout
// the splits and don't make the last split significantly larger than the rest.
double numKeysPerSplit = Math.max(1.0, ((double) keys.size()) / (numSplits - 1));
List<Key> keysList = new ArrayList<Key>(numSplits - 1);
// Grab the last sample for each split, otherwise the first split will be too small.
for (int i = 1; i < numSplits; i++) {
int splitIndex = (int) Math.round(i * numKeysPerSplit) - 1;
keysList.add(keys.get(splitIndex));
}
return keysList;
} | [
"private",
"Iterable",
"<",
"Key",
">",
"getSplitKey",
"(",
"List",
"<",
"Key",
">",
"keys",
",",
"int",
"numSplits",
")",
"{",
"// If the number of keys is less than the number of splits, we are limited in the number of",
"// splits we can make.",
"if",
"(",
"keys",
".",... | Given a list of keys and a number of splits find the keys to split on.
@param keys the list of keys.
@param numSplits the number of splits. | [
"Given",
"a",
"list",
"of",
"keys",
"and",
"a",
"number",
"of",
"splits",
"find",
"the",
"keys",
"to",
"split",
"on",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java#L236-L269 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreFactory.java | DatastoreFactory.makeClient | public HttpRequestFactory makeClient(DatastoreOptions options) {
Credential credential = options.getCredential();
HttpTransport transport = options.getTransport();
if (transport == null) {
transport = credential == null ? new NetHttpTransport() : credential.getTransport();
transport = transport == null ? new NetHttpTransport() : transport;
}
return transport.createRequestFactory(credential);
} | java | public HttpRequestFactory makeClient(DatastoreOptions options) {
Credential credential = options.getCredential();
HttpTransport transport = options.getTransport();
if (transport == null) {
transport = credential == null ? new NetHttpTransport() : credential.getTransport();
transport = transport == null ? new NetHttpTransport() : transport;
}
return transport.createRequestFactory(credential);
} | [
"public",
"HttpRequestFactory",
"makeClient",
"(",
"DatastoreOptions",
"options",
")",
"{",
"Credential",
"credential",
"=",
"options",
".",
"getCredential",
"(",
")",
";",
"HttpTransport",
"transport",
"=",
"options",
".",
"getTransport",
"(",
")",
";",
"if",
"... | Constructs a Google APIs HTTP client with the associated credentials. | [
"Constructs",
"a",
"Google",
"APIs",
"HTTP",
"client",
"with",
"the",
"associated",
"credentials",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreFactory.java#L71-L79 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreFactory.java | DatastoreFactory.buildProjectEndpoint | String buildProjectEndpoint(DatastoreOptions options) {
if (options.getProjectEndpoint() != null) {
return options.getProjectEndpoint();
}
// DatastoreOptions ensures either project endpoint or project ID is set.
String projectId = checkNotNull(options.getProjectId());
if (options.getHost() != null) {
return validateUrl(String.format("https://%s/%s/projects/%s",
options.getHost(), VERSION, projectId));
} else if (options.getLocalHost() != null) {
return validateUrl(String.format("http://%s/%s/projects/%s",
options.getLocalHost(), VERSION, projectId));
}
return validateUrl(String.format("%s/%s/projects/%s",
DEFAULT_HOST, VERSION, projectId));
} | java | String buildProjectEndpoint(DatastoreOptions options) {
if (options.getProjectEndpoint() != null) {
return options.getProjectEndpoint();
}
// DatastoreOptions ensures either project endpoint or project ID is set.
String projectId = checkNotNull(options.getProjectId());
if (options.getHost() != null) {
return validateUrl(String.format("https://%s/%s/projects/%s",
options.getHost(), VERSION, projectId));
} else if (options.getLocalHost() != null) {
return validateUrl(String.format("http://%s/%s/projects/%s",
options.getLocalHost(), VERSION, projectId));
}
return validateUrl(String.format("%s/%s/projects/%s",
DEFAULT_HOST, VERSION, projectId));
} | [
"String",
"buildProjectEndpoint",
"(",
"DatastoreOptions",
"options",
")",
"{",
"if",
"(",
"options",
".",
"getProjectEndpoint",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"options",
".",
"getProjectEndpoint",
"(",
")",
";",
"}",
"// DatastoreOptions ensures eith... | Build a valid datastore URL. | [
"Build",
"a",
"valid",
"datastore",
"URL",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreFactory.java#L95-L110 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreFactory.java | DatastoreFactory.getStreamHandler | private static synchronized StreamHandler getStreamHandler() {
if (methodHandler == null) {
methodHandler = new ConsoleHandler();
methodHandler.setFormatter(new Formatter() {
@Override
public String format(LogRecord record) {
return record.getMessage() + "\n";
}
});
methodHandler.setLevel(Level.FINE);
}
return methodHandler;
} | java | private static synchronized StreamHandler getStreamHandler() {
if (methodHandler == null) {
methodHandler = new ConsoleHandler();
methodHandler.setFormatter(new Formatter() {
@Override
public String format(LogRecord record) {
return record.getMessage() + "\n";
}
});
methodHandler.setLevel(Level.FINE);
}
return methodHandler;
} | [
"private",
"static",
"synchronized",
"StreamHandler",
"getStreamHandler",
"(",
")",
"{",
"if",
"(",
"methodHandler",
"==",
"null",
")",
"{",
"methodHandler",
"=",
"new",
"ConsoleHandler",
"(",
")",
";",
"methodHandler",
".",
"setFormatter",
"(",
"new",
"Formatte... | running in App Engine | [
"running",
"in",
"App",
"Engine"
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreFactory.java#L128-L140 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java | DatastoreHelper.getServiceAccountCredential | public static Credential getServiceAccountCredential(String serviceAccountId,
String privateKeyFile, Collection<String> serviceAccountScopes)
throws GeneralSecurityException, IOException {
return getCredentialBuilderWithoutPrivateKey(serviceAccountId, serviceAccountScopes)
.setServiceAccountPrivateKeyFromP12File(new File(privateKeyFile))
.build();
} | java | public static Credential getServiceAccountCredential(String serviceAccountId,
String privateKeyFile, Collection<String> serviceAccountScopes)
throws GeneralSecurityException, IOException {
return getCredentialBuilderWithoutPrivateKey(serviceAccountId, serviceAccountScopes)
.setServiceAccountPrivateKeyFromP12File(new File(privateKeyFile))
.build();
} | [
"public",
"static",
"Credential",
"getServiceAccountCredential",
"(",
"String",
"serviceAccountId",
",",
"String",
"privateKeyFile",
",",
"Collection",
"<",
"String",
">",
"serviceAccountScopes",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"return"... | Constructs credentials for the given account and key file.
@param serviceAccountId service account ID (typically an e-mail address).
@param privateKeyFile the file name from which to get the private key.
@param serviceAccountScopes Collection of OAuth scopes to use with the the service
account flow or {@code null} if not.
@return valid credentials or {@code null} | [
"Constructs",
"credentials",
"for",
"the",
"given",
"account",
"and",
"key",
"file",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java#L177-L183 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java | DatastoreHelper.makeOrder | public static PropertyOrder.Builder makeOrder(String property,
PropertyOrder.Direction direction) {
return PropertyOrder.newBuilder()
.setProperty(makePropertyReference(property))
.setDirection(direction);
} | java | public static PropertyOrder.Builder makeOrder(String property,
PropertyOrder.Direction direction) {
return PropertyOrder.newBuilder()
.setProperty(makePropertyReference(property))
.setDirection(direction);
} | [
"public",
"static",
"PropertyOrder",
".",
"Builder",
"makeOrder",
"(",
"String",
"property",
",",
"PropertyOrder",
".",
"Direction",
"direction",
")",
"{",
"return",
"PropertyOrder",
".",
"newBuilder",
"(",
")",
".",
"setProperty",
"(",
"makePropertyReference",
"(... | Make a sort order for use in a query. | [
"Make",
"a",
"sort",
"order",
"for",
"use",
"in",
"a",
"query",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java#L366-L371 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java | DatastoreHelper.makeAncestorFilter | public static Filter.Builder makeAncestorFilter(Key ancestor) {
return makeFilter(
DatastoreHelper.KEY_PROPERTY_NAME, PropertyFilter.Operator.HAS_ANCESTOR,
makeValue(ancestor));
} | java | public static Filter.Builder makeAncestorFilter(Key ancestor) {
return makeFilter(
DatastoreHelper.KEY_PROPERTY_NAME, PropertyFilter.Operator.HAS_ANCESTOR,
makeValue(ancestor));
} | [
"public",
"static",
"Filter",
".",
"Builder",
"makeAncestorFilter",
"(",
"Key",
"ancestor",
")",
"{",
"return",
"makeFilter",
"(",
"DatastoreHelper",
".",
"KEY_PROPERTY_NAME",
",",
"PropertyFilter",
".",
"Operator",
".",
"HAS_ANCESTOR",
",",
"makeValue",
"(",
"anc... | Makes an ancestor filter. | [
"Makes",
"an",
"ancestor",
"filter",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java#L376-L380 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java | DatastoreHelper.makeAndFilter | public static Filter.Builder makeAndFilter(Iterable<Filter> subfilters) {
return Filter.newBuilder()
.setCompositeFilter(CompositeFilter.newBuilder()
.addAllFilters(subfilters)
.setOp(CompositeFilter.Operator.AND));
} | java | public static Filter.Builder makeAndFilter(Iterable<Filter> subfilters) {
return Filter.newBuilder()
.setCompositeFilter(CompositeFilter.newBuilder()
.addAllFilters(subfilters)
.setOp(CompositeFilter.Operator.AND));
} | [
"public",
"static",
"Filter",
".",
"Builder",
"makeAndFilter",
"(",
"Iterable",
"<",
"Filter",
">",
"subfilters",
")",
"{",
"return",
"Filter",
".",
"newBuilder",
"(",
")",
".",
"setCompositeFilter",
"(",
"CompositeFilter",
".",
"newBuilder",
"(",
")",
".",
... | Make a composite filter from the given sub-filters using AND to combine filters. | [
"Make",
"a",
"composite",
"filter",
"from",
"the",
"given",
"sub",
"-",
"filters",
"using",
"AND",
"to",
"combine",
"filters",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java#L412-L417 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java | DatastoreHelper.makeValue | public static Value.Builder makeValue(Value value1, Value value2, Value... rest) {
ArrayValue.Builder arrayValue = ArrayValue.newBuilder();
arrayValue.addValues(value1);
arrayValue.addValues(value2);
arrayValue.addAllValues(Arrays.asList(rest));
return Value.newBuilder().setArrayValue(arrayValue);
} | java | public static Value.Builder makeValue(Value value1, Value value2, Value... rest) {
ArrayValue.Builder arrayValue = ArrayValue.newBuilder();
arrayValue.addValues(value1);
arrayValue.addValues(value2);
arrayValue.addAllValues(Arrays.asList(rest));
return Value.newBuilder().setArrayValue(arrayValue);
} | [
"public",
"static",
"Value",
".",
"Builder",
"makeValue",
"(",
"Value",
"value1",
",",
"Value",
"value2",
",",
"Value",
"...",
"rest",
")",
"{",
"ArrayValue",
".",
"Builder",
"arrayValue",
"=",
"ArrayValue",
".",
"newBuilder",
"(",
")",
";",
"arrayValue",
... | Make a list value containing the specified values. | [
"Make",
"a",
"list",
"value",
"containing",
"the",
"specified",
"values",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java#L436-L442 | train |
GoogleCloudPlatform/google-cloud-datastore | java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java | DatastoreHelper.makeValue | public static Value.Builder makeValue(Date date) {
return Value.newBuilder().setTimestampValue(toTimestamp(date.getTime() * 1000L));
} | java | public static Value.Builder makeValue(Date date) {
return Value.newBuilder().setTimestampValue(toTimestamp(date.getTime() * 1000L));
} | [
"public",
"static",
"Value",
".",
"Builder",
"makeValue",
"(",
"Date",
"date",
")",
"{",
"return",
"Value",
".",
"newBuilder",
"(",
")",
".",
"setTimestampValue",
"(",
"toTimestamp",
"(",
"date",
".",
"getTime",
"(",
")",
"*",
"1000L",
")",
")",
";",
"... | Make a timestamp value given a date. | [
"Make",
"a",
"timestamp",
"value",
"given",
"a",
"date",
"."
] | a23940d0634d7f537faf01ad9e60598046bcb40a | https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/a23940d0634d7f537faf01ad9e60598046bcb40a/java/datastore/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java#L524-L526 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ListExtensions.java | ListExtensions.sortInplace | public static <T extends Comparable<? super T>> List<T> sortInplace(List<T> list) {
Collections.sort(list);
return list;
} | java | public static <T extends Comparable<? super T>> List<T> sortInplace(List<T> list) {
Collections.sort(list);
return list;
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"List",
"<",
"T",
">",
"sortInplace",
"(",
"List",
"<",
"T",
">",
"list",
")",
"{",
"Collections",
".",
"sort",
"(",
"list",
")",
";",
"return",
"list",
";",
... | Sorts the specified list itself into ascending order, according to the natural ordering of its elements.
@param list
the list to be sorted. May not be <code>null</code>.
@return the sorted list itself.
@see Collections#sort(List) | [
"Sorts",
"the",
"specified",
"list",
"itself",
"into",
"ascending",
"order",
"according",
"to",
"the",
"natural",
"ordering",
"of",
"its",
"elements",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ListExtensions.java#L44-L47 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ListExtensions.java | ListExtensions.sortInplaceBy | public static <T, C extends Comparable<? super C>> List<T> sortInplaceBy(List<T> list,
final Functions.Function1<? super T, C> key) {
if (key == null)
throw new NullPointerException("key");
Collections.sort(list, new KeyComparator<T, C>(key));
return list;
} | java | public static <T, C extends Comparable<? super C>> List<T> sortInplaceBy(List<T> list,
final Functions.Function1<? super T, C> key) {
if (key == null)
throw new NullPointerException("key");
Collections.sort(list, new KeyComparator<T, C>(key));
return list;
} | [
"public",
"static",
"<",
"T",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"List",
"<",
"T",
">",
"sortInplaceBy",
"(",
"List",
"<",
"T",
">",
"list",
",",
"final",
"Functions",
".",
"Function1",
"<",
"?",
"super",
"T",
",",... | Sorts the specified list itself according to the order induced by applying a key function to each element which
yields a comparable criteria.
@param list
the list to be sorted. May not be <code>null</code>.
@param key
the key function to-be-used. May not be <code>null</code>.
@return the sorted list itself.
@see Collections#sort(List) | [
"Sorts",
"the",
"specified",
"list",
"itself",
"according",
"to",
"the",
"order",
"induced",
"by",
"applying",
"a",
"key",
"function",
"to",
"each",
"element",
"which",
"yields",
"a",
"comparable",
"criteria",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ListExtensions.java#L78-L84 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ListExtensions.java | ListExtensions.reverseView | @Pure
public static <T> List<T> reverseView(List<T> list) {
return Lists.reverse(list);
} | java | @Pure
public static <T> List<T> reverseView(List<T> list) {
return Lists.reverse(list);
} | [
"@",
"Pure",
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"reverseView",
"(",
"List",
"<",
"T",
">",
"list",
")",
"{",
"return",
"Lists",
".",
"reverse",
"(",
"list",
")",
";",
"}"
] | Provides a reverse view on the given list which is especially useful to traverse a list backwards in a for-each
loop. The list itself is not modified by calling this method.
@param list
the list whose elements should be traversed in reverse. May not be <code>null</code>.
@return a list with the same elements as the given list, in reverse | [
"Provides",
"a",
"reverse",
"view",
"on",
"the",
"given",
"list",
"which",
"is",
"especially",
"useful",
"to",
"traverse",
"a",
"list",
"backwards",
"in",
"a",
"for",
"-",
"each",
"loop",
".",
"The",
"list",
"itself",
"is",
"not",
"modified",
"by",
"call... | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ListExtensions.java#L94-L97 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ReflectExtensions.java | ReflectExtensions.set | public void set(Object receiver, String fieldName, /* @Nullable */ Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Preconditions.checkNotNull(receiver,"receiver");
Preconditions.checkNotNull(fieldName,"fieldName");
Class<? extends Object> clazz = receiver.getClass();
Field f = getDeclaredField(clazz, fieldName);
if (!f.isAccessible())
f.setAccessible(true);
f.set(receiver, value);
} | java | public void set(Object receiver, String fieldName, /* @Nullable */ Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Preconditions.checkNotNull(receiver,"receiver");
Preconditions.checkNotNull(fieldName,"fieldName");
Class<? extends Object> clazz = receiver.getClass();
Field f = getDeclaredField(clazz, fieldName);
if (!f.isAccessible())
f.setAccessible(true);
f.set(receiver, value);
} | [
"public",
"void",
"set",
"(",
"Object",
"receiver",
",",
"String",
"fieldName",
",",
"/* @Nullable */",
"Object",
"value",
")",
"throws",
"SecurityException",
",",
"NoSuchFieldException",
",",
"IllegalArgumentException",
",",
"IllegalAccessException",
"{",
"Precondition... | Sets the given value on an the receivers's accessible field with the given name.
@param receiver the receiver, never <code>null</code>
@param fieldName the field's name, never <code>null</code>
@param value the value to set
@throws NoSuchFieldException see {@link Class#getField(String)}
@throws SecurityException see {@link Class#getField(String)}
@throws IllegalAccessException see {@link Field#set(Object, Object)}
@throws IllegalArgumentException see {@link Field#set(Object, Object)} | [
"Sets",
"the",
"given",
"value",
"on",
"an",
"the",
"receivers",
"s",
"accessible",
"field",
"with",
"the",
"given",
"name",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ReflectExtensions.java#L38-L46 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ReflectExtensions.java | ReflectExtensions.get | @SuppressWarnings("unchecked")
/* @Nullable */
public <T> T get(Object receiver, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Preconditions.checkNotNull(receiver,"receiver");
Preconditions.checkNotNull(fieldName,"fieldName");
Class<? extends Object> clazz = receiver.getClass();
Field f = getDeclaredField(clazz, fieldName);
if (!f.isAccessible())
f.setAccessible(true);
return (T) f.get(receiver);
} | java | @SuppressWarnings("unchecked")
/* @Nullable */
public <T> T get(Object receiver, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Preconditions.checkNotNull(receiver,"receiver");
Preconditions.checkNotNull(fieldName,"fieldName");
Class<? extends Object> clazz = receiver.getClass();
Field f = getDeclaredField(clazz, fieldName);
if (!f.isAccessible())
f.setAccessible(true);
return (T) f.get(receiver);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"/* @Nullable */",
"public",
"<",
"T",
">",
"T",
"get",
"(",
"Object",
"receiver",
",",
"String",
"fieldName",
")",
"throws",
"SecurityException",
",",
"NoSuchFieldException",
",",
"IllegalArgumentException",
",",
... | Retrieves the value of the given accessible field of the given receiver.
@param receiver the container of the field, not <code>null</code>
@param fieldName the field's name, not <code>null</code>
@return the value of the field
@throws NoSuchFieldException see {@link Class#getField(String)}
@throws SecurityException see {@link Class#getField(String)}
@throws IllegalAccessException see {@link Field#get(Object)}
@throws IllegalArgumentException see {@link Field#get(Object)} | [
"Retrieves",
"the",
"value",
"of",
"the",
"given",
"accessible",
"field",
"of",
"the",
"given",
"receiver",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ReflectExtensions.java#L60-L71 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java | StringConcatenation.append | public void append(Object object, String indentation) {
append(object, indentation, segments.size());
} | java | public void append(Object object, String indentation) {
append(object, indentation, segments.size());
} | [
"public",
"void",
"append",
"(",
"Object",
"object",
",",
"String",
"indentation",
")",
"{",
"append",
"(",
"object",
",",
"indentation",
",",
"segments",
".",
"size",
"(",
")",
")",
";",
"}"
] | Add the string representation of the given object to this sequence. The given indentation will be prepended to
each line except the first one if the object has a multi-line string representation.
@param object
the appended object.
@param indentation
the indentation string that should be prepended. May not be <code>null</code>. | [
"Add",
"the",
"string",
"representation",
"of",
"the",
"given",
"object",
"to",
"this",
"sequence",
".",
"The",
"given",
"indentation",
"will",
"be",
"prepended",
"to",
"each",
"line",
"except",
"the",
"first",
"one",
"if",
"the",
"object",
"has",
"a",
"mu... | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java#L225-L227 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java | StringConcatenation.append | public void append(String str, String indentation) {
if (indentation.isEmpty()) {
append(str);
} else if (str != null)
append(indentation, str, segments.size());
} | java | public void append(String str, String indentation) {
if (indentation.isEmpty()) {
append(str);
} else if (str != null)
append(indentation, str, segments.size());
} | [
"public",
"void",
"append",
"(",
"String",
"str",
",",
"String",
"indentation",
")",
"{",
"if",
"(",
"indentation",
".",
"isEmpty",
"(",
")",
")",
"{",
"append",
"(",
"str",
")",
";",
"}",
"else",
"if",
"(",
"str",
"!=",
"null",
")",
"append",
"(",... | Add the given string to this sequence. The given indentation will be prepended to
each line except the first one if the object has a multi-line string representation.
@param str
the appended string.
@param indentation
the indentation string that should be prepended. May not be <code>null</code>.
@since 2.11 | [
"Add",
"the",
"given",
"string",
"to",
"this",
"sequence",
".",
"The",
"given",
"indentation",
"will",
"be",
"prepended",
"to",
"each",
"line",
"except",
"the",
"first",
"one",
"if",
"the",
"object",
"has",
"a",
"multi",
"-",
"line",
"string",
"representat... | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java#L239-L244 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java | StringConcatenation.append | protected void append(Object object, String indentation, int index) {
if (indentation.length() == 0) {
append(object, index);
return;
}
if (object == null)
return;
if (object instanceof String) {
append(indentation, (String)object, index);
} else if (object instanceof StringConcatenation) {
StringConcatenation other = (StringConcatenation) object;
List<String> otherSegments = other.getSignificantContent();
appendSegments(indentation, index, otherSegments, other.lineDelimiter);
} else if (object instanceof StringConcatenationClient) {
StringConcatenationClient other = (StringConcatenationClient) object;
other.appendTo(new IndentedTarget(this, indentation, index));
} else {
final String text = getStringRepresentation(object);
if (text != null) {
append(indentation, text, index);
}
}
} | java | protected void append(Object object, String indentation, int index) {
if (indentation.length() == 0) {
append(object, index);
return;
}
if (object == null)
return;
if (object instanceof String) {
append(indentation, (String)object, index);
} else if (object instanceof StringConcatenation) {
StringConcatenation other = (StringConcatenation) object;
List<String> otherSegments = other.getSignificantContent();
appendSegments(indentation, index, otherSegments, other.lineDelimiter);
} else if (object instanceof StringConcatenationClient) {
StringConcatenationClient other = (StringConcatenationClient) object;
other.appendTo(new IndentedTarget(this, indentation, index));
} else {
final String text = getStringRepresentation(object);
if (text != null) {
append(indentation, text, index);
}
}
} | [
"protected",
"void",
"append",
"(",
"Object",
"object",
",",
"String",
"indentation",
",",
"int",
"index",
")",
"{",
"if",
"(",
"indentation",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"append",
"(",
"object",
",",
"index",
")",
";",
"return",
";... | Add the string representation of the given object to this sequence at the given index. The given indentation will
be prepended to each line except the first one if the object has a multi-line string representation.
@param object
the to-be-appended object.
@param indentation
the indentation string that should be prepended. May not be <code>null</code>.
@param index
the index in the list of segments. | [
"Add",
"the",
"string",
"representation",
"of",
"the",
"given",
"object",
"to",
"this",
"sequence",
"at",
"the",
"given",
"index",
".",
"The",
"given",
"indentation",
"will",
"be",
"prepended",
"to",
"each",
"line",
"except",
"the",
"first",
"one",
"if",
"... | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java#L293-L315 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java | StringConcatenation.appendImmediate | public void appendImmediate(Object object, String indentation) {
for (int i = segments.size() - 1; i >= 0; i--) {
String segment = segments.get(i);
for (int j = 0; j < segment.length(); j++) {
if (!WhitespaceMatcher.isWhitespace(segment.charAt(j))) {
append(object, indentation, i + 1);
return;
}
}
}
append(object, indentation, 0);
} | java | public void appendImmediate(Object object, String indentation) {
for (int i = segments.size() - 1; i >= 0; i--) {
String segment = segments.get(i);
for (int j = 0; j < segment.length(); j++) {
if (!WhitespaceMatcher.isWhitespace(segment.charAt(j))) {
append(object, indentation, i + 1);
return;
}
}
}
append(object, indentation, 0);
} | [
"public",
"void",
"appendImmediate",
"(",
"Object",
"object",
",",
"String",
"indentation",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"segments",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"String",
"segment",
"=",... | Add the string representation of the given object to this sequence immediately. That is, all the trailing
whitespace of this sequence will be ignored and the string is appended directly after the last segment that
contains something besides whitespace. The given indentation will be prepended to each line except the first one
if the object has a multi-line string representation.
@param object
the to-be-appended object.
@param indentation
the indentation string that should be prepended. May not be <code>null</code>. | [
"Add",
"the",
"string",
"representation",
"of",
"the",
"given",
"object",
"to",
"this",
"sequence",
"immediately",
".",
"That",
"is",
"all",
"the",
"trailing",
"whitespace",
"of",
"this",
"sequence",
"will",
"be",
"ignored",
"and",
"the",
"string",
"is",
"ap... | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java#L350-L361 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java | StringConcatenation.newLineIfNotEmpty | public void newLineIfNotEmpty() {
for (int i = segments.size() - 1; i >= 0; i--) {
String segment = segments.get(i);
if (lineDelimiter.equals(segment)) {
segments.subList(i + 1, segments.size()).clear();
cachedToString = null;
return;
}
for (int j = 0; j < segment.length(); j++) {
if (!WhitespaceMatcher.isWhitespace(segment.charAt(j))) {
newLine();
return;
}
}
}
segments.clear();
cachedToString = null;
} | java | public void newLineIfNotEmpty() {
for (int i = segments.size() - 1; i >= 0; i--) {
String segment = segments.get(i);
if (lineDelimiter.equals(segment)) {
segments.subList(i + 1, segments.size()).clear();
cachedToString = null;
return;
}
for (int j = 0; j < segment.length(); j++) {
if (!WhitespaceMatcher.isWhitespace(segment.charAt(j))) {
newLine();
return;
}
}
}
segments.clear();
cachedToString = null;
} | [
"public",
"void",
"newLineIfNotEmpty",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"segments",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"String",
"segment",
"=",
"segments",
".",
"get",
"(",
"i",
")",
";",... | Add a newline to this sequence according to the configured lineDelimiter if the last line contains
something besides whitespace. | [
"Add",
"a",
"newline",
"to",
"this",
"sequence",
"according",
"to",
"the",
"configured",
"lineDelimiter",
"if",
"the",
"last",
"line",
"contains",
"something",
"besides",
"whitespace",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java#L461-L478 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java | StringConcatenation.splitLinesAndNewLines | protected List<String> splitLinesAndNewLines(String text) {
if (text == null)
return Collections.emptyList();
int idx = initialSegmentSize(text);
if (idx == text.length()) {
return Collections.singletonList(text);
}
return continueSplitting(text, idx);
} | java | protected List<String> splitLinesAndNewLines(String text) {
if (text == null)
return Collections.emptyList();
int idx = initialSegmentSize(text);
if (idx == text.length()) {
return Collections.singletonList(text);
}
return continueSplitting(text, idx);
} | [
"protected",
"List",
"<",
"String",
">",
"splitLinesAndNewLines",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"int",
"idx",
"=",
"initialSegmentSize",
"(",
"text",
")",
... | Return a list of segments where each segment is either the content of a line in the given text or a line-break
according to the configured delimiter. Existing line-breaks in the text will be replaced by this's
instances delimiter.
@param text
the to-be-splitted text. May be <code>null</code>.
@return a list of segments. Is never <code>null</code>. | [
"Return",
"a",
"list",
"of",
"segments",
"where",
"each",
"segment",
"is",
"either",
"the",
"content",
"of",
"a",
"line",
"in",
"the",
"given",
"text",
"or",
"a",
"line",
"-",
"break",
"according",
"to",
"the",
"configured",
"delimiter",
".",
"Existing",
... | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtend2/lib/StringConcatenation.java#L582-L591 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/Pair.java | Pair.of | @Pure
public static <K, V> Pair<K, V> of(K k, V v) {
return new Pair<K, V>(k, v);
} | java | @Pure
public static <K, V> Pair<K, V> of(K k, V v) {
return new Pair<K, V>(k, v);
} | [
"@",
"Pure",
"public",
"static",
"<",
"K",
",",
"V",
">",
"Pair",
"<",
"K",
",",
"V",
">",
"of",
"(",
"K",
"k",
",",
"V",
"v",
")",
"{",
"return",
"new",
"Pair",
"<",
"K",
",",
"V",
">",
"(",
"k",
",",
"v",
")",
";",
"}"
] | Creates a new instance with the given key and value.
May be used instead of the constructor for convenience reasons.
@param k
the key. May be <code>null</code>.
@param v
the value. May be <code>null</code>.
@return a newly created pair. Never <code>null</code>.
@since 2.3 | [
"Creates",
"a",
"new",
"instance",
"with",
"the",
"given",
"key",
"and",
"value",
".",
"May",
"be",
"used",
"instead",
"of",
"the",
"constructor",
"for",
"convenience",
"reasons",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/Pair.java#L42-L45 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ProcedureExtensions.java | ProcedureExtensions.curry | @Pure
public static <P1> Procedure0 curry(final Procedure1<? super P1> procedure, final P1 argument) {
if (procedure == null)
throw new NullPointerException("procedure");
return new Procedure0() {
@Override
public void apply() {
procedure.apply(argument);
}
};
} | java | @Pure
public static <P1> Procedure0 curry(final Procedure1<? super P1> procedure, final P1 argument) {
if (procedure == null)
throw new NullPointerException("procedure");
return new Procedure0() {
@Override
public void apply() {
procedure.apply(argument);
}
};
} | [
"@",
"Pure",
"public",
"static",
"<",
"P1",
">",
"Procedure0",
"curry",
"(",
"final",
"Procedure1",
"<",
"?",
"super",
"P1",
">",
"procedure",
",",
"final",
"P1",
"argument",
")",
"{",
"if",
"(",
"procedure",
"==",
"null",
")",
"throw",
"new",
"NullPoi... | Curries a procedure that takes one argument.
@param procedure
the original procedure. May not be <code>null</code>.
@param argument
the fixed argument.
@return a procedure that takes no arguments. Never <code>null</code>. | [
"Curries",
"a",
"procedure",
"that",
"takes",
"one",
"argument",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ProcedureExtensions.java#L37-L47 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ProcedureExtensions.java | ProcedureExtensions.curry | @Pure
public static <P1, P2> Procedure1<P2> curry(final Procedure2<? super P1, ? super P2> procedure, final P1 argument) {
if (procedure == null)
throw new NullPointerException("procedure");
return new Procedure1<P2>() {
@Override
public void apply(P2 p) {
procedure.apply(argument, p);
}
};
} | java | @Pure
public static <P1, P2> Procedure1<P2> curry(final Procedure2<? super P1, ? super P2> procedure, final P1 argument) {
if (procedure == null)
throw new NullPointerException("procedure");
return new Procedure1<P2>() {
@Override
public void apply(P2 p) {
procedure.apply(argument, p);
}
};
} | [
"@",
"Pure",
"public",
"static",
"<",
"P1",
",",
"P2",
">",
"Procedure1",
"<",
"P2",
">",
"curry",
"(",
"final",
"Procedure2",
"<",
"?",
"super",
"P1",
",",
"?",
"super",
"P2",
">",
"procedure",
",",
"final",
"P1",
"argument",
")",
"{",
"if",
"(",
... | Curries a procedure that takes two arguments.
@param procedure
the original procedure. May not be <code>null</code>.
@param argument
the fixed first argument of {@code procedure}.
@return a procedure that takes one argument. Never <code>null</code>. | [
"Curries",
"a",
"procedure",
"that",
"takes",
"two",
"arguments",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ProcedureExtensions.java#L58-L68 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ProcedureExtensions.java | ProcedureExtensions.curry | @Pure
public static <P1, P2, P3> Procedure2<P2, P3> curry(final Procedure3<? super P1, ? super P2, ? super P3> procedure, final P1 argument) {
if (procedure == null)
throw new NullPointerException("procedure");
return new Procedure2<P2, P3>() {
@Override
public void apply(P2 p2, P3 p3) {
procedure.apply(argument, p2, p3);
}
};
} | java | @Pure
public static <P1, P2, P3> Procedure2<P2, P3> curry(final Procedure3<? super P1, ? super P2, ? super P3> procedure, final P1 argument) {
if (procedure == null)
throw new NullPointerException("procedure");
return new Procedure2<P2, P3>() {
@Override
public void apply(P2 p2, P3 p3) {
procedure.apply(argument, p2, p3);
}
};
} | [
"@",
"Pure",
"public",
"static",
"<",
"P1",
",",
"P2",
",",
"P3",
">",
"Procedure2",
"<",
"P2",
",",
"P3",
">",
"curry",
"(",
"final",
"Procedure3",
"<",
"?",
"super",
"P1",
",",
"?",
"super",
"P2",
",",
"?",
"super",
"P3",
">",
"procedure",
",",... | Curries a procedure that takes three arguments.
@param procedure
the original procedure. May not be <code>null</code>.
@param argument
the fixed first argument of {@code procedure}.
@return a procedure that takes two arguments. Never <code>null</code>. | [
"Curries",
"a",
"procedure",
"that",
"takes",
"three",
"arguments",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ProcedureExtensions.java#L79-L89 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ProcedureExtensions.java | ProcedureExtensions.curry | @Pure
public static <P1, P2, P3, P4, P5> Procedure4<P2, P3, P4, P5> curry(final Procedure5<? super P1, ? super P2, ? super P3, ? super P4, ? super P5> procedure,
final P1 argument) {
if (procedure == null)
throw new NullPointerException("procedure");
return new Procedure4<P2, P3, P4, P5>() {
@Override
public void apply(P2 p2, P3 p3, P4 p4, P5 p5) {
procedure.apply(argument, p2, p3, p4, p5);
}
};
} | java | @Pure
public static <P1, P2, P3, P4, P5> Procedure4<P2, P3, P4, P5> curry(final Procedure5<? super P1, ? super P2, ? super P3, ? super P4, ? super P5> procedure,
final P1 argument) {
if (procedure == null)
throw new NullPointerException("procedure");
return new Procedure4<P2, P3, P4, P5>() {
@Override
public void apply(P2 p2, P3 p3, P4 p4, P5 p5) {
procedure.apply(argument, p2, p3, p4, p5);
}
};
} | [
"@",
"Pure",
"public",
"static",
"<",
"P1",
",",
"P2",
",",
"P3",
",",
"P4",
",",
"P5",
">",
"Procedure4",
"<",
"P2",
",",
"P3",
",",
"P4",
",",
"P5",
">",
"curry",
"(",
"final",
"Procedure5",
"<",
"?",
"super",
"P1",
",",
"?",
"super",
"P2",
... | Curries a procedure that takes five arguments.
@param procedure
the original procedure. May not be <code>null</code>.
@param argument
the fixed first argument of {@code procedure}.
@return a procedure that takes four arguments. Never <code>null</code>. | [
"Curries",
"a",
"procedure",
"that",
"takes",
"five",
"arguments",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/ProcedureExtensions.java#L122-L133 | train |
eclipse/xtext-lib | org.eclipse.xtend.lib.macro/src/org/eclipse/xtend/lib/macro/file/Path.java | Path.getParent | public Path getParent() {
if (!isAbsolute())
throw new IllegalStateException("path is not absolute: " + toString());
if (segments.isEmpty())
return null;
return new Path(segments.subList(0, segments.size()-1), true);
} | java | public Path getParent() {
if (!isAbsolute())
throw new IllegalStateException("path is not absolute: " + toString());
if (segments.isEmpty())
return null;
return new Path(segments.subList(0, segments.size()-1), true);
} | [
"public",
"Path",
"getParent",
"(",
")",
"{",
"if",
"(",
"!",
"isAbsolute",
"(",
")",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"path is not absolute: \"",
"+",
"toString",
"(",
")",
")",
";",
"if",
"(",
"segments",
".",
"isEmpty",
"(",
")",
"... | Returns the parent of this path or null if this path is the root path.
@return the parent of this path or null if this path is the root path. | [
"Returns",
"the",
"parent",
"of",
"this",
"path",
"or",
"null",
"if",
"this",
"path",
"is",
"the",
"root",
"path",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtend.lib.macro/src/org/eclipse/xtend/lib/macro/file/Path.java#L134-L140 | train |
eclipse/xtext-lib | org.eclipse.xtend.lib.macro/src/org/eclipse/xtend/lib/macro/file/Path.java | Path.relativize | public Path relativize(Path other) {
if (other.isAbsolute() != isAbsolute())
throw new IllegalArgumentException("This path and the given path are not both absolute or both relative: " + toString() + " | " + other.toString());
if (startsWith(other)) {
return internalRelativize(this, other);
} else if (other.startsWith(this)) {
return internalRelativize(other, this);
}
return null;
} | java | public Path relativize(Path other) {
if (other.isAbsolute() != isAbsolute())
throw new IllegalArgumentException("This path and the given path are not both absolute or both relative: " + toString() + " | " + other.toString());
if (startsWith(other)) {
return internalRelativize(this, other);
} else if (other.startsWith(this)) {
return internalRelativize(other, this);
}
return null;
} | [
"public",
"Path",
"relativize",
"(",
"Path",
"other",
")",
"{",
"if",
"(",
"other",
".",
"isAbsolute",
"(",
")",
"!=",
"isAbsolute",
"(",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"This path and the given path are not both absolute or both relative:... | Constructs a relative path between this path and a given path.
<p> Relativization is the inverse of {@link #getAbsolutePath(Path) resolution}.
This method attempts to construct a {@link #isAbsolute relative} path
that when {@link #getAbsolutePath(Path) resolved} against this path, yields a
path that locates the same file as the given path. For example, on UNIX,
if this path is {@code "/a/b"} and the given path is {@code "/a/b/c/d"}
then the resulting relative path would be {@code "c/d"}.
Both paths must be absolute and and either this path or the given path must be a
{@link #startsWith(Path) prefix} of the other.
@param other
the path to relativize against this path
@return the resulting relative path or null if neither of the given paths is a prefix of the other
@throws IllegalArgumentException
if this path and {@code other} are not both absolute or relative | [
"Constructs",
"a",
"relative",
"path",
"between",
"this",
"path",
"and",
"a",
"given",
"path",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtend.lib.macro/src/org/eclipse/xtend/lib/macro/file/Path.java#L215-L224 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_add | @Inline(value = "$1.put($2.getKey(), $2.getValue())", statementExpression = true)
public static <K, V> V operator_add(Map<K, V> map, Pair<? extends K, ? extends V> entry) {
return map.put(entry.getKey(), entry.getValue());
} | java | @Inline(value = "$1.put($2.getKey(), $2.getValue())", statementExpression = true)
public static <K, V> V operator_add(Map<K, V> map, Pair<? extends K, ? extends V> entry) {
return map.put(entry.getKey(), entry.getValue());
} | [
"@",
"Inline",
"(",
"value",
"=",
"\"$1.put($2.getKey(), $2.getValue())\"",
",",
"statementExpression",
"=",
"true",
")",
"public",
"static",
"<",
"K",
",",
"V",
">",
"V",
"operator_add",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Pair",
"<",
"?",... | Add the given pair into the map.
<p>
If the pair key already exists in the map, its value is replaced
by the value in the pair, and the old value in the map is returned.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param map the map to update.
@param entry the entry (key, value) to add into the map.
@return the value previously associated to the key, or <code>null</code>
if the key was not present in the map before the addition.
@since 2.15 | [
"Add",
"the",
"given",
"pair",
"into",
"the",
"map",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L118-L121 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_add | @Inline(value = "$1.putAll($2)", statementExpression = true)
public static <K, V> void operator_add(Map<K, V> outputMap, Map<? extends K, ? extends V> inputMap) {
outputMap.putAll(inputMap);
} | java | @Inline(value = "$1.putAll($2)", statementExpression = true)
public static <K, V> void operator_add(Map<K, V> outputMap, Map<? extends K, ? extends V> inputMap) {
outputMap.putAll(inputMap);
} | [
"@",
"Inline",
"(",
"value",
"=",
"\"$1.putAll($2)\"",
",",
"statementExpression",
"=",
"true",
")",
"public",
"static",
"<",
"K",
",",
"V",
">",
"void",
"operator_add",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"outputMap",
",",
"Map",
"<",
"?",
"extends",... | Add the given entries of the input map into the output map.
<p>
If a key in the inputMap already exists in the outputMap, its value is
replaced in the outputMap by the value from the inputMap.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param outputMap the map to update.
@param inputMap the entries to add.
@since 2.15 | [
"Add",
"the",
"given",
"entries",
"of",
"the",
"input",
"map",
"into",
"the",
"output",
"map",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L137-L140 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_plus | @Pure
@Inline(value = "$3.union($1, $4.singletonMap($2.getKey(), $2.getValue()))",
imported = { MapExtensions.class, Collections.class })
public static <K, V> Map<K, V> operator_plus(Map<K, V> left, final Pair<? extends K, ? extends V> right) {
return union(left, Collections.singletonMap(right.getKey(), right.getValue()));
} | java | @Pure
@Inline(value = "$3.union($1, $4.singletonMap($2.getKey(), $2.getValue()))",
imported = { MapExtensions.class, Collections.class })
public static <K, V> Map<K, V> operator_plus(Map<K, V> left, final Pair<? extends K, ? extends V> right) {
return union(left, Collections.singletonMap(right.getKey(), right.getValue()));
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"$3.union($1, $4.singletonMap($2.getKey(), $2.getValue()))\"",
",",
"imported",
"=",
"{",
"MapExtensions",
".",
"class",
",",
"Collections",
".",
"class",
"}",
")",
"public",
"static",
"<",
"K",
",",
"V",
">",
"... | Add the given pair to a given map for obtaining a new map.
<p>
The replied map is a view on the given map. It means that any change
in the original map is reflected to the result of this operation.
</p>
<p>
Even if the key of the right operand exists in the left operand, the value in the right operand is preferred.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param left the map to consider.
@param right the entry (key, value) to add into the map.
@return an immutable map with the content of the map and with the given entry.
@throws IllegalArgumentException - when the right operand key exists in the left operand.
@since 2.15 | [
"Add",
"the",
"given",
"pair",
"to",
"a",
"given",
"map",
"for",
"obtaining",
"a",
"new",
"map",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L162-L167 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_plus | @Pure
@Inline(value = "$3.union($1, $2)", imported = MapExtensions.class)
public static <K, V> Map<K, V> operator_plus(Map<K, V> left, Map<? extends K, ? extends V> right) {
return union(left, right);
} | java | @Pure
@Inline(value = "$3.union($1, $2)", imported = MapExtensions.class)
public static <K, V> Map<K, V> operator_plus(Map<K, V> left, Map<? extends K, ? extends V> right) {
return union(left, right);
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"$3.union($1, $2)\"",
",",
"imported",
"=",
"MapExtensions",
".",
"class",
")",
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"operator_plus",
"(",
"Map",
"<",
"K",
",",
... | Merge the two maps.
<p>
The replied map is a view on the given map. It means that any change
in the original map is reflected to the result of this operation.
</p>
<p>
If a key exists in the left and right operands, the value in the right operand is preferred.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param left the left map.
@param right the right map.
@return a map with the merged contents from the two maps.
@throws IllegalArgumentException - when a right operand key exists in the left operand.
@since 2.15 | [
"Merge",
"the",
"two",
"maps",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L189-L193 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_remove | @Inline(value = "$1.remove($2)", statementExpression = true)
public static <K, V> V operator_remove(Map<K, V> map, K key) {
return map.remove(key);
} | java | @Inline(value = "$1.remove($2)", statementExpression = true)
public static <K, V> V operator_remove(Map<K, V> map, K key) {
return map.remove(key);
} | [
"@",
"Inline",
"(",
"value",
"=",
"\"$1.remove($2)\"",
",",
"statementExpression",
"=",
"true",
")",
"public",
"static",
"<",
"K",
",",
"V",
">",
"V",
"operator_remove",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"K",
"key",
")",
"{",
"return",... | Remove a key from the given map.
@param <K> type of the map keys.
@param <V> type of the map values.
@param map the map to update.
@param key the key to remove.
@return the removed value, or <code>null</code> if the key was not
present in the map.
@since 2.15 | [
"Remove",
"a",
"key",
"from",
"the",
"given",
"map",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L206-L209 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_remove | @Inline(value = "$1.remove($2.getKey(), $2.getValue())", statementExpression = true)
public static <K, V> boolean operator_remove(Map<K, V> map, Pair<? extends K, ? extends V> entry) {
//TODO use the JRE 1.8 API: map.remove(entry.getKey(), entry.getValue());
final K key = entry.getKey();
final V storedValue = map.get(entry.getKey());
if (!Objects.equal(storedValue, entry.getValue())
|| (storedValue == null && !map.containsKey(key))) {
return false;
}
map.remove(key);
return true;
} | java | @Inline(value = "$1.remove($2.getKey(), $2.getValue())", statementExpression = true)
public static <K, V> boolean operator_remove(Map<K, V> map, Pair<? extends K, ? extends V> entry) {
//TODO use the JRE 1.8 API: map.remove(entry.getKey(), entry.getValue());
final K key = entry.getKey();
final V storedValue = map.get(entry.getKey());
if (!Objects.equal(storedValue, entry.getValue())
|| (storedValue == null && !map.containsKey(key))) {
return false;
}
map.remove(key);
return true;
} | [
"@",
"Inline",
"(",
"value",
"=",
"\"$1.remove($2.getKey(), $2.getValue())\"",
",",
"statementExpression",
"=",
"true",
")",
"public",
"static",
"<",
"K",
",",
"V",
">",
"boolean",
"operator_remove",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Pair",
... | Remove the given pair into the map.
<p>
If the given key is inside the map, but is not mapped to the given value, the
map will not be changed.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param map the map to update.
@param entry the entry (key, value) to remove from the map.
@return {@code true} if the pair was removed.
@since 2.15 | [
"Remove",
"the",
"given",
"pair",
"into",
"the",
"map",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L226-L237 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_remove | public static <K, V> void operator_remove(Map<K, V> map, Iterable<? super K> keysToRemove) {
for (final Object key : keysToRemove) {
map.remove(key);
}
} | java | public static <K, V> void operator_remove(Map<K, V> map, Iterable<? super K> keysToRemove) {
for (final Object key : keysToRemove) {
map.remove(key);
}
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"void",
"operator_remove",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Iterable",
"<",
"?",
"super",
"K",
">",
"keysToRemove",
")",
"{",
"for",
"(",
"final",
"Object",
"key",
":",
"keysToRemove",
"... | Remove pairs with the given keys from the map.
@param <K> type of the map keys.
@param <V> type of the map values.
@param map the map to update.
@param keysToRemove the keys of the pairs to remove.
@since 2.15 | [
"Remove",
"pairs",
"with",
"the",
"given",
"keys",
"from",
"the",
"map",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L248-L252 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_minus | @Pure
public static <K, V> Map<K, V> operator_minus(Map<K, V> left, final Pair<? extends K, ? extends V> right) {
return Maps.filterEntries(left, new Predicate<Entry<K, V>>() {
@Override
public boolean apply(Entry<K, V> input) {
return !Objects.equal(input.getKey(), right.getKey()) || !Objects.equal(input.getValue(), right.getValue());
}
});
} | java | @Pure
public static <K, V> Map<K, V> operator_minus(Map<K, V> left, final Pair<? extends K, ? extends V> right) {
return Maps.filterEntries(left, new Predicate<Entry<K, V>>() {
@Override
public boolean apply(Entry<K, V> input) {
return !Objects.equal(input.getKey(), right.getKey()) || !Objects.equal(input.getValue(), right.getValue());
}
});
} | [
"@",
"Pure",
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"operator_minus",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"left",
",",
"final",
"Pair",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
"right",
"... | Remove the given pair from a given map for obtaining a new map.
<p>
If the given key is inside the map, but is not mapped to the given value, the
map will not be changed.
</p>
<p>
The replied map is a view on the given map. It means that any change
in the original map is reflected to the result of this operation.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param left the map to consider.
@param right the entry (key, value) to remove from the map.
@return an immutable map with the content of the map and with the given entry.
@throws IllegalArgumentException - when the right operand key exists in the left operand.
@since 2.15 | [
"Remove",
"the",
"given",
"pair",
"from",
"a",
"given",
"map",
"for",
"obtaining",
"a",
"new",
"map",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L275-L283 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_minus | @Pure
public static <K, V> Map<K, V> operator_minus(Map<K, V> map, final K key) {
return Maps.filterKeys(map, new Predicate<K>() {
@Override
public boolean apply(K input) {
return !Objects.equal(input, key);
}
});
} | java | @Pure
public static <K, V> Map<K, V> operator_minus(Map<K, V> map, final K key) {
return Maps.filterKeys(map, new Predicate<K>() {
@Override
public boolean apply(K input) {
return !Objects.equal(input, key);
}
});
} | [
"@",
"Pure",
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"operator_minus",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"final",
"K",
"key",
")",
"{",
"return",
"Maps",
".",
"filterKeys",
"(",
"map",
",",
... | Replies the elements of the given map except the pair with the given key.
<p>
The replied map is a view on the given map. It means that any change
in the original map is reflected to the result of this operation.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param map the map to update.
@param key the key to remove.
@return the map with the content of the map except the key.
@since 2.15 | [
"Replies",
"the",
"elements",
"of",
"the",
"given",
"map",
"except",
"the",
"pair",
"with",
"the",
"given",
"key",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L300-L308 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_minus | @Pure
public static <K, V> Map<K, V> operator_minus(Map<K, V> left, final Map<? extends K, ? extends V> right) {
return Maps.filterEntries(left, new Predicate<Entry<K, V>>() {
@Override
public boolean apply(Entry<K, V> input) {
final V value = right.get(input.getKey());
if (value == null) {
return input.getValue() == null && right.containsKey(input.getKey());
}
return !Objects.equal(input.getValue(), value);
}
});
} | java | @Pure
public static <K, V> Map<K, V> operator_minus(Map<K, V> left, final Map<? extends K, ? extends V> right) {
return Maps.filterEntries(left, new Predicate<Entry<K, V>>() {
@Override
public boolean apply(Entry<K, V> input) {
final V value = right.get(input.getKey());
if (value == null) {
return input.getValue() == null && right.containsKey(input.getKey());
}
return !Objects.equal(input.getValue(), value);
}
});
} | [
"@",
"Pure",
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"operator_minus",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"left",
",",
"final",
"Map",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
"right",
")... | Replies the elements of the left map without the pairs in the right map.
If the pair's values differ from
the value within the map, the map entry is not removed.
<p>
The difference is an immutable
snapshot of the state of the maps at the time this method is called. It
will never change, even if the maps change at a later time.
</p>
<p>
Since this method uses {@code HashMap} instances internally, the keys of
the supplied maps must be well-behaved with respect to
{@link Object#equals} and {@link Object#hashCode}.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param left the map to update.
@param right the pairs to remove.
@return the map with the content of the left map except the pairs of the right map.
@since 2.15 | [
"Replies",
"the",
"elements",
"of",
"the",
"left",
"map",
"without",
"the",
"pairs",
"in",
"the",
"right",
"map",
".",
"If",
"the",
"pair",
"s",
"values",
"differ",
"from",
"the",
"value",
"within",
"the",
"map",
"the",
"map",
"entry",
"is",
"not",
"re... | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L334-L346 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.operator_minus | @Pure
public static <K, V> Map<K, V> operator_minus(Map<K, V> map, final Iterable<?> keys) {
return Maps.filterKeys(map, new Predicate<K>() {
@Override
public boolean apply(K input) {
return !Iterables.contains(keys, input);
}
});
} | java | @Pure
public static <K, V> Map<K, V> operator_minus(Map<K, V> map, final Iterable<?> keys) {
return Maps.filterKeys(map, new Predicate<K>() {
@Override
public boolean apply(K input) {
return !Iterables.contains(keys, input);
}
});
} | [
"@",
"Pure",
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"operator_minus",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"final",
"Iterable",
"<",
"?",
">",
"keys",
")",
"{",
"return",
"Maps",
".",
"filterKey... | Replies the elements of the given map except the pairs with the given keys.
<p>
The replied map is a view on the given map. It means that any change
in the original map is reflected to the result of this operation.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param map the map to update.
@param keys the keys of the pairs to remove.
@return the map with the content of the map except the pairs.
@since 2.15 | [
"Replies",
"the",
"elements",
"of",
"the",
"given",
"map",
"except",
"the",
"pairs",
"with",
"the",
"given",
"keys",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L363-L371 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java | MapExtensions.union | @Pure
@Inline(value = "(new $3<$5, $6>($1, $2))", imported = UnmodifiableMergingMapView.class, constantExpression = true)
public static <K, V> Map<K, V> union(Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right) {
return new UnmodifiableMergingMapView<K, V>(left, right);
} | java | @Pure
@Inline(value = "(new $3<$5, $6>($1, $2))", imported = UnmodifiableMergingMapView.class, constantExpression = true)
public static <K, V> Map<K, V> union(Map<? extends K, ? extends V> left, Map<? extends K, ? extends V> right) {
return new UnmodifiableMergingMapView<K, V>(left, right);
} | [
"@",
"Pure",
"@",
"Inline",
"(",
"value",
"=",
"\"(new $3<$5, $6>($1, $2))\"",
",",
"imported",
"=",
"UnmodifiableMergingMapView",
".",
"class",
",",
"constantExpression",
"=",
"true",
")",
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
... | Merge the given maps.
<p>
The replied map is a view on the given two maps.
If a key exists in the two maps, the replied value is the value of the right operand.
</p>
<p>
Even if the key of the right operand exists in the left operand, the value in the right operand is preferred.
</p>
<p>
The replied map is unmodifiable.
</p>
@param <K> type of the map keys.
@param <V> type of the map values.
@param left the left map.
@param right the right map.
@return a map with the merged contents from the two maps.
@since 2.15 | [
"Merge",
"the",
"given",
"maps",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/MapExtensions.java#L396-L400 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java | FunctionExtensions.curry | @Pure
public static <P1, RESULT> Function0<RESULT> curry(final Function1<? super P1, ? extends RESULT> function, final P1 argument) {
if (function == null)
throw new NullPointerException("function");
return new Function0<RESULT>() {
@Override
public RESULT apply() {
return function.apply(argument);
}
};
} | java | @Pure
public static <P1, RESULT> Function0<RESULT> curry(final Function1<? super P1, ? extends RESULT> function, final P1 argument) {
if (function == null)
throw new NullPointerException("function");
return new Function0<RESULT>() {
@Override
public RESULT apply() {
return function.apply(argument);
}
};
} | [
"@",
"Pure",
"public",
"static",
"<",
"P1",
",",
"RESULT",
">",
"Function0",
"<",
"RESULT",
">",
"curry",
"(",
"final",
"Function1",
"<",
"?",
"super",
"P1",
",",
"?",
"extends",
"RESULT",
">",
"function",
",",
"final",
"P1",
"argument",
")",
"{",
"i... | Curries a function that takes one argument.
@param function
the original function. May not be <code>null</code>.
@param argument
the fixed argument.
@return a function that takes no arguments. Never <code>null</code>. | [
"Curries",
"a",
"function",
"that",
"takes",
"one",
"argument",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java#L39-L49 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java | FunctionExtensions.curry | @Pure
public static <P1, P2, RESULT> Function1<P2, RESULT> curry(final Function2<? super P1, ? super P2, ? extends RESULT> function,
final P1 argument) {
if (function == null)
throw new NullPointerException("function");
return new Function1<P2, RESULT>() {
@Override
public RESULT apply(P2 p) {
return function.apply(argument, p);
}
};
} | java | @Pure
public static <P1, P2, RESULT> Function1<P2, RESULT> curry(final Function2<? super P1, ? super P2, ? extends RESULT> function,
final P1 argument) {
if (function == null)
throw new NullPointerException("function");
return new Function1<P2, RESULT>() {
@Override
public RESULT apply(P2 p) {
return function.apply(argument, p);
}
};
} | [
"@",
"Pure",
"public",
"static",
"<",
"P1",
",",
"P2",
",",
"RESULT",
">",
"Function1",
"<",
"P2",
",",
"RESULT",
">",
"curry",
"(",
"final",
"Function2",
"<",
"?",
"super",
"P1",
",",
"?",
"super",
"P2",
",",
"?",
"extends",
"RESULT",
">",
"functi... | Curries a function that takes two arguments.
@param function
the original function. May not be <code>null</code>.
@param argument
the fixed first argument of {@code function}.
@return a function that takes one argument. Never <code>null</code>. | [
"Curries",
"a",
"function",
"that",
"takes",
"two",
"arguments",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java#L60-L71 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java | FunctionExtensions.curry | @Pure
public static <P1, P2, P3, RESULT> Function2<P2, P3, RESULT> curry(final Function3<? super P1, ? super P2, ? super P3, ? extends RESULT> function,
final P1 argument) {
if (function == null)
throw new NullPointerException("function");
return new Function2<P2, P3, RESULT>() {
@Override
public RESULT apply(P2 p2, P3 p3) {
return function.apply(argument, p2, p3);
}
};
} | java | @Pure
public static <P1, P2, P3, RESULT> Function2<P2, P3, RESULT> curry(final Function3<? super P1, ? super P2, ? super P3, ? extends RESULT> function,
final P1 argument) {
if (function == null)
throw new NullPointerException("function");
return new Function2<P2, P3, RESULT>() {
@Override
public RESULT apply(P2 p2, P3 p3) {
return function.apply(argument, p2, p3);
}
};
} | [
"@",
"Pure",
"public",
"static",
"<",
"P1",
",",
"P2",
",",
"P3",
",",
"RESULT",
">",
"Function2",
"<",
"P2",
",",
"P3",
",",
"RESULT",
">",
"curry",
"(",
"final",
"Function3",
"<",
"?",
"super",
"P1",
",",
"?",
"super",
"P2",
",",
"?",
"super",
... | Curries a function that takes three arguments.
@param function
the original function. May not be <code>null</code>.
@param argument
the fixed first argument of {@code function}.
@return a function that takes two arguments. Never <code>null</code>. | [
"Curries",
"a",
"function",
"that",
"takes",
"three",
"arguments",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java#L82-L93 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java | FunctionExtensions.curry | @Pure
public static <P1, P2, P3, P4, RESULT> Function3<P2, P3, P4, RESULT> curry(
final Function4<? super P1, ? super P2, ? super P3, ? super P4, ? extends RESULT> function, final P1 argument) {
if (function == null)
throw new NullPointerException("function");
return new Function3<P2, P3, P4, RESULT>() {
@Override
public RESULT apply(P2 p2, P3 p3, P4 p4) {
return function.apply(argument, p2, p3, p4);
}
};
} | java | @Pure
public static <P1, P2, P3, P4, RESULT> Function3<P2, P3, P4, RESULT> curry(
final Function4<? super P1, ? super P2, ? super P3, ? super P4, ? extends RESULT> function, final P1 argument) {
if (function == null)
throw new NullPointerException("function");
return new Function3<P2, P3, P4, RESULT>() {
@Override
public RESULT apply(P2 p2, P3 p3, P4 p4) {
return function.apply(argument, p2, p3, p4);
}
};
} | [
"@",
"Pure",
"public",
"static",
"<",
"P1",
",",
"P2",
",",
"P3",
",",
"P4",
",",
"RESULT",
">",
"Function3",
"<",
"P2",
",",
"P3",
",",
"P4",
",",
"RESULT",
">",
"curry",
"(",
"final",
"Function4",
"<",
"?",
"super",
"P1",
",",
"?",
"super",
"... | Curries a function that takes four arguments.
@param function
the original function. May not be <code>null</code>.
@param argument
the fixed first argument of {@code function}.
@return a function that takes three arguments. Never <code>null</code>. | [
"Curries",
"a",
"function",
"that",
"takes",
"four",
"arguments",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/FunctionExtensions.java#L104-L115 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java | IterableExtensions.filterNull | @Pure
public static <T> Iterable<T> filterNull(Iterable<T> unfiltered) {
return Iterables.filter(unfiltered, Predicates.notNull());
} | java | @Pure
public static <T> Iterable<T> filterNull(Iterable<T> unfiltered) {
return Iterables.filter(unfiltered, Predicates.notNull());
} | [
"@",
"Pure",
"public",
"static",
"<",
"T",
">",
"Iterable",
"<",
"T",
">",
"filterNull",
"(",
"Iterable",
"<",
"T",
">",
"unfiltered",
")",
"{",
"return",
"Iterables",
".",
"filter",
"(",
"unfiltered",
",",
"Predicates",
".",
"notNull",
"(",
")",
")",
... | Returns a new iterable filtering any null references.
@param unfiltered
the unfiltered iterable. May not be <code>null</code>.
@return an unmodifiable iterable containing all elements of the original iterable without any <code>null</code> references. Never <code>null</code>. | [
"Returns",
"a",
"new",
"iterable",
"filtering",
"any",
"null",
"references",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java#L321-L324 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java | IterableExtensions.sort | public static <T extends Comparable<? super T>> List<T> sort(Iterable<T> iterable) {
List<T> asList = Lists.newArrayList(iterable);
if (iterable instanceof SortedSet<?>) {
if (((SortedSet<T>) iterable).comparator() == null) {
return asList;
}
}
return ListExtensions.sortInplace(asList);
} | java | public static <T extends Comparable<? super T>> List<T> sort(Iterable<T> iterable) {
List<T> asList = Lists.newArrayList(iterable);
if (iterable instanceof SortedSet<?>) {
if (((SortedSet<T>) iterable).comparator() == null) {
return asList;
}
}
return ListExtensions.sortInplace(asList);
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"List",
"<",
"T",
">",
"sort",
"(",
"Iterable",
"<",
"T",
">",
"iterable",
")",
"{",
"List",
"<",
"T",
">",
"asList",
"=",
"Lists",
".",
"newArrayList",
"(",
... | Creates a sorted list that contains the items of the given iterable. The resulting list is in ascending order,
according to the natural ordering of the elements in the iterable.
@param iterable
the items to be sorted. May not be <code>null</code>.
@return a sorted list as a shallow copy of the given iterable.
@see Collections#sort(List)
@see #sort(Iterable, Comparator)
@see #sortBy(Iterable, org.eclipse.xtext.xbase.lib.Functions.Function1)
@see ListExtensions#sortInplace(List) | [
"Creates",
"a",
"sorted",
"list",
"that",
"contains",
"the",
"items",
"of",
"the",
"given",
"iterable",
".",
"The",
"resulting",
"list",
"is",
"in",
"ascending",
"order",
"according",
"to",
"the",
"natural",
"ordering",
"of",
"the",
"elements",
"in",
"the",
... | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java#L726-L734 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java | IterableExtensions.sortWith | public static <T> List<T> sortWith(Iterable<T> iterable, Comparator<? super T> comparator) {
return ListExtensions.sortInplace(Lists.newArrayList(iterable), comparator);
} | java | public static <T> List<T> sortWith(Iterable<T> iterable, Comparator<? super T> comparator) {
return ListExtensions.sortInplace(Lists.newArrayList(iterable), comparator);
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"sortWith",
"(",
"Iterable",
"<",
"T",
">",
"iterable",
",",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comparator",
")",
"{",
"return",
"ListExtensions",
".",
"sortInplace",
"(",
"Lists",
".",... | Creates a sorted list that contains the items of the given iterable. The resulting list is sorted according to
the order induced by the specified comparator.
@param iterable
the items to be sorted. May not be <code>null</code>.
@param comparator
the comparator to be used. May be <code>null</code> to indicate that the natural ordering of the
elements should be used.
@return a sorted list as a shallow copy of the given iterable.
@see Collections#sort(List, Comparator)
@see #sort(Iterable)
@see #sortBy(Iterable, org.eclipse.xtext.xbase.lib.Functions.Function1)
@see ListExtensions#sortInplace(List, Comparator)
@since 2.7 | [
"Creates",
"a",
"sorted",
"list",
"that",
"contains",
"the",
"items",
"of",
"the",
"given",
"iterable",
".",
"The",
"resulting",
"list",
"is",
"sorted",
"according",
"to",
"the",
"order",
"induced",
"by",
"the",
"specified",
"comparator",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java#L773-L775 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java | IterableExtensions.sortBy | public static <T, C extends Comparable<? super C>> List<T> sortBy(Iterable<T> iterable,
final Functions.Function1<? super T, C> key) {
return ListExtensions.sortInplaceBy(Lists.newArrayList(iterable), key);
} | java | public static <T, C extends Comparable<? super C>> List<T> sortBy(Iterable<T> iterable,
final Functions.Function1<? super T, C> key) {
return ListExtensions.sortInplaceBy(Lists.newArrayList(iterable), key);
} | [
"public",
"static",
"<",
"T",
",",
"C",
"extends",
"Comparable",
"<",
"?",
"super",
"C",
">",
">",
"List",
"<",
"T",
">",
"sortBy",
"(",
"Iterable",
"<",
"T",
">",
"iterable",
",",
"final",
"Functions",
".",
"Function1",
"<",
"?",
"super",
"T",
","... | Creates a sorted list that contains the items of the given iterable. The resulting list is sorted according to
the order induced by applying a key function to each element which yields a comparable criteria.
@param iterable
the elements to be sorted. May not be <code>null</code>.
@param key
the key function to-be-used. May not be <code>null</code>.
@return a sorted list as a shallow copy of the given iterable.
@see #sort(Iterable)
@see #sort(Iterable, Comparator)
@see ListExtensions#sortInplaceBy(List, org.eclipse.xtext.xbase.lib.Functions.Function1) | [
"Creates",
"a",
"sorted",
"list",
"that",
"contains",
"the",
"items",
"of",
"the",
"given",
"iterable",
".",
"The",
"resulting",
"list",
"is",
"sorted",
"according",
"to",
"the",
"order",
"induced",
"by",
"applying",
"a",
"key",
"function",
"to",
"each",
"... | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IterableExtensions.java#L790-L793 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/Conversions.java | Conversions.checkComponentType | private static Object checkComponentType(Object array, Class<?> expectedComponentType) {
Class<?> actualComponentType = array.getClass().getComponentType();
if (!expectedComponentType.isAssignableFrom(actualComponentType)) {
throw new ArrayStoreException(
String.format("The expected component type %s is not assignable from the actual type %s",
expectedComponentType.getCanonicalName(), actualComponentType.getCanonicalName()));
}
return array;
} | java | private static Object checkComponentType(Object array, Class<?> expectedComponentType) {
Class<?> actualComponentType = array.getClass().getComponentType();
if (!expectedComponentType.isAssignableFrom(actualComponentType)) {
throw new ArrayStoreException(
String.format("The expected component type %s is not assignable from the actual type %s",
expectedComponentType.getCanonicalName(), actualComponentType.getCanonicalName()));
}
return array;
} | [
"private",
"static",
"Object",
"checkComponentType",
"(",
"Object",
"array",
",",
"Class",
"<",
"?",
">",
"expectedComponentType",
")",
"{",
"Class",
"<",
"?",
">",
"actualComponentType",
"=",
"array",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
... | Checks the component type of the given array against the expected component type.
@param array
the array to be checked. May not be <code>null</code>.
@param expectedComponentType
the expected component type of the array. May not be <code>null</code>.
@return the unchanged array.
@throws ArrayStoreException
if the expected runtime {@code componentType} does not match the actual runtime component type. | [
"Checks",
"the",
"component",
"type",
"of",
"the",
"given",
"array",
"against",
"the",
"expected",
"component",
"type",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/Conversions.java#L226-L234 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ToStringBuilder.java | ToStringBuilder.addDeclaredFields | @GwtIncompatible("Class.getDeclaredFields")
public ToStringBuilder addDeclaredFields() {
Field[] fields = instance.getClass().getDeclaredFields();
for(Field field : fields) {
addField(field);
}
return this;
} | java | @GwtIncompatible("Class.getDeclaredFields")
public ToStringBuilder addDeclaredFields() {
Field[] fields = instance.getClass().getDeclaredFields();
for(Field field : fields) {
addField(field);
}
return this;
} | [
"@",
"GwtIncompatible",
"(",
"\"Class.getDeclaredFields\"",
")",
"public",
"ToStringBuilder",
"addDeclaredFields",
"(",
")",
"{",
"Field",
"[",
"]",
"fields",
"=",
"instance",
".",
"getClass",
"(",
")",
".",
"getDeclaredFields",
"(",
")",
";",
"for",
"(",
"Fie... | Adds all fields declared directly in the object's class to the output
@return this | [
"Adds",
"all",
"fields",
"declared",
"directly",
"in",
"the",
"object",
"s",
"class",
"to",
"the",
"output"
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ToStringBuilder.java#L114-L121 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ToStringBuilder.java | ToStringBuilder.addAllFields | @GwtIncompatible("Class.getDeclaredFields")
public ToStringBuilder addAllFields() {
List<Field> fields = getAllDeclaredFields(instance.getClass());
for(Field field : fields) {
addField(field);
}
return this;
} | java | @GwtIncompatible("Class.getDeclaredFields")
public ToStringBuilder addAllFields() {
List<Field> fields = getAllDeclaredFields(instance.getClass());
for(Field field : fields) {
addField(field);
}
return this;
} | [
"@",
"GwtIncompatible",
"(",
"\"Class.getDeclaredFields\"",
")",
"public",
"ToStringBuilder",
"addAllFields",
"(",
")",
"{",
"List",
"<",
"Field",
">",
"fields",
"=",
"getAllDeclaredFields",
"(",
"instance",
".",
"getClass",
"(",
")",
")",
";",
"for",
"(",
"Fi... | Adds all fields declared in the object's class and its superclasses to the output.
@return this | [
"Adds",
"all",
"fields",
"declared",
"in",
"the",
"object",
"s",
"class",
"and",
"its",
"superclasses",
"to",
"the",
"output",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/util/ToStringBuilder.java#L127-L134 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java | IteratorExtensions.filterNull | @Pure
public static <T> Iterator<T> filterNull(Iterator<T> unfiltered) {
return Iterators.filter(unfiltered, Predicates.notNull());
} | java | @Pure
public static <T> Iterator<T> filterNull(Iterator<T> unfiltered) {
return Iterators.filter(unfiltered, Predicates.notNull());
} | [
"@",
"Pure",
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"filterNull",
"(",
"Iterator",
"<",
"T",
">",
"unfiltered",
")",
"{",
"return",
"Iterators",
".",
"filter",
"(",
"unfiltered",
",",
"Predicates",
".",
"notNull",
"(",
")",
")",
... | Returns a new iterator filtering any null references.
@param unfiltered
the unfiltered iterator. May not be <code>null</code>.
@return an unmodifiable iterator containing all elements of the original iterator without any <code>null</code>
references. Never <code>null</code>. | [
"Returns",
"a",
"new",
"iterator",
"filtering",
"any",
"null",
"references",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java#L350-L353 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java | IteratorExtensions.toList | public static <T> List<T> toList(Iterator<? extends T> iterator) {
return Lists.newArrayList(iterator);
} | java | public static <T> List<T> toList(Iterator<? extends T> iterator) {
return Lists.newArrayList(iterator);
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"toList",
"(",
"Iterator",
"<",
"?",
"extends",
"T",
">",
"iterator",
")",
"{",
"return",
"Lists",
".",
"newArrayList",
"(",
"iterator",
")",
";",
"}"
] | Returns a list that contains all the entries of the given iterator in the same order.
@param iterator
the iterator. May not be <code>null</code>.
@return a list with the same entries as the given iterator. Never <code>null</code>. | [
"Returns",
"a",
"list",
"that",
"contains",
"all",
"the",
"entries",
"of",
"the",
"given",
"iterator",
"in",
"the",
"same",
"order",
"."
] | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java#L702-L704 | train |
eclipse/xtext-lib | org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java | IteratorExtensions.toSet | public static <T> Set<T> toSet(Iterator<? extends T> iterator) {
return Sets.newLinkedHashSet(toIterable(iterator));
} | java | public static <T> Set<T> toSet(Iterator<? extends T> iterator) {
return Sets.newLinkedHashSet(toIterable(iterator));
} | [
"public",
"static",
"<",
"T",
">",
"Set",
"<",
"T",
">",
"toSet",
"(",
"Iterator",
"<",
"?",
"extends",
"T",
">",
"iterator",
")",
"{",
"return",
"Sets",
".",
"newLinkedHashSet",
"(",
"toIterable",
"(",
"iterator",
")",
")",
";",
"}"
] | Returns a set that contains all the unique entries of the given iterator in the order of their appearance.
The result set is a copy of the iterator with stable order.
@param iterator
the iterator. May not be <code>null</code>.
@return a set with the unique entries of the given iterator. Never <code>null</code>. | [
"Returns",
"a",
"set",
"that",
"contains",
"all",
"the",
"unique",
"entries",
"of",
"the",
"given",
"iterator",
"in",
"the",
"order",
"of",
"their",
"appearance",
".",
"The",
"result",
"set",
"is",
"a",
"copy",
"of",
"the",
"iterator",
"with",
"stable",
... | 7063572e1f1bd713a3aa53bdf3a8dc60e25c169a | https://github.com/eclipse/xtext-lib/blob/7063572e1f1bd713a3aa53bdf3a8dc60e25c169a/org.eclipse.xtext.xbase.lib/src/org/eclipse/xtext/xbase/lib/IteratorExtensions.java#L714-L716 | train |
hap-java/HAP-Java | src/main/java/io/github/hapjava/HomekitServer.java | HomekitServer.createBridge | public HomekitRoot createBridge(
HomekitAuthInfo authInfo,
String label,
String manufacturer,
String model,
String serialNumber)
throws IOException {
HomekitRoot root = new HomekitRoot(label, http, localAddress, authInfo);
root.addAccessory(new HomekitBridge(label, serialNumber, model, manufacturer));
return root;
} | java | public HomekitRoot createBridge(
HomekitAuthInfo authInfo,
String label,
String manufacturer,
String model,
String serialNumber)
throws IOException {
HomekitRoot root = new HomekitRoot(label, http, localAddress, authInfo);
root.addAccessory(new HomekitBridge(label, serialNumber, model, manufacturer));
return root;
} | [
"public",
"HomekitRoot",
"createBridge",
"(",
"HomekitAuthInfo",
"authInfo",
",",
"String",
"label",
",",
"String",
"manufacturer",
",",
"String",
"model",
",",
"String",
"serialNumber",
")",
"throws",
"IOException",
"{",
"HomekitRoot",
"root",
"=",
"new",
"Homeki... | Creates a bridge accessory, capable of holding multiple child accessories. This has the
advantage over multiple standalone accessories of only requiring a single pairing from iOS for
the bridge.
@param authInfo authentication information for this accessory. These values should be persisted
and re-supplied on re-start of your application.
@param label label for the bridge. This will show in iOS during pairing.
@param manufacturer manufacturer of the bridge. This information is exposed to iOS for unknown
purposes.
@param model model of the bridge. This is also exposed to iOS for unknown purposes.
@param serialNumber serial number of the bridge. Also exposed. Purposes also unknown.
@return the bridge, from which you can {@link HomekitRoot#addAccessory add accessories} and
then {@link HomekitRoot#start start} handling requests.
@throws IOException when mDNS cannot connect to the network | [
"Creates",
"a",
"bridge",
"accessory",
"capable",
"of",
"holding",
"multiple",
"child",
"accessories",
".",
"This",
"has",
"the",
"advantage",
"over",
"multiple",
"standalone",
"accessories",
"of",
"only",
"requiring",
"a",
"single",
"pairing",
"from",
"iOS",
"f... | d2b2f4f1579580a2b5958af3a192128345843db9 | https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/HomekitServer.java#L104-L114 | train |
hap-java/HAP-Java | src/main/java/io/github/hapjava/characteristics/BaseCharacteristic.java | BaseCharacteristic.makeBuilder | protected CompletableFuture<JsonObjectBuilder> makeBuilder(int instanceId) {
CompletableFuture<T> futureValue = getValue();
if (futureValue == null) {
logger.error("Could not retrieve value " + this.getClass().getName());
return null;
}
return futureValue
.exceptionally(
t -> {
logger.error("Could not retrieve value " + this.getClass().getName(), t);
return null;
})
.thenApply(
value -> {
JsonArrayBuilder perms = Json.createArrayBuilder();
if (isWritable) {
perms.add("pw");
}
if (isReadable) {
perms.add("pr");
}
if (isEventable) {
perms.add("ev");
}
JsonObjectBuilder builder =
Json.createObjectBuilder()
.add("iid", instanceId)
.add("type", shortType)
.add("perms", perms.build())
.add("format", format)
.add("ev", false)
.add("description", description);
setJsonValue(builder, value);
return builder;
});
} | java | protected CompletableFuture<JsonObjectBuilder> makeBuilder(int instanceId) {
CompletableFuture<T> futureValue = getValue();
if (futureValue == null) {
logger.error("Could not retrieve value " + this.getClass().getName());
return null;
}
return futureValue
.exceptionally(
t -> {
logger.error("Could not retrieve value " + this.getClass().getName(), t);
return null;
})
.thenApply(
value -> {
JsonArrayBuilder perms = Json.createArrayBuilder();
if (isWritable) {
perms.add("pw");
}
if (isReadable) {
perms.add("pr");
}
if (isEventable) {
perms.add("ev");
}
JsonObjectBuilder builder =
Json.createObjectBuilder()
.add("iid", instanceId)
.add("type", shortType)
.add("perms", perms.build())
.add("format", format)
.add("ev", false)
.add("description", description);
setJsonValue(builder, value);
return builder;
});
} | [
"protected",
"CompletableFuture",
"<",
"JsonObjectBuilder",
">",
"makeBuilder",
"(",
"int",
"instanceId",
")",
"{",
"CompletableFuture",
"<",
"T",
">",
"futureValue",
"=",
"getValue",
"(",
")",
";",
"if",
"(",
"futureValue",
"==",
"null",
")",
"{",
"logger",
... | Creates the JSON serialized form of the accessory for use over the Homekit Accessory Protocol.
@param instanceId the static id of the accessory.
@return a future that will complete with the JSON builder for the object. | [
"Creates",
"the",
"JSON",
"serialized",
"form",
"of",
"the",
"accessory",
"for",
"use",
"over",
"the",
"Homekit",
"Accessory",
"Protocol",
"."
] | d2b2f4f1579580a2b5958af3a192128345843db9 | https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/characteristics/BaseCharacteristic.java#L70-L107 | train |
hap-java/HAP-Java | src/main/java/io/github/hapjava/characteristics/BaseCharacteristic.java | BaseCharacteristic.setJsonValue | protected void setJsonValue(JsonObjectBuilder builder, T value) {
// I don't like this - there should really be a way to construct a disconnected JSONValue...
if (value instanceof Boolean) {
builder.add("value", (Boolean) value);
} else if (value instanceof Double) {
builder.add("value", (Double) value);
} else if (value instanceof Integer) {
builder.add("value", (Integer) value);
} else if (value instanceof Long) {
builder.add("value", (Long) value);
} else if (value instanceof BigInteger) {
builder.add("value", (BigInteger) value);
} else if (value instanceof BigDecimal) {
builder.add("value", (BigDecimal) value);
} else if (value == null) {
builder.addNull("value");
} else {
builder.add("value", value.toString());
}
} | java | protected void setJsonValue(JsonObjectBuilder builder, T value) {
// I don't like this - there should really be a way to construct a disconnected JSONValue...
if (value instanceof Boolean) {
builder.add("value", (Boolean) value);
} else if (value instanceof Double) {
builder.add("value", (Double) value);
} else if (value instanceof Integer) {
builder.add("value", (Integer) value);
} else if (value instanceof Long) {
builder.add("value", (Long) value);
} else if (value instanceof BigInteger) {
builder.add("value", (BigInteger) value);
} else if (value instanceof BigDecimal) {
builder.add("value", (BigDecimal) value);
} else if (value == null) {
builder.addNull("value");
} else {
builder.add("value", value.toString());
}
} | [
"protected",
"void",
"setJsonValue",
"(",
"JsonObjectBuilder",
"builder",
",",
"T",
"value",
")",
"{",
"// I don't like this - there should really be a way to construct a disconnected JSONValue...",
"if",
"(",
"value",
"instanceof",
"Boolean",
")",
"{",
"builder",
".",
"add... | Writes the value key to the serialized characteristic
@param builder The JSON builder to add the value to
@param value The value to add | [
"Writes",
"the",
"value",
"key",
"to",
"the",
"serialized",
"characteristic"
] | d2b2f4f1579580a2b5958af3a192128345843db9 | https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/characteristics/BaseCharacteristic.java#L167-L186 | train |
hap-java/HAP-Java | src/main/java/io/github/hapjava/impl/connections/SubscriptionManager.java | SubscriptionManager.removeAll | public void removeAll() {
LOGGER.debug("Removing {} reverse connections from subscription manager", reverse.size());
Iterator<HomekitClientConnection> i = reverse.keySet().iterator();
while (i.hasNext()) {
HomekitClientConnection connection = i.next();
LOGGER.debug("Removing connection {}", connection.hashCode());
removeConnection(connection);
}
LOGGER.debug("Subscription sizes are {} and {}", reverse.size(), subscriptions.size());
} | java | public void removeAll() {
LOGGER.debug("Removing {} reverse connections from subscription manager", reverse.size());
Iterator<HomekitClientConnection> i = reverse.keySet().iterator();
while (i.hasNext()) {
HomekitClientConnection connection = i.next();
LOGGER.debug("Removing connection {}", connection.hashCode());
removeConnection(connection);
}
LOGGER.debug("Subscription sizes are {} and {}", reverse.size(), subscriptions.size());
} | [
"public",
"void",
"removeAll",
"(",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Removing {} reverse connections from subscription manager\"",
",",
"reverse",
".",
"size",
"(",
")",
")",
";",
"Iterator",
"<",
"HomekitClientConnection",
">",
"i",
"=",
"reverse",
".",
... | Remove all existing subscriptions | [
"Remove",
"all",
"existing",
"subscriptions"
] | d2b2f4f1579580a2b5958af3a192128345843db9 | https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/impl/connections/SubscriptionManager.java#L144-L153 | train |
hap-java/HAP-Java | src/main/java/io/github/hapjava/HomekitRoot.java | HomekitRoot.addAccessory | public void addAccessory(HomekitAccessory accessory) {
if (accessory.getId() <= 1 && !(accessory instanceof Bridge)) {
throw new IndexOutOfBoundsException(
"The ID of an accessory used in a bridge must be greater than 1");
}
addAccessorySkipRangeCheck(accessory);
} | java | public void addAccessory(HomekitAccessory accessory) {
if (accessory.getId() <= 1 && !(accessory instanceof Bridge)) {
throw new IndexOutOfBoundsException(
"The ID of an accessory used in a bridge must be greater than 1");
}
addAccessorySkipRangeCheck(accessory);
} | [
"public",
"void",
"addAccessory",
"(",
"HomekitAccessory",
"accessory",
")",
"{",
"if",
"(",
"accessory",
".",
"getId",
"(",
")",
"<=",
"1",
"&&",
"!",
"(",
"accessory",
"instanceof",
"Bridge",
")",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",... | Add an accessory to be handled and advertised by this root. Any existing Homekit connections
will be terminated to allow the clients to reconnect and see the updated accessory list. When
using this for a bridge, the ID of the accessory must be greater than 1, as that ID is reserved
for the Bridge itself.
@param accessory to advertise and handle. | [
"Add",
"an",
"accessory",
"to",
"be",
"handled",
"and",
"advertised",
"by",
"this",
"root",
".",
"Any",
"existing",
"Homekit",
"connections",
"will",
"be",
"terminated",
"to",
"allow",
"the",
"clients",
"to",
"reconnect",
"and",
"see",
"the",
"updated",
"acc... | d2b2f4f1579580a2b5958af3a192128345843db9 | https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/HomekitRoot.java#L63-L69 | train |
hap-java/HAP-Java | src/main/java/io/github/hapjava/HomekitRoot.java | HomekitRoot.removeAccessory | public void removeAccessory(HomekitAccessory accessory) {
this.registry.remove(accessory);
logger.info("Removed accessory " + accessory.getLabel());
if (started) {
registry.reset();
webHandler.resetConnections();
}
} | java | public void removeAccessory(HomekitAccessory accessory) {
this.registry.remove(accessory);
logger.info("Removed accessory " + accessory.getLabel());
if (started) {
registry.reset();
webHandler.resetConnections();
}
} | [
"public",
"void",
"removeAccessory",
"(",
"HomekitAccessory",
"accessory",
")",
"{",
"this",
".",
"registry",
".",
"remove",
"(",
"accessory",
")",
";",
"logger",
".",
"info",
"(",
"\"Removed accessory \"",
"+",
"accessory",
".",
"getLabel",
"(",
")",
")",
"... | Removes an accessory from being handled or advertised by this root. Any existing Homekit
connections will be terminated to allow the clients to reconnect and see the updated accessory
list.
@param accessory accessory to cease advertising and handling | [
"Removes",
"an",
"accessory",
"from",
"being",
"handled",
"or",
"advertised",
"by",
"this",
"root",
".",
"Any",
"existing",
"Homekit",
"connections",
"will",
"be",
"terminated",
"to",
"allow",
"the",
"clients",
"to",
"reconnect",
"and",
"see",
"the",
"updated"... | d2b2f4f1579580a2b5958af3a192128345843db9 | https://github.com/hap-java/HAP-Java/blob/d2b2f4f1579580a2b5958af3a192128345843db9/src/main/java/io/github/hapjava/HomekitRoot.java#L93-L100 | train |
smanikandan14/ThinDownloadManager | ThinDownloadManager/src/main/java/com/thin/downloadmanager/ThinDownloadManager.java | ThinDownloadManager.add | @Override
public int add(DownloadRequest request) throws IllegalArgumentException {
checkReleased("add(...) called on a released ThinDownloadManager.");
if (request == null) {
throw new IllegalArgumentException("DownloadRequest cannot be null");
}
return mRequestQueue.add(request);
} | java | @Override
public int add(DownloadRequest request) throws IllegalArgumentException {
checkReleased("add(...) called on a released ThinDownloadManager.");
if (request == null) {
throw new IllegalArgumentException("DownloadRequest cannot be null");
}
return mRequestQueue.add(request);
} | [
"@",
"Override",
"public",
"int",
"add",
"(",
"DownloadRequest",
"request",
")",
"throws",
"IllegalArgumentException",
"{",
"checkReleased",
"(",
"\"add(...) called on a released ThinDownloadManager.\"",
")",
";",
"if",
"(",
"request",
"==",
"null",
")",
"{",
"throw",... | Add a new download. The download will start automatically once the download manager is
ready to execute it and connectivity is available.
@param request the parameters specifying this download
@return an ID for the download, unique across the application. This ID is used to make future
calls related to this download.
@throws IllegalArgumentException | [
"Add",
"a",
"new",
"download",
".",
"The",
"download",
"will",
"start",
"automatically",
"once",
"the",
"download",
"manager",
"is",
"ready",
"to",
"execute",
"it",
"and",
"connectivity",
"is",
"available",
"."
] | 63c153c918eff0b1c9de384171563d2c70baea5e | https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/ThinDownloadManager.java#L74-L81 | train |
smanikandan14/ThinDownloadManager | ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequest.java | DownloadRequest.addCustomHeader | public DownloadRequest addCustomHeader(String key, String value) {
mCustomHeader.put(key, value);
return this;
} | java | public DownloadRequest addCustomHeader(String key, String value) {
mCustomHeader.put(key, value);
return this;
} | [
"public",
"DownloadRequest",
"addCustomHeader",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"mCustomHeader",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Adds custom header to request
@param key
@param value | [
"Adds",
"custom",
"header",
"to",
"request"
] | 63c153c918eff0b1c9de384171563d2c70baea5e | https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequest.java#L112-L115 | train |
smanikandan14/ThinDownloadManager | ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadDispatcher.java | DownloadDispatcher.cleanupDestination | private void cleanupDestination(DownloadRequest request, boolean forceClean) {
if (!request.isResumable() || forceClean) {
Log.d("cleanupDestination() deleting " + request.getDestinationURI().getPath());
File destinationFile = new File(request.getDestinationURI().getPath());
if (destinationFile.exists()) {
destinationFile.delete();
}
}
} | java | private void cleanupDestination(DownloadRequest request, boolean forceClean) {
if (!request.isResumable() || forceClean) {
Log.d("cleanupDestination() deleting " + request.getDestinationURI().getPath());
File destinationFile = new File(request.getDestinationURI().getPath());
if (destinationFile.exists()) {
destinationFile.delete();
}
}
} | [
"private",
"void",
"cleanupDestination",
"(",
"DownloadRequest",
"request",
",",
"boolean",
"forceClean",
")",
"{",
"if",
"(",
"!",
"request",
".",
"isResumable",
"(",
")",
"||",
"forceClean",
")",
"{",
"Log",
".",
"d",
"(",
"\"cleanupDestination() deleting \"",... | Called just before the thread finishes, regardless of status, to take any necessary action on
the downloaded file with mDownloadedCacheSize file.
@param forceClean - It will delete downloaded cache, Even streaming is enabled, If user intentionally cancelled. | [
"Called",
"just",
"before",
"the",
"thread",
"finishes",
"regardless",
"of",
"status",
"to",
"take",
"any",
"necessary",
"action",
"on",
"the",
"downloaded",
"file",
"with",
"mDownloadedCacheSize",
"file",
"."
] | 63c153c918eff0b1c9de384171563d2c70baea5e | https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadDispatcher.java#L438-L446 | train |
smanikandan14/ThinDownloadManager | ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java | DownloadRequestQueue.add | int add(DownloadRequest request) {
int downloadId = getDownloadId();
// Tag the request as belonging to this queue and add it to the set of current requests.
request.setDownloadRequestQueue(this);
synchronized (mCurrentRequests) {
mCurrentRequests.add(request);
}
// Process requests in the order they are added.
request.setDownloadId(downloadId);
mDownloadQueue.add(request);
return downloadId;
} | java | int add(DownloadRequest request) {
int downloadId = getDownloadId();
// Tag the request as belonging to this queue and add it to the set of current requests.
request.setDownloadRequestQueue(this);
synchronized (mCurrentRequests) {
mCurrentRequests.add(request);
}
// Process requests in the order they are added.
request.setDownloadId(downloadId);
mDownloadQueue.add(request);
return downloadId;
} | [
"int",
"add",
"(",
"DownloadRequest",
"request",
")",
"{",
"int",
"downloadId",
"=",
"getDownloadId",
"(",
")",
";",
"// Tag the request as belonging to this queue and add it to the set of current requests.",
"request",
".",
"setDownloadRequestQueue",
"(",
"this",
")",
";",... | Generates a download id for the request and adds the download request to the download request queue for the dispatchers pool to act on immediately.
@param request
@return downloadId | [
"Generates",
"a",
"download",
"id",
"for",
"the",
"request",
"and",
"adds",
"the",
"download",
"request",
"to",
"the",
"download",
"request",
"queue",
"for",
"the",
"dispatchers",
"pool",
"to",
"act",
"on",
"immediately",
"."
] | 63c153c918eff0b1c9de384171563d2c70baea5e | https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L142-L156 | train |
smanikandan14/ThinDownloadManager | ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java | DownloadRequestQueue.query | int query(int downloadId) {
synchronized (mCurrentRequests) {
for (DownloadRequest request : mCurrentRequests) {
if (request.getDownloadId() == downloadId) {
return request.getDownloadState();
}
}
}
return DownloadManager.STATUS_NOT_FOUND;
} | java | int query(int downloadId) {
synchronized (mCurrentRequests) {
for (DownloadRequest request : mCurrentRequests) {
if (request.getDownloadId() == downloadId) {
return request.getDownloadState();
}
}
}
return DownloadManager.STATUS_NOT_FOUND;
} | [
"int",
"query",
"(",
"int",
"downloadId",
")",
"{",
"synchronized",
"(",
"mCurrentRequests",
")",
"{",
"for",
"(",
"DownloadRequest",
"request",
":",
"mCurrentRequests",
")",
"{",
"if",
"(",
"request",
".",
"getDownloadId",
"(",
")",
"==",
"downloadId",
")",... | Returns the current download state for a download request.
@param downloadId
@return | [
"Returns",
"the",
"current",
"download",
"state",
"for",
"a",
"download",
"request",
"."
] | 63c153c918eff0b1c9de384171563d2c70baea5e | https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L164-L173 | train |
smanikandan14/ThinDownloadManager | ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java | DownloadRequestQueue.cancel | int cancel(int downloadId) {
synchronized (mCurrentRequests) {
for (DownloadRequest request : mCurrentRequests) {
if (request.getDownloadId() == downloadId) {
request.cancel();
return 1;
}
}
}
return 0;
} | java | int cancel(int downloadId) {
synchronized (mCurrentRequests) {
for (DownloadRequest request : mCurrentRequests) {
if (request.getDownloadId() == downloadId) {
request.cancel();
return 1;
}
}
}
return 0;
} | [
"int",
"cancel",
"(",
"int",
"downloadId",
")",
"{",
"synchronized",
"(",
"mCurrentRequests",
")",
"{",
"for",
"(",
"DownloadRequest",
"request",
":",
"mCurrentRequests",
")",
"{",
"if",
"(",
"request",
".",
"getDownloadId",
"(",
")",
"==",
"downloadId",
")"... | Cancel a particular download in progress. Returns 1 if the download Id is found else returns 0.
@param downloadId
@return int | [
"Cancel",
"a",
"particular",
"download",
"in",
"progress",
".",
"Returns",
"1",
"if",
"the",
"download",
"Id",
"is",
"found",
"else",
"returns",
"0",
"."
] | 63c153c918eff0b1c9de384171563d2c70baea5e | https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L196-L207 | train |
smanikandan14/ThinDownloadManager | ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java | DownloadRequestQueue.release | void release() {
if (mCurrentRequests != null) {
synchronized (mCurrentRequests) {
mCurrentRequests.clear();
mCurrentRequests = null;
}
}
if (mDownloadQueue != null) {
mDownloadQueue = null;
}
if (mDownloadDispatchers != null) {
stop();
for (int i = 0; i < mDownloadDispatchers.length; i++) {
mDownloadDispatchers[i] = null;
}
mDownloadDispatchers = null;
}
} | java | void release() {
if (mCurrentRequests != null) {
synchronized (mCurrentRequests) {
mCurrentRequests.clear();
mCurrentRequests = null;
}
}
if (mDownloadQueue != null) {
mDownloadQueue = null;
}
if (mDownloadDispatchers != null) {
stop();
for (int i = 0; i < mDownloadDispatchers.length; i++) {
mDownloadDispatchers[i] = null;
}
mDownloadDispatchers = null;
}
} | [
"void",
"release",
"(",
")",
"{",
"if",
"(",
"mCurrentRequests",
"!=",
"null",
")",
"{",
"synchronized",
"(",
"mCurrentRequests",
")",
"{",
"mCurrentRequests",
".",
"clear",
"(",
")",
";",
"mCurrentRequests",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"mDown... | Cancels all the pending & running requests and releases all the dispatchers. | [
"Cancels",
"all",
"the",
"pending",
"&",
"running",
"requests",
"and",
"releases",
"all",
"the",
"dispatchers",
"."
] | 63c153c918eff0b1c9de384171563d2c70baea5e | https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L260-L281 | train |
smanikandan14/ThinDownloadManager | ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java | DownloadRequestQueue.initialize | private void initialize(Handler callbackHandler) {
int processors = Runtime.getRuntime().availableProcessors();
mDownloadDispatchers = new DownloadDispatcher[processors];
mDelivery = new CallBackDelivery(callbackHandler);
} | java | private void initialize(Handler callbackHandler) {
int processors = Runtime.getRuntime().availableProcessors();
mDownloadDispatchers = new DownloadDispatcher[processors];
mDelivery = new CallBackDelivery(callbackHandler);
} | [
"private",
"void",
"initialize",
"(",
"Handler",
"callbackHandler",
")",
"{",
"int",
"processors",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"availableProcessors",
"(",
")",
";",
"mDownloadDispatchers",
"=",
"new",
"DownloadDispatcher",
"[",
"processors",
... | Perform construction.
@param callbackHandler | [
"Perform",
"construction",
"."
] | 63c153c918eff0b1c9de384171563d2c70baea5e | https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L290-L294 | train |
smanikandan14/ThinDownloadManager | ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java | DownloadRequestQueue.initialize | private void initialize(Handler callbackHandler, int threadPoolSize) {
mDownloadDispatchers = new DownloadDispatcher[threadPoolSize];
mDelivery = new CallBackDelivery(callbackHandler);
} | java | private void initialize(Handler callbackHandler, int threadPoolSize) {
mDownloadDispatchers = new DownloadDispatcher[threadPoolSize];
mDelivery = new CallBackDelivery(callbackHandler);
} | [
"private",
"void",
"initialize",
"(",
"Handler",
"callbackHandler",
",",
"int",
"threadPoolSize",
")",
"{",
"mDownloadDispatchers",
"=",
"new",
"DownloadDispatcher",
"[",
"threadPoolSize",
"]",
";",
"mDelivery",
"=",
"new",
"CallBackDelivery",
"(",
"callbackHandler",
... | Perform construction with custom thread pool size. | [
"Perform",
"construction",
"with",
"custom",
"thread",
"pool",
"size",
"."
] | 63c153c918eff0b1c9de384171563d2c70baea5e | https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L299-L302 | train |
smanikandan14/ThinDownloadManager | ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java | DownloadRequestQueue.stop | private void stop() {
for (int i = 0; i < mDownloadDispatchers.length; i++) {
if (mDownloadDispatchers[i] != null) {
mDownloadDispatchers[i].quit();
}
}
} | java | private void stop() {
for (int i = 0; i < mDownloadDispatchers.length; i++) {
if (mDownloadDispatchers[i] != null) {
mDownloadDispatchers[i].quit();
}
}
} | [
"private",
"void",
"stop",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mDownloadDispatchers",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"mDownloadDispatchers",
"[",
"i",
"]",
"!=",
"null",
")",
"{",
"mDownloadDispatcher... | Stops download dispatchers. | [
"Stops",
"download",
"dispatchers",
"."
] | 63c153c918eff0b1c9de384171563d2c70baea5e | https://github.com/smanikandan14/ThinDownloadManager/blob/63c153c918eff0b1c9de384171563d2c70baea5e/ThinDownloadManager/src/main/java/com/thin/downloadmanager/DownloadRequestQueue.java#L307-L313 | train |
streamsets/datacollector-api | src/main/java/com/streamsets/pipeline/api/Field.java | Field.getValueAsMap | @SuppressWarnings("unchecked")
public Map<String, Field> getValueAsMap() {
return (Map<String, Field>) type.convert(getValue(), Type.MAP);
} | java | @SuppressWarnings("unchecked")
public Map<String, Field> getValueAsMap() {
return (Map<String, Field>) type.convert(getValue(), Type.MAP);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Map",
"<",
"String",
",",
"Field",
">",
"getValueAsMap",
"(",
")",
"{",
"return",
"(",
"Map",
"<",
"String",
",",
"Field",
">",
")",
"type",
".",
"convert",
"(",
"getValue",
"(",
")",
",",
... | Returns the Map value of the field.
@return the Map value of the field. It returns a reference of the value both for <code>MAP</code> and
<code>LIST_MAP</code>.
@throws IllegalArgumentException if the value cannot be converted to Map. | [
"Returns",
"the",
"Map",
"value",
"of",
"the",
"field",
"."
] | ac832a97bea2fcef11f50fac6746e85019adad58 | https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/Field.java#L620-L623 | train |
streamsets/datacollector-api | src/main/java/com/streamsets/pipeline/api/Field.java | Field.getValueAsList | @SuppressWarnings("unchecked")
public List<Field> getValueAsList() {
return (List<Field>) type.convert(getValue(), Type.LIST);
} | java | @SuppressWarnings("unchecked")
public List<Field> getValueAsList() {
return (List<Field>) type.convert(getValue(), Type.LIST);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"List",
"<",
"Field",
">",
"getValueAsList",
"(",
")",
"{",
"return",
"(",
"List",
"<",
"Field",
">",
")",
"type",
".",
"convert",
"(",
"getValue",
"(",
")",
",",
"Type",
".",
"LIST",
")",
... | Returns the List value of the field.
@return the List value of the field. It returns a reference of the value if the type is <code>LIST</code>, if
the type is <code>LIST_MAP</code> it returns a copy of the value.
@throws IllegalArgumentException if the value cannot be converted to List. | [
"Returns",
"the",
"List",
"value",
"of",
"the",
"field",
"."
] | ac832a97bea2fcef11f50fac6746e85019adad58 | https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/Field.java#L632-L635 | train |
streamsets/datacollector-api | src/main/java/com/streamsets/pipeline/api/Field.java | Field.getValueAsListMap | @SuppressWarnings("unchecked")
public LinkedHashMap<String, Field> getValueAsListMap() {
return (LinkedHashMap<String, Field>) type.convert(getValue(), Type.LIST_MAP);
} | java | @SuppressWarnings("unchecked")
public LinkedHashMap<String, Field> getValueAsListMap() {
return (LinkedHashMap<String, Field>) type.convert(getValue(), Type.LIST_MAP);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"LinkedHashMap",
"<",
"String",
",",
"Field",
">",
"getValueAsListMap",
"(",
")",
"{",
"return",
"(",
"LinkedHashMap",
"<",
"String",
",",
"Field",
">",
")",
"type",
".",
"convert",
"(",
"getValue... | Returns the ordered Map value of the field.
@return the ordered Map value of the field. It returns a reference of the value.
@throws IllegalArgumentException if the value cannot be converted to ordered Map. | [
"Returns",
"the",
"ordered",
"Map",
"value",
"of",
"the",
"field",
"."
] | ac832a97bea2fcef11f50fac6746e85019adad58 | https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/Field.java#L643-L646 | train |
streamsets/datacollector-api | src/main/java/com/streamsets/pipeline/api/Field.java | Field.getAttributeNames | public Set<String> getAttributeNames() {
if (attributes == null) {
return Collections.emptySet();
} else {
return Collections.unmodifiableSet(attributes.keySet());
}
} | java | public Set<String> getAttributeNames() {
if (attributes == null) {
return Collections.emptySet();
} else {
return Collections.unmodifiableSet(attributes.keySet());
}
} | [
"public",
"Set",
"<",
"String",
">",
"getAttributeNames",
"(",
")",
"{",
"if",
"(",
"attributes",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"emptySet",
"(",
")",
";",
"}",
"else",
"{",
"return",
"Collections",
".",
"unmodifiableSet",
"(",
"at... | Returns the list of user defined attribute names.
@return the list of user defined attribute names, if there are none it returns an empty set. | [
"Returns",
"the",
"list",
"of",
"user",
"defined",
"attribute",
"names",
"."
] | ac832a97bea2fcef11f50fac6746e85019adad58 | https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/Field.java#L665-L671 | train |
streamsets/datacollector-api | src/main/java/com/streamsets/pipeline/api/Field.java | Field.getAttributes | public Map<String, String> getAttributes() {
if (attributes == null) {
return null;
} else {
return Collections.unmodifiableMap(attributes);
}
} | java | public Map<String, String> getAttributes() {
if (attributes == null) {
return null;
} else {
return Collections.unmodifiableMap(attributes);
}
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getAttributes",
"(",
")",
"{",
"if",
"(",
"attributes",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"Collections",
".",
"unmodifiableMap",
"(",
"attributes",
")",
";",
... | Get all field attributes in an unmodifiable Map, or null if no attributes have been added
@return all field attributes, or <code>NULL</code> if none exist | [
"Get",
"all",
"field",
"attributes",
"in",
"an",
"unmodifiable",
"Map",
"or",
"null",
"if",
"no",
"attributes",
"have",
"been",
"added"
] | ac832a97bea2fcef11f50fac6746e85019adad58 | https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/Field.java#L735-L741 | train |
streamsets/datacollector-api | src/main/java/com/streamsets/pipeline/api/impl/Utils.java | Utils.formatL | public static Object formatL(final String template, final Object... args) {
return new Object() {
@Override
public String toString() {
return format(template, args);
}
};
} | java | public static Object formatL(final String template, final Object... args) {
return new Object() {
@Override
public String toString() {
return format(template, args);
}
};
} | [
"public",
"static",
"Object",
"formatL",
"(",
"final",
"String",
"template",
",",
"final",
"Object",
"...",
"args",
")",
"{",
"return",
"new",
"Object",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"format",
"(... | format with lazy-eval | [
"format",
"with",
"lazy",
"-",
"eval"
] | ac832a97bea2fcef11f50fac6746e85019adad58 | https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/impl/Utils.java#L123-L130 | train |
streamsets/datacollector-api | src/main/java/com/streamsets/pipeline/api/base/BaseService.java | BaseService.init | @Override
public List<ConfigIssue> init(Service.Context context) {
this.context = context;
return init();
} | java | @Override
public List<ConfigIssue> init(Service.Context context) {
this.context = context;
return init();
} | [
"@",
"Override",
"public",
"List",
"<",
"ConfigIssue",
">",
"init",
"(",
"Service",
".",
"Context",
"context",
")",
"{",
"this",
".",
"context",
"=",
"context",
";",
"return",
"init",
"(",
")",
";",
"}"
] | Initializes the service.
Stores the <code>Service.Context</code> in instance variables and calls the {@link #init()} method.
@param context Service context.
@return The list of configuration issues found during initialization, an empty list if none. | [
"Initializes",
"the",
"service",
"."
] | ac832a97bea2fcef11f50fac6746e85019adad58 | https://github.com/streamsets/datacollector-api/blob/ac832a97bea2fcef11f50fac6746e85019adad58/src/main/java/com/streamsets/pipeline/api/base/BaseService.java#L37-L41 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.