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
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/search/AbstractSearcher.java
AbstractSearcher.searchForAll
public <E> Iterable<E> searchForAll(final Collection<E> collection) { Assert.notNull(collection, "The collection to search cannot be null!"); final List<E> results = new ArrayList<>(collection.size()); for (E element : collection) { if (getMatcher().isMatch(element)) { results.add(element); } } return results; }
java
public <E> Iterable<E> searchForAll(final Collection<E> collection) { Assert.notNull(collection, "The collection to search cannot be null!"); final List<E> results = new ArrayList<>(collection.size()); for (E element : collection) { if (getMatcher().isMatch(element)) { results.add(element); } } return results; }
[ "public", "<", "E", ">", "Iterable", "<", "E", ">", "searchForAll", "(", "final", "Collection", "<", "E", ">", "collection", ")", "{", "Assert", ".", "notNull", "(", "collection", ",", "\"The collection to search cannot be null!\"", ")", ";", "final", "List", ...
Searches a collection of elements finding all elements in the collection matching the criteria defined by the Matcher. @param <E> the Class type of elements in the collection. @param collection the collection of elements to search. @return an Iterable object containing all elements in the collection that match the criteria defined by the Matcher. @throws NullPointerException if the collection is null! @see #getMatcher() @see java.lang.Iterable @see java.util.Collection
[ "Searches", "a", "collection", "of", "elements", "finding", "all", "elements", "in", "the", "collection", "matching", "the", "criteria", "defined", "by", "the", "Matcher", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/search/AbstractSearcher.java#L202-L214
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/search/AbstractSearcher.java
AbstractSearcher.searchForAll
public <E> Iterable<E> searchForAll(final Searchable<E> searchable) { try { return searchForAll(configureMatcher(searchable).asList()); } finally { MatcherHolder.unset(); } }
java
public <E> Iterable<E> searchForAll(final Searchable<E> searchable) { try { return searchForAll(configureMatcher(searchable).asList()); } finally { MatcherHolder.unset(); } }
[ "public", "<", "E", ">", "Iterable", "<", "E", ">", "searchForAll", "(", "final", "Searchable", "<", "E", ">", "searchable", ")", "{", "try", "{", "return", "searchForAll", "(", "configureMatcher", "(", "searchable", ")", ".", "asList", "(", ")", ")", ...
Searches the Searchable object finding all elements in the Searchable object matching the criteria defined by the Matcher. @param <E> the Class type of elements to search in the Searchable object. @param searchable the Searchable object to search. @return an Iterable object containing all elements from the Searchable object that match the criteria defined by the Matcher. @throws NullPointerException if the Searchable object is null! @see #configureMatcher(Searchable) @see #searchForAll(java.util.Collection) @see java.lang.Iterable @see org.cp.elements.util.search.Searchable#asList()
[ "Searches", "the", "Searchable", "object", "finding", "all", "elements", "in", "the", "Searchable", "object", "matching", "the", "criteria", "defined", "by", "the", "Matcher", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/search/AbstractSearcher.java#L230-L237
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/search/AbstractSearcher.java
AbstractSearcher.configureMatcher
protected <T> Searchable<T> configureMatcher(final Searchable<T> searchable) { if (isCustomMatcherAllowed()) { Matcher<T> matcher = searchable.getMatcher(); if (matcher != null) { MatcherHolder.set(matcher); } } return searchable; }
java
protected <T> Searchable<T> configureMatcher(final Searchable<T> searchable) { if (isCustomMatcherAllowed()) { Matcher<T> matcher = searchable.getMatcher(); if (matcher != null) { MatcherHolder.set(matcher); } } return searchable; }
[ "protected", "<", "T", ">", "Searchable", "<", "T", ">", "configureMatcher", "(", "final", "Searchable", "<", "T", ">", "searchable", ")", "{", "if", "(", "isCustomMatcherAllowed", "(", ")", ")", "{", "Matcher", "<", "T", ">", "matcher", "=", "searchable...
Configures the desired Matcher used to match and find elements from the Searchable implementing object based on the annotation meta-data, applying only to the calling Thread and only if a custom Matcher is allowed. The Matcher is local to calling Thread during the search operation and does not change the Matcher set on the Searcher. @param <T> the class type of the elements in the {@link Searchable} collection. @param searchable the Searchable implementing object used to determine the desired Matcher used to match and find elements during the search operation. @return the Searchable implementing object evaluated, allowing this method call to be chained. @see #isCustomMatcherAllowed() @see MatcherHolder#set(Matcher) @see org.cp.elements.util.search.Searchable#getMatcher()
[ "Configures", "the", "desired", "Matcher", "used", "to", "match", "and", "find", "elements", "from", "the", "Searchable", "implementing", "object", "based", "on", "the", "annotation", "meta", "-", "data", "applying", "only", "to", "the", "calling", "Thread", "...
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/search/AbstractSearcher.java#L300-L310
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/io/FileUtils.java
FileUtils.assertExists
@NullSafe public static File assertExists(File path) throws FileNotFoundException { if (isExisting(path)) { return path; } throw new FileNotFoundException(String.format("[%1$s] was not found", path)); }
java
@NullSafe public static File assertExists(File path) throws FileNotFoundException { if (isExisting(path)) { return path; } throw new FileNotFoundException(String.format("[%1$s] was not found", path)); }
[ "@", "NullSafe", "public", "static", "File", "assertExists", "(", "File", "path", ")", "throws", "FileNotFoundException", "{", "if", "(", "isExisting", "(", "path", ")", ")", "{", "return", "path", ";", "}", "throw", "new", "FileNotFoundException", "(", "Str...
Asserts that the given file exists. @param path the {@link File} to assert for existence. @return a reference back to the file. @throws java.io.FileNotFoundException if the file does not exist. @see #isExisting(File)
[ "Asserts", "that", "the", "given", "file", "exists", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/io/FileUtils.java#L52-L59
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/io/FileUtils.java
FileUtils.getExtension
public static String getExtension(File file) { Assert.notNull(file, "File cannot be null"); String filename = file.getName(); int dotIndex = filename.indexOf(StringUtils.DOT_SEPARATOR); return (dotIndex != -1 ? filename.substring(dotIndex + 1) : StringUtils.EMPTY_STRING); }
java
public static String getExtension(File file) { Assert.notNull(file, "File cannot be null"); String filename = file.getName(); int dotIndex = filename.indexOf(StringUtils.DOT_SEPARATOR); return (dotIndex != -1 ? filename.substring(dotIndex + 1) : StringUtils.EMPTY_STRING); }
[ "public", "static", "String", "getExtension", "(", "File", "file", ")", "{", "Assert", ".", "notNull", "(", "file", ",", "\"File cannot be null\"", ")", ";", "String", "filename", "=", "file", ".", "getName", "(", ")", ";", "int", "dotIndex", "=", "filenam...
Returns the extension of the given file. @param file the {@link File} from which to get the extension. @return the file extension of the given file or an empty String if the file does not have an extension. @throws java.lang.NullPointerException if the file reference is null. @see java.io.File#getName()
[ "Returns", "the", "extension", "of", "the", "given", "file", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/io/FileUtils.java#L115-L120
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/io/FileUtils.java
FileUtils.getLocation
public static String getLocation(File file) { Assert.notNull(file, "File cannot be null"); File parent = file.getParentFile(); Assert.notNull(parent, new IllegalArgumentException(String.format( "Unable to determine the location of file [%1$s]", file))); return tryGetCanonicalPathElseGetAbsolutePath(parent); }
java
public static String getLocation(File file) { Assert.notNull(file, "File cannot be null"); File parent = file.getParentFile(); Assert.notNull(parent, new IllegalArgumentException(String.format( "Unable to determine the location of file [%1$s]", file))); return tryGetCanonicalPathElseGetAbsolutePath(parent); }
[ "public", "static", "String", "getLocation", "(", "File", "file", ")", "{", "Assert", ".", "notNull", "(", "file", ",", "\"File cannot be null\"", ")", ";", "File", "parent", "=", "file", ".", "getParentFile", "(", ")", ";", "Assert", ".", "notNull", "(", ...
Returns the absolute path of the given file. @param file the {@link File} from which to get the absolute filesystem path. @return a String indicating the absolute filesystem pathname (location) of the given file. @throws java.lang.NullPointerException if the file reference is null. @see java.io.File#getParentFile() @see #tryGetCanonicalPathElseGetAbsolutePath(java.io.File)
[ "Returns", "the", "absolute", "path", "of", "the", "given", "file", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/io/FileUtils.java#L131-L137
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/io/FileUtils.java
FileUtils.tryGetCanonicalFileElseGetAbsoluteFile
public static File tryGetCanonicalFileElseGetAbsoluteFile(File file) { try { return file.getCanonicalFile(); } catch (IOException ignore) { return file.getAbsoluteFile(); } }
java
public static File tryGetCanonicalFileElseGetAbsoluteFile(File file) { try { return file.getCanonicalFile(); } catch (IOException ignore) { return file.getAbsoluteFile(); } }
[ "public", "static", "File", "tryGetCanonicalFileElseGetAbsoluteFile", "(", "File", "file", ")", "{", "try", "{", "return", "file", ".", "getCanonicalFile", "(", ")", ";", "}", "catch", "(", "IOException", "ignore", ")", "{", "return", "file", ".", "getAbsolute...
Attempts to the get the canonical form of the given file, otherwise returns the absolute form of the file. @param file the {@link File} from which the canonical or absolute file will be returned. @return the canonical form of the file unless an IOException occurs then return the absolute form of the file. @throws NullPointerException if the file reference is null. @see java.io.File#getAbsoluteFile() @see java.io.File#getCanonicalFile()
[ "Attempts", "to", "the", "get", "the", "canonical", "form", "of", "the", "given", "file", "otherwise", "returns", "the", "absolute", "form", "of", "the", "file", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/io/FileUtils.java#L270-L277
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/io/FileUtils.java
FileUtils.tryGetCanonicalPathElseGetAbsolutePath
public static String tryGetCanonicalPathElseGetAbsolutePath(File file) { try { return file.getCanonicalPath(); } catch (IOException ignore) { return file.getAbsolutePath(); } }
java
public static String tryGetCanonicalPathElseGetAbsolutePath(File file) { try { return file.getCanonicalPath(); } catch (IOException ignore) { return file.getAbsolutePath(); } }
[ "public", "static", "String", "tryGetCanonicalPathElseGetAbsolutePath", "(", "File", "file", ")", "{", "try", "{", "return", "file", ".", "getCanonicalPath", "(", ")", ";", "}", "catch", "(", "IOException", "ignore", ")", "{", "return", "file", ".", "getAbsolu...
Attempts to the get the canonical path of the given file, otherwise returns the absolute path of the file. @param file the {@link File} from which the canonical or absolute path will be returned. @return the canonical path of the file unless an IOException occurs then return the absolute path of the file. @see java.io.File#getAbsolutePath() @see java.io.File#getCanonicalPath()
[ "Attempts", "to", "the", "get", "the", "canonical", "path", "of", "the", "given", "file", "otherwise", "returns", "the", "absolute", "path", "of", "the", "file", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/io/FileUtils.java#L287-L294
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/br/br_currentconfig.java
br_currentconfig.get
public static br_currentconfig get(nitro_service client, br_currentconfig resource) throws Exception { resource.validate("get"); return ((br_currentconfig[]) resource.get_resources(client))[0]; }
java
public static br_currentconfig get(nitro_service client, br_currentconfig resource) throws Exception { resource.validate("get"); return ((br_currentconfig[]) resource.get_resources(client))[0]; }
[ "public", "static", "br_currentconfig", "get", "(", "nitro_service", "client", ",", "br_currentconfig", "resource", ")", "throws", "Exception", "{", "resource", ".", "validate", "(", "\"get\"", ")", ";", "return", "(", "(", "br_currentconfig", "[", "]", ")", "...
Use this operation to get current configuration from Repeater Instance.
[ "Use", "this", "operation", "to", "get", "current", "configuration", "from", "Repeater", "Instance", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/br/br_currentconfig.java#L94-L98
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/util/ListUtils.java
ListUtils.join
public static String join(Collection<? extends Object> lst, String separator) { StringBuilder buf = new StringBuilder(lst.size() * 64); boolean first = true; for (Object value : lst) { if (first) first = false; else buf.append(separator); buf.append(value.toString()); } return buf.toString(); }
java
public static String join(Collection<? extends Object> lst, String separator) { StringBuilder buf = new StringBuilder(lst.size() * 64); boolean first = true; for (Object value : lst) { if (first) first = false; else buf.append(separator); buf.append(value.toString()); } return buf.toString(); }
[ "public", "static", "String", "join", "(", "Collection", "<", "?", "extends", "Object", ">", "lst", ",", "String", "separator", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", "lst", ".", "size", "(", ")", "*", "64", ")", ";", "bool...
Concatenates a list of objects using the given separator. @param lst list of text strings @param separator separator @return string
[ "Concatenates", "a", "list", "of", "objects", "using", "the", "given", "separator", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/util/ListUtils.java#L56-L64
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/util/ListUtils.java
ListUtils.last
public static <T> T last(List<T> lst) { if (lst == null || lst.isEmpty()) return null; return lst.get(lst.size() - 1); }
java
public static <T> T last(List<T> lst) { if (lst == null || lst.isEmpty()) return null; return lst.get(lst.size() - 1); }
[ "public", "static", "<", "T", ">", "T", "last", "(", "List", "<", "T", ">", "lst", ")", "{", "if", "(", "lst", "==", "null", "||", "lst", ".", "isEmpty", "(", ")", ")", "return", "null", ";", "return", "lst", ".", "get", "(", "lst", ".", "siz...
Returns the last element of a list, or null if empty. @param lst the list @param <T> element type @return last element or null
[ "Returns", "the", "last", "element", "of", "a", "list", "or", "null", "if", "empty", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/util/ListUtils.java#L72-L75
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/util/ListUtils.java
ListUtils.map
@SuppressWarnings("unchecked") public static <From, To> List<To> map(List<From> list, MapClosure<From,To> f) { List<To> result = new ArrayList<To>(list.size()); for (From value : list) { result.add( f.eval(value) ); } return result; }
java
@SuppressWarnings("unchecked") public static <From, To> List<To> map(List<From> list, MapClosure<From,To> f) { List<To> result = new ArrayList<To>(list.size()); for (From value : list) { result.add( f.eval(value) ); } return result; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "From", ",", "To", ">", "List", "<", "To", ">", "map", "(", "List", "<", "From", ">", "list", ",", "MapClosure", "<", "From", ",", "To", ">", "f", ")", "{", "List", "<", ...
Applies a function to every item in a list. @param list the list with values @param f closure to apply @param <From> value type @param <To> destination type @return list of transformed values
[ "Applies", "a", "function", "to", "every", "item", "in", "a", "list", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/util/ListUtils.java#L85-L92
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/util/ListUtils.java
ListUtils.reduce
public static <Accumulator, Value> Accumulator reduce(List<Value> list, Accumulator init, ReduceClosure<Accumulator,Value> f) { Accumulator accumulator = init; for (Value value : list) { accumulator = f.eval(accumulator, value); } return accumulator; }
java
public static <Accumulator, Value> Accumulator reduce(List<Value> list, Accumulator init, ReduceClosure<Accumulator,Value> f) { Accumulator accumulator = init; for (Value value : list) { accumulator = f.eval(accumulator, value); } return accumulator; }
[ "public", "static", "<", "Accumulator", ",", "Value", ">", "Accumulator", "reduce", "(", "List", "<", "Value", ">", "list", ",", "Accumulator", "init", ",", "ReduceClosure", "<", "Accumulator", ",", "Value", ">", "f", ")", "{", "Accumulator", "accumulator", ...
Applies a binary function between each element of the given list. @param list list of elements @param init initial value for the accumulator @param f accumulator expression to apply @param <Accumulator> binary function @param <Value> element type @return an accumulated/aggregated value
[ "Applies", "a", "binary", "function", "between", "each", "element", "of", "the", "given", "list", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/util/ListUtils.java#L103-L109
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/util/ListUtils.java
ListUtils.median
@SuppressWarnings("unchecked") public static int median(List<Integer> values) { if (values == null || values.isEmpty()) return 0; values = new ArrayList<Integer>(values); Collections.sort(values); final int size = values.size(); final int sizeHalf = size / 2; if (size % 2 == 1) { //is odd? // 0 1 [2] 3 4: size/2 = 5/2 = 2.5 -> 2 return values.get(sizeHalf); } // 0 1 [2 3] 4 5: size/2 = 6/2 = 3 return (values.get(sizeHalf - 1) + values.get(sizeHalf)) / 2; }
java
@SuppressWarnings("unchecked") public static int median(List<Integer> values) { if (values == null || values.isEmpty()) return 0; values = new ArrayList<Integer>(values); Collections.sort(values); final int size = values.size(); final int sizeHalf = size / 2; if (size % 2 == 1) { //is odd? // 0 1 [2] 3 4: size/2 = 5/2 = 2.5 -> 2 return values.get(sizeHalf); } // 0 1 [2 3] 4 5: size/2 = 6/2 = 3 return (values.get(sizeHalf - 1) + values.get(sizeHalf)) / 2; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "int", "median", "(", "List", "<", "Integer", ">", "values", ")", "{", "if", "(", "values", "==", "null", "||", "values", ".", "isEmpty", "(", ")", ")", "return", "0", ";", "values...
Computes the median value of a list of integers. @param values list of values @return the computed medium
[ "Computes", "the", "median", "value", "of", "a", "list", "of", "integers", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/util/ListUtils.java#L130-L146
train
jsilland/piezo
src/main/java/io/soliton/protobuf/json/JsonRpcResponse.java
JsonRpcResponse.error
static JsonRpcResponse error(JsonRpcError error, JsonElement id) { return new JsonRpcResponse(id, error, null); }
java
static JsonRpcResponse error(JsonRpcError error, JsonElement id) { return new JsonRpcResponse(id, error, null); }
[ "static", "JsonRpcResponse", "error", "(", "JsonRpcError", "error", ",", "JsonElement", "id", ")", "{", "return", "new", "JsonRpcResponse", "(", "id", ",", "error", ",", "null", ")", ";", "}" ]
Builds a new response for an identifier request and containing an error. @param error the error to return to the user @param id the identifier of the request for which this response if generated
[ "Builds", "a", "new", "response", "for", "an", "identifier", "request", "and", "containing", "an", "error", "." ]
9a340f1460d25e07ec475dd24128b838667c959b
https://github.com/jsilland/piezo/blob/9a340f1460d25e07ec475dd24128b838667c959b/src/main/java/io/soliton/protobuf/json/JsonRpcResponse.java#L50-L52
train
jsilland/piezo
src/main/java/io/soliton/protobuf/json/JsonRpcResponse.java
JsonRpcResponse.success
public static JsonRpcResponse success(JsonObject payload, JsonElement id) { return new JsonRpcResponse(id, null, payload); }
java
public static JsonRpcResponse success(JsonObject payload, JsonElement id) { return new JsonRpcResponse(id, null, payload); }
[ "public", "static", "JsonRpcResponse", "success", "(", "JsonObject", "payload", ",", "JsonElement", "id", ")", "{", "return", "new", "JsonRpcResponse", "(", "id", ",", "null", ",", "payload", ")", ";", "}" ]
Builds a new, successful response. @param payload the object to return to the user. @param id the identifier of the request for which this response is generated
[ "Builds", "a", "new", "successful", "response", "." ]
9a340f1460d25e07ec475dd24128b838667c959b
https://github.com/jsilland/piezo/blob/9a340f1460d25e07ec475dd24128b838667c959b/src/main/java/io/soliton/protobuf/json/JsonRpcResponse.java#L61-L63
train
jsilland/piezo
src/main/java/io/soliton/protobuf/json/JsonRpcResponse.java
JsonRpcResponse.toJson
public JsonObject toJson() { JsonObject body = new JsonObject(); body.add(JsonRpcProtocol.ID, id()); if (isError()) { body.add(JsonRpcProtocol.ERROR, error().toJson()); } else { body.add(JsonRpcProtocol.RESULT, result()); } return body; }
java
public JsonObject toJson() { JsonObject body = new JsonObject(); body.add(JsonRpcProtocol.ID, id()); if (isError()) { body.add(JsonRpcProtocol.ERROR, error().toJson()); } else { body.add(JsonRpcProtocol.RESULT, result()); } return body; }
[ "public", "JsonObject", "toJson", "(", ")", "{", "JsonObject", "body", "=", "new", "JsonObject", "(", ")", ";", "body", ".", "add", "(", "JsonRpcProtocol", ".", "ID", ",", "id", "(", ")", ")", ";", "if", "(", "isError", "(", ")", ")", "{", "body", ...
Generates the JSON representation of this response.
[ "Generates", "the", "JSON", "representation", "of", "this", "response", "." ]
9a340f1460d25e07ec475dd24128b838667c959b
https://github.com/jsilland/piezo/blob/9a340f1460d25e07ec475dd24128b838667c959b/src/main/java/io/soliton/protobuf/json/JsonRpcResponse.java#L81-L91
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/mps/traceroute.java
traceroute.get
public static traceroute get(nitro_service client, traceroute resource) throws Exception { resource.validate("get"); return ((traceroute[]) resource.get_resources(client))[0]; }
java
public static traceroute get(nitro_service client, traceroute resource) throws Exception { resource.validate("get"); return ((traceroute[]) resource.get_resources(client))[0]; }
[ "public", "static", "traceroute", "get", "(", "nitro_service", "client", ",", "traceroute", "resource", ")", "throws", "Exception", "{", "resource", ".", "validate", "(", "\"get\"", ")", ";", "return", "(", "(", "traceroute", "[", "]", ")", "resource", ".", ...
Use this operation to get the status of traceroute on a given device.
[ "Use", "this", "operation", "to", "get", "the", "status", "of", "traceroute", "on", "a", "given", "device", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/traceroute.java#L95-L99
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/mps/traceroute.java
traceroute.get_filtered
public static traceroute[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { traceroute obj = new traceroute(); options option = new options(); option.set_filter(filter); traceroute[] response = (traceroute[]) obj.getfiltered(service, option); return response; }
java
public static traceroute[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { traceroute obj = new traceroute(); options option = new options(); option.set_filter(filter); traceroute[] response = (traceroute[]) obj.getfiltered(service, option); return response; }
[ "public", "static", "traceroute", "[", "]", "get_filtered", "(", "nitro_service", "service", ",", "filtervalue", "[", "]", "filter", ")", "throws", "Exception", "{", "traceroute", "obj", "=", "new", "traceroute", "(", ")", ";", "options", "option", "=", "new...
Use this API to fetch filtered set of traceroute resources. set the filter parameter values in filtervalue object.
[ "Use", "this", "API", "to", "fetch", "filtered", "set", "of", "traceroute", "resources", ".", "set", "the", "filter", "parameter", "values", "in", "filtervalue", "object", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/traceroute.java#L118-L125
train
dejv78/javafx-commons
jfx-input/src/main/java/dejv/commons/jfx/input/properties/MouseEventProperties.java
MouseEventProperties.isMatching
public boolean isMatching(MouseEvent event) { return (event != null) && !event.isConsumed() && (mouseModifiers.isNone() || ((event.isPrimaryButtonDown() == mouseButtons.isPrimary()) && (event.isMiddleButtonDown() == mouseButtons.isMiddle()) && (event.isSecondaryButtonDown() == mouseButtons.isSecondary()) && (event.isAltDown() == mouseModifiers.isAlt()) && (event.isShiftDown() == mouseModifiers.isShift()) && (event.isControlDown() == mouseModifiers.isControl()) && (event.isMetaDown() == mouseModifiers.isMeta()))); }
java
public boolean isMatching(MouseEvent event) { return (event != null) && !event.isConsumed() && (mouseModifiers.isNone() || ((event.isPrimaryButtonDown() == mouseButtons.isPrimary()) && (event.isMiddleButtonDown() == mouseButtons.isMiddle()) && (event.isSecondaryButtonDown() == mouseButtons.isSecondary()) && (event.isAltDown() == mouseModifiers.isAlt()) && (event.isShiftDown() == mouseModifiers.isShift()) && (event.isControlDown() == mouseModifiers.isControl()) && (event.isMetaDown() == mouseModifiers.isMeta()))); }
[ "public", "boolean", "isMatching", "(", "MouseEvent", "event", ")", "{", "return", "(", "event", "!=", "null", ")", "&&", "!", "event", ".", "isConsumed", "(", ")", "&&", "(", "mouseModifiers", ".", "isNone", "(", ")", "||", "(", "(", "event", ".", "...
Check, whether the given MouseEvent is matching the current properties. @param event MouseEvent to test. @return True, if no modifiers are set, or the event matches exactly the properties. False, if some modifiers are set, and the event doesn't match them, or if the event is null, or already consumed.
[ "Check", "whether", "the", "given", "MouseEvent", "is", "matching", "the", "current", "properties", "." ]
ea846eeeb4ed43a7628a40931a3e6f27d513592f
https://github.com/dejv78/javafx-commons/blob/ea846eeeb4ed43a7628a40931a3e6f27d513592f/jfx-input/src/main/java/dejv/commons/jfx/input/properties/MouseEventProperties.java#L70-L80
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.configure
private WebTarget configure(String token, boolean debug, Logger log, int maxLog) { Client client = ClientBuilder.newBuilder() .register(MultiPartFeature.class) .register(JsonProcessingFeature.class) .build(); client.register(HttpAuthenticationFeature.basic(token, "")); if (debug) client.register(new LoggingFilter(log, maxLog)); return client.target(baseUri); }
java
private WebTarget configure(String token, boolean debug, Logger log, int maxLog) { Client client = ClientBuilder.newBuilder() .register(MultiPartFeature.class) .register(JsonProcessingFeature.class) .build(); client.register(HttpAuthenticationFeature.basic(token, "")); if (debug) client.register(new LoggingFilter(log, maxLog)); return client.target(baseUri); }
[ "private", "WebTarget", "configure", "(", "String", "token", ",", "boolean", "debug", ",", "Logger", "log", ",", "int", "maxLog", ")", "{", "Client", "client", "=", "ClientBuilder", ".", "newBuilder", "(", ")", ".", "register", "(", "MultiPartFeature", ".", ...
Configures this client, by settings HTTP AUTH filter, the REST URL and logging. @param token its API Token @param debug true for Jersey REQ/RES logging @param log debug log stream (if debug==true) @param maxLog max size of logged entity (if debug==true) @return configured REST URL target
[ "Configures", "this", "client", "by", "settings", "HTTP", "AUTH", "filter", "the", "REST", "URL", "and", "logging", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L187-L197
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.invoke
protected <JsonType extends JsonStructure, ValueType> ValueType invoke(String operation, String id, String action, QueryClosure queryClosure, RequestClosure<JsonType> requestClosure, ResponseClosure<JsonType, ValueType> responseClosure) { try { WebTarget ws = wsBase.path(operation); if (id != null) ws = ws.path(id); if (action != null) ws = ws.path(action); if (queryClosure != null) ws = queryClosure.modify(ws); Invocation.Builder request = ws.request(MediaType.APPLICATION_JSON_TYPE); request.header(AGENT_REQHDR, getAgentRequestHeaderValue()); JsonType json = requestClosure.call(request); return (responseClosure != null) ? responseClosure.call(json) : null; } catch (WebApplicationException e) { Response.StatusType status = e.getResponse().getStatusInfo(); switch (status.getStatusCode()) { case 400: throw new BadRequestException(operation, id, action, e); case 401: throw new MissingApiTokenException(status.getReasonPhrase()); case 403: throw new UnauthorizedException(operation, id, action); case 404: throw new NotFoundException(operation, id); case 409: throw new ConflictException(operation, id, action, e); case 422: throw new CoercionException(operation, id, action, e); case 427: throw new RateLimitedException(operation, id, action); case 429: throw new ResponseParseException(operation, id, action, e); case 500: { String message = ""; Response response = e.getResponse(); String contentType = response.getHeaderString("Content-Type"); if (contentType.equals("application/json")) { InputStream is = (InputStream) response.getEntity(); JsonObject errJson = Json.createReader(is).readObject(); message = errJson.getString("message"); } else if (contentType.startsWith("text/html")) { InputStream is = (InputStream) response.getEntity(); message = StringUtils.toString(is); } throw new ServerException(status.getReasonPhrase() + ": " + message); } default: throw new ApiException(e); } } catch (ApiException e) { throw e; } catch (Exception e) { throw new ApiException(e); } }
java
protected <JsonType extends JsonStructure, ValueType> ValueType invoke(String operation, String id, String action, QueryClosure queryClosure, RequestClosure<JsonType> requestClosure, ResponseClosure<JsonType, ValueType> responseClosure) { try { WebTarget ws = wsBase.path(operation); if (id != null) ws = ws.path(id); if (action != null) ws = ws.path(action); if (queryClosure != null) ws = queryClosure.modify(ws); Invocation.Builder request = ws.request(MediaType.APPLICATION_JSON_TYPE); request.header(AGENT_REQHDR, getAgentRequestHeaderValue()); JsonType json = requestClosure.call(request); return (responseClosure != null) ? responseClosure.call(json) : null; } catch (WebApplicationException e) { Response.StatusType status = e.getResponse().getStatusInfo(); switch (status.getStatusCode()) { case 400: throw new BadRequestException(operation, id, action, e); case 401: throw new MissingApiTokenException(status.getReasonPhrase()); case 403: throw new UnauthorizedException(operation, id, action); case 404: throw new NotFoundException(operation, id); case 409: throw new ConflictException(operation, id, action, e); case 422: throw new CoercionException(operation, id, action, e); case 427: throw new RateLimitedException(operation, id, action); case 429: throw new ResponseParseException(operation, id, action, e); case 500: { String message = ""; Response response = e.getResponse(); String contentType = response.getHeaderString("Content-Type"); if (contentType.equals("application/json")) { InputStream is = (InputStream) response.getEntity(); JsonObject errJson = Json.createReader(is).readObject(); message = errJson.getString("message"); } else if (contentType.startsWith("text/html")) { InputStream is = (InputStream) response.getEntity(); message = StringUtils.toString(is); } throw new ServerException(status.getReasonPhrase() + ": " + message); } default: throw new ApiException(e); } } catch (ApiException e) { throw e; } catch (Exception e) { throw new ApiException(e); } }
[ "protected", "<", "JsonType", "extends", "JsonStructure", ",", "ValueType", ">", "ValueType", "invoke", "(", "String", "operation", ",", "String", "id", ",", "String", "action", ",", "QueryClosure", "queryClosure", ",", "RequestClosure", "<", "JsonType", ">", "r...
Performs a REST API invocation. @param operation operation name, such as <code>tests</code>, <code>data-stores</code>, etc @param id resource ID (if fetching a specific resource) @param action optional action, such as <code>clone</code>, <code>abort</code>, etc @param queryClosure optional closure to modify the web-target before requests processing @param requestClosure closure to create the request, such as GET, POST, PUT, DELETE @param responseClosure closure to convert the response JSON into a value-object @param <JsonType> JSON type, such as JsonObject, JsonArray @param <ValueType> value-type, such as {@link com.loadimpact.resource.Test}, {@link com.loadimpact.resource.UserScenario}, etc @return a single value-object or a list of it @throws com.loadimpact.exception.ApiException if anything goes wrong, such as the server returns HTTP status not being 20x
[ "Performs", "a", "REST", "API", "invocation", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L424-L479
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.checkApiToken
protected void checkApiToken(String apiToken) { if (StringUtils.isBlank(apiToken)) throw new MissingApiTokenException("Empty key"); if (apiToken.length() != TOKEN_LENGTH) throw new MissingApiTokenException("Wrong length"); if (!apiToken.matches(HEX_PATTERN)) throw new MissingApiTokenException("Not a HEX value"); }
java
protected void checkApiToken(String apiToken) { if (StringUtils.isBlank(apiToken)) throw new MissingApiTokenException("Empty key"); if (apiToken.length() != TOKEN_LENGTH) throw new MissingApiTokenException("Wrong length"); if (!apiToken.matches(HEX_PATTERN)) throw new MissingApiTokenException("Not a HEX value"); }
[ "protected", "void", "checkApiToken", "(", "String", "apiToken", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "apiToken", ")", ")", "throw", "new", "MissingApiTokenException", "(", "\"Empty key\"", ")", ";", "if", "(", "apiToken", ".", "length", ...
Syntax checks the API Token. @param apiToken value to check @throws IllegalArgumentException if invalid
[ "Syntax", "checks", "the", "API", "Token", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L487-L491
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.isValidToken
public boolean isValidToken() { try { // Response response = wsBase.path(TEST_CONFIGS).request(MediaType.APPLICATION_JSON_TYPE).get(); // return response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL; LoadZone zone = getLoadZone(LoadZone.AMAZON_US_ASHBURN.uid); return zone == LoadZone.AMAZON_US_ASHBURN; } catch (Exception e) { log.info("API token validation failed: " + e); } return false; }
java
public boolean isValidToken() { try { // Response response = wsBase.path(TEST_CONFIGS).request(MediaType.APPLICATION_JSON_TYPE).get(); // return response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL; LoadZone zone = getLoadZone(LoadZone.AMAZON_US_ASHBURN.uid); return zone == LoadZone.AMAZON_US_ASHBURN; } catch (Exception e) { log.info("API token validation failed: " + e); } return false; }
[ "public", "boolean", "isValidToken", "(", ")", "{", "try", "{", "// Response response = wsBase.path(TEST_CONFIGS).request(MediaType.APPLICATION_JSON_TYPE).get();", "// return response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL;", "LoadZone", "zone", ...
Returns true if we can successfully logon and fetch some data. @return true if can logon
[ "Returns", "true", "if", "we", "can", "successfully", "logon", "and", "fetch", "some", "data", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L498-L509
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.getLoadZone
public LoadZone getLoadZone(String id) { return invoke(LOAD_ZONES, id, null, null, new RequestClosure<JsonArray>() { @Override public JsonArray call(Invocation.Builder request) { return request.get(JsonArray.class); } }, new ResponseClosure<JsonArray, LoadZone>() { @Override public LoadZone call(JsonArray json) { return LoadZone.valueOf(json.getJsonObject(0)); } } ); }
java
public LoadZone getLoadZone(String id) { return invoke(LOAD_ZONES, id, null, null, new RequestClosure<JsonArray>() { @Override public JsonArray call(Invocation.Builder request) { return request.get(JsonArray.class); } }, new ResponseClosure<JsonArray, LoadZone>() { @Override public LoadZone call(JsonArray json) { return LoadZone.valueOf(json.getJsonObject(0)); } } ); }
[ "public", "LoadZone", "getLoadZone", "(", "String", "id", ")", "{", "return", "invoke", "(", "LOAD_ZONES", ",", "id", ",", "null", ",", "null", ",", "new", "RequestClosure", "<", "JsonArray", ">", "(", ")", "{", "@", "Override", "public", "JsonArray", "c...
Retrieves a load-zone. @param id its id @return {@link com.loadimpact.resource.LoadZone}
[ "Retrieves", "a", "load", "-", "zone", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L664-L679
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.getLoadZone
public List<LoadZone> getLoadZone() { return invoke(LOAD_ZONES, new RequestClosure<JsonArray>() { @Override public JsonArray call(Invocation.Builder request) { return request.get(JsonArray.class); } }, new ResponseClosure<JsonArray, List<LoadZone>>() { @Override public List<LoadZone> call(JsonArray json) { List<LoadZone> zones = new ArrayList<LoadZone>(json.size()); for (int k = 0; k < json.size(); ++k) { zones.add(LoadZone.valueOf(json.getJsonObject(k))); } return zones; } } ); }
java
public List<LoadZone> getLoadZone() { return invoke(LOAD_ZONES, new RequestClosure<JsonArray>() { @Override public JsonArray call(Invocation.Builder request) { return request.get(JsonArray.class); } }, new ResponseClosure<JsonArray, List<LoadZone>>() { @Override public List<LoadZone> call(JsonArray json) { List<LoadZone> zones = new ArrayList<LoadZone>(json.size()); for (int k = 0; k < json.size(); ++k) { zones.add(LoadZone.valueOf(json.getJsonObject(k))); } return zones; } } ); }
[ "public", "List", "<", "LoadZone", ">", "getLoadZone", "(", ")", "{", "return", "invoke", "(", "LOAD_ZONES", ",", "new", "RequestClosure", "<", "JsonArray", ">", "(", ")", "{", "@", "Override", "public", "JsonArray", "call", "(", "Invocation", ".", "Builde...
Retrieves all load-zones. @return list of {@link com.loadimpact.resource.LoadZone}
[ "Retrieves", "all", "load", "-", "zones", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L686-L705
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.getDataStore
public DataStore getDataStore(int id) { return invoke(DATA_STORES, id, new RequestClosure<JsonObject>() { @Override public JsonObject call(Invocation.Builder request) { return request.get(JsonObject.class); } }, new ResponseClosure<JsonObject, DataStore>() { @Override public DataStore call(JsonObject json) { return new DataStore(json); } } ); }
java
public DataStore getDataStore(int id) { return invoke(DATA_STORES, id, new RequestClosure<JsonObject>() { @Override public JsonObject call(Invocation.Builder request) { return request.get(JsonObject.class); } }, new ResponseClosure<JsonObject, DataStore>() { @Override public DataStore call(JsonObject json) { return new DataStore(json); } } ); }
[ "public", "DataStore", "getDataStore", "(", "int", "id", ")", "{", "return", "invoke", "(", "DATA_STORES", ",", "id", ",", "new", "RequestClosure", "<", "JsonObject", ">", "(", ")", "{", "@", "Override", "public", "JsonObject", "call", "(", "Invocation", "...
Retrieves a data store. @param id ist id @return {@link com.loadimpact.resource.DataStore}
[ "Retrieves", "a", "data", "store", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L713-L728
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.getDataStores
public List<DataStore> getDataStores() { return invoke(DATA_STORES, new RequestClosure<JsonArray>() { @Override public JsonArray call(Invocation.Builder request) { return request.get(JsonArray.class); } }, new ResponseClosure<JsonArray, List<DataStore>>() { @Override public List<DataStore> call(JsonArray json) { List<DataStore> ds = new ArrayList<DataStore>(json.size()); for (int k = 0; k < json.size(); ++k) { ds.add(new DataStore(json.getJsonObject(k))); } return ds; } } ); }
java
public List<DataStore> getDataStores() { return invoke(DATA_STORES, new RequestClosure<JsonArray>() { @Override public JsonArray call(Invocation.Builder request) { return request.get(JsonArray.class); } }, new ResponseClosure<JsonArray, List<DataStore>>() { @Override public List<DataStore> call(JsonArray json) { List<DataStore> ds = new ArrayList<DataStore>(json.size()); for (int k = 0; k < json.size(); ++k) { ds.add(new DataStore(json.getJsonObject(k))); } return ds; } } ); }
[ "public", "List", "<", "DataStore", ">", "getDataStores", "(", ")", "{", "return", "invoke", "(", "DATA_STORES", ",", "new", "RequestClosure", "<", "JsonArray", ">", "(", ")", "{", "@", "Override", "public", "JsonArray", "call", "(", "Invocation", ".", "Bu...
Retrieves all data stores. @return list of {@link com.loadimpact.resource.DataStore}
[ "Retrieves", "all", "data", "stores", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L735-L754
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.deleteDataStore
public void deleteDataStore(final int id) { invoke(DATA_STORES, id, new RequestClosure<JsonStructure>() { @Override public JsonStructure call(Invocation.Builder request) { Response response = request.delete(); if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) { throw new ResponseParseException(DATA_STORES, id, null, null); } return null; } }, null ); }
java
public void deleteDataStore(final int id) { invoke(DATA_STORES, id, new RequestClosure<JsonStructure>() { @Override public JsonStructure call(Invocation.Builder request) { Response response = request.delete(); if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) { throw new ResponseParseException(DATA_STORES, id, null, null); } return null; } }, null ); }
[ "public", "void", "deleteDataStore", "(", "final", "int", "id", ")", "{", "invoke", "(", "DATA_STORES", ",", "id", ",", "new", "RequestClosure", "<", "JsonStructure", ">", "(", ")", "{", "@", "Override", "public", "JsonStructure", "call", "(", "Invocation", ...
Deletes a data store. @param id its id @throws com.loadimpact.exception.ResponseParseException if it was unsuccessful
[ "Deletes", "a", "data", "store", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L762-L776
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.createDataStore
public DataStore createDataStore(final File file, final String name, final int fromline, final DataStore.Separator separator, final DataStore.StringDelimiter delimiter) { return invoke(DATA_STORES, new RequestClosure<JsonObject>() { @Override public JsonObject call(Invocation.Builder request) { MultiPart form = new FormDataMultiPart() .field("name", name) .field("fromline", Integer.toString(fromline)) .field("separator", separator.param()) .field("delimiter", delimiter.param()) .bodyPart(new FileDataBodyPart("file", file, new MediaType("text", "csv"))); return request.post(Entity.entity(form, form.getMediaType()), JsonObject.class); } }, new ResponseClosure<JsonObject, DataStore>() { @Override public DataStore call(JsonObject json) { return new DataStore(json); } } ); }
java
public DataStore createDataStore(final File file, final String name, final int fromline, final DataStore.Separator separator, final DataStore.StringDelimiter delimiter) { return invoke(DATA_STORES, new RequestClosure<JsonObject>() { @Override public JsonObject call(Invocation.Builder request) { MultiPart form = new FormDataMultiPart() .field("name", name) .field("fromline", Integer.toString(fromline)) .field("separator", separator.param()) .field("delimiter", delimiter.param()) .bodyPart(new FileDataBodyPart("file", file, new MediaType("text", "csv"))); return request.post(Entity.entity(form, form.getMediaType()), JsonObject.class); } }, new ResponseClosure<JsonObject, DataStore>() { @Override public DataStore call(JsonObject json) { return new DataStore(json); } } ); }
[ "public", "DataStore", "createDataStore", "(", "final", "File", "file", ",", "final", "String", "name", ",", "final", "int", "fromline", ",", "final", "DataStore", ".", "Separator", "separator", ",", "final", "DataStore", ".", "StringDelimiter", "delimiter", ")"...
Creates a new data store. @param file CSV file that should be uploaded (N.B. max 50MB) @param name name to use in the Load Impact web-console @param fromline Payload from this line (1st line is 1). Set to value 2, if the CSV file starts with a headings line @param separator field separator, one of {@link com.loadimpact.resource.DataStore.Separator} @param delimiter surround delimiter for text-strings, one of {@link com.loadimpact.resource.DataStore.StringDelimiter} @return {@link com.loadimpact.resource.DataStore}
[ "Creates", "a", "new", "data", "store", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L788-L810
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.getUserScenario
public UserScenario getUserScenario(int id) { return invoke(USER_SCENARIOS, id, new RequestClosure<JsonObject>() { @Override public JsonObject call(Invocation.Builder request) { return request.get(JsonObject.class); } }, new ResponseClosure<JsonObject, UserScenario>() { @Override public UserScenario call(JsonObject json) { return new UserScenario(json); } } ); }
java
public UserScenario getUserScenario(int id) { return invoke(USER_SCENARIOS, id, new RequestClosure<JsonObject>() { @Override public JsonObject call(Invocation.Builder request) { return request.get(JsonObject.class); } }, new ResponseClosure<JsonObject, UserScenario>() { @Override public UserScenario call(JsonObject json) { return new UserScenario(json); } } ); }
[ "public", "UserScenario", "getUserScenario", "(", "int", "id", ")", "{", "return", "invoke", "(", "USER_SCENARIOS", ",", "id", ",", "new", "RequestClosure", "<", "JsonObject", ">", "(", ")", "{", "@", "Override", "public", "JsonObject", "call", "(", "Invocat...
Retrieves a user scenario. @param id its id @return {@link com.loadimpact.resource.UserScenario}
[ "Retrieves", "a", "user", "scenario", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L818-L833
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.getUserScenarios
public List<UserScenario> getUserScenarios() { return invoke(USER_SCENARIOS, new RequestClosure<JsonArray>() { @Override public JsonArray call(Invocation.Builder request) { return request.get(JsonArray.class); } }, new ResponseClosure<JsonArray, List<UserScenario>>() { @Override public List<UserScenario> call(JsonArray json) { List<UserScenario> ds = new ArrayList<UserScenario>(json.size()); for (int k = 0; k < json.size(); ++k) { ds.add(new UserScenario(json.getJsonObject(k))); } return ds; } } ); }
java
public List<UserScenario> getUserScenarios() { return invoke(USER_SCENARIOS, new RequestClosure<JsonArray>() { @Override public JsonArray call(Invocation.Builder request) { return request.get(JsonArray.class); } }, new ResponseClosure<JsonArray, List<UserScenario>>() { @Override public List<UserScenario> call(JsonArray json) { List<UserScenario> ds = new ArrayList<UserScenario>(json.size()); for (int k = 0; k < json.size(); ++k) { ds.add(new UserScenario(json.getJsonObject(k))); } return ds; } } ); }
[ "public", "List", "<", "UserScenario", ">", "getUserScenarios", "(", ")", "{", "return", "invoke", "(", "USER_SCENARIOS", ",", "new", "RequestClosure", "<", "JsonArray", ">", "(", ")", "{", "@", "Override", "public", "JsonArray", "call", "(", "Invocation", "...
Retrieves all user scenarios. @return list of {@link com.loadimpact.resource.UserScenario}
[ "Retrieves", "all", "user", "scenarios", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L840-L859
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.createUserScenario
public UserScenario createUserScenario(final UserScenario scenario) { return invoke(USER_SCENARIOS, new RequestClosure<JsonObject>() { @Override public JsonObject call(Invocation.Builder request) { String json = scenario.toJSON().toString(); Entity<String> data = Entity.entity(json, MediaType.APPLICATION_JSON_TYPE); return request.post(data, JsonObject.class); } }, new ResponseClosure<JsonObject, UserScenario>() { @Override public UserScenario call(JsonObject json) { return new UserScenario(json); } } ); }
java
public UserScenario createUserScenario(final UserScenario scenario) { return invoke(USER_SCENARIOS, new RequestClosure<JsonObject>() { @Override public JsonObject call(Invocation.Builder request) { String json = scenario.toJSON().toString(); Entity<String> data = Entity.entity(json, MediaType.APPLICATION_JSON_TYPE); return request.post(data, JsonObject.class); } }, new ResponseClosure<JsonObject, UserScenario>() { @Override public UserScenario call(JsonObject json) { return new UserScenario(json); } } ); }
[ "public", "UserScenario", "createUserScenario", "(", "final", "UserScenario", "scenario", ")", "{", "return", "invoke", "(", "USER_SCENARIOS", ",", "new", "RequestClosure", "<", "JsonObject", ">", "(", ")", "{", "@", "Override", "public", "JsonObject", "call", "...
Creates a new user scenario. @param scenario scenario configuration (no ID) @return server stored {@link com.loadimpact.resource.UserScenario}
[ "Creates", "a", "new", "user", "scenario", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L940-L957
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/ApiTokenClient.java
ApiTokenClient.getUserScenarioValidation
public UserScenarioValidation getUserScenarioValidation(int id) { return invoke(USER_SCENARIO_VALIDATIONS, id, new RequestClosure<JsonObject>() { @Override public JsonObject call(Invocation.Builder request) { return request.get(JsonObject.class); } }, new ResponseClosure<JsonObject, UserScenarioValidation>() { @Override public UserScenarioValidation call(JsonObject json) { return new UserScenarioValidation(json); } } ); }
java
public UserScenarioValidation getUserScenarioValidation(int id) { return invoke(USER_SCENARIO_VALIDATIONS, id, new RequestClosure<JsonObject>() { @Override public JsonObject call(Invocation.Builder request) { return request.get(JsonObject.class); } }, new ResponseClosure<JsonObject, UserScenarioValidation>() { @Override public UserScenarioValidation call(JsonObject json) { return new UserScenarioValidation(json); } } ); }
[ "public", "UserScenarioValidation", "getUserScenarioValidation", "(", "int", "id", ")", "{", "return", "invoke", "(", "USER_SCENARIO_VALIDATIONS", ",", "id", ",", "new", "RequestClosure", "<", "JsonObject", ">", "(", ")", "{", "@", "Override", "public", "JsonObjec...
Retrieves a user scenario validation. @param id its id @return {@link com.loadimpact.resource.UserScenarioValidation}
[ "Retrieves", "a", "user", "scenario", "validation", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/ApiTokenClient.java#L990-L1005
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/support/AuditableSupport.java
AuditableSupport.setModifiedBy
@Override @SuppressWarnings("unchecked") public void setModifiedBy(USER modifiedBy) { this.modifiedBy = assertNotNull(modifiedBy, () -> "Modified by is required"); this.lastModifiedBy = defaultIfNull(this.lastModifiedBy, this.modifiedBy); }
java
@Override @SuppressWarnings("unchecked") public void setModifiedBy(USER modifiedBy) { this.modifiedBy = assertNotNull(modifiedBy, () -> "Modified by is required"); this.lastModifiedBy = defaultIfNull(this.lastModifiedBy, this.modifiedBy); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "setModifiedBy", "(", "USER", "modifiedBy", ")", "{", "this", ".", "modifiedBy", "=", "assertNotNull", "(", "modifiedBy", ",", "(", ")", "->", "\"Modified by is required\"", "...
Sets the user responsible for modifying this object. @param modifiedBy object representing the user responsible for modifying this object.
[ "Sets", "the", "user", "responsible", "for", "modifying", "this", "object", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/support/AuditableSupport.java#L175-L180
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/br/br.java
br.reboot
public static br reboot(nitro_service client, br resource) throws Exception { return ((br[]) resource.perform_operation(client, "reboot"))[0]; }
java
public static br reboot(nitro_service client, br resource) throws Exception { return ((br[]) resource.perform_operation(client, "reboot"))[0]; }
[ "public", "static", "br", "reboot", "(", "nitro_service", "client", ",", "br", "resource", ")", "throws", "Exception", "{", "return", "(", "(", "br", "[", "]", ")", "resource", ".", "perform_operation", "(", "client", ",", "\"reboot\"", ")", ")", "[", "0...
Use this operation to reboot Repeater Instance.
[ "Use", "this", "operation", "to", "reboot", "Repeater", "Instance", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/br/br.java#L512-L515
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/br/br.java
br.stop
public static br stop(nitro_service client, br resource) throws Exception { return ((br[]) resource.perform_operation(client, "stop"))[0]; }
java
public static br stop(nitro_service client, br resource) throws Exception { return ((br[]) resource.perform_operation(client, "stop"))[0]; }
[ "public", "static", "br", "stop", "(", "nitro_service", "client", ",", "br", "resource", ")", "throws", "Exception", "{", "return", "(", "(", "br", "[", "]", ")", "resource", ".", "perform_operation", "(", "client", ",", "\"stop\"", ")", ")", "[", "0", ...
Use this operation to stop Repeater Instance.
[ "Use", "this", "operation", "to", "stop", "Repeater", "Instance", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/br/br.java#L543-L546
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/br/br.java
br.force_reboot
public static br force_reboot(nitro_service client, br resource) throws Exception { return ((br[]) resource.perform_operation(client, "force_reboot"))[0]; }
java
public static br force_reboot(nitro_service client, br resource) throws Exception { return ((br[]) resource.perform_operation(client, "force_reboot"))[0]; }
[ "public", "static", "br", "force_reboot", "(", "nitro_service", "client", ",", "br", "resource", ")", "throws", "Exception", "{", "return", "(", "(", "br", "[", "]", ")", "resource", ".", "perform_operation", "(", "client", ",", "\"force_reboot\"", ")", ")",...
Use this operation to force reboot Repeater Instance.
[ "Use", "this", "operation", "to", "force", "reboot", "Repeater", "Instance", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/br/br.java#L606-L609
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/br/br.java
br.force_stop
public static br force_stop(nitro_service client, br resource) throws Exception { return ((br[]) resource.perform_operation(client, "force_stop"))[0]; }
java
public static br force_stop(nitro_service client, br resource) throws Exception { return ((br[]) resource.perform_operation(client, "force_stop"))[0]; }
[ "public", "static", "br", "force_stop", "(", "nitro_service", "client", ",", "br", "resource", ")", "throws", "Exception", "{", "return", "(", "(", "br", "[", "]", ")", "resource", ".", "perform_operation", "(", "client", ",", "\"force_stop\"", ")", ")", "...
Use this operation to force stop Repeater Instance.
[ "Use", "this", "operation", "to", "force", "stop", "Repeater", "Instance", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/br/br.java#L728-L731
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/br/br.java
br.start
public static br start(nitro_service client, br resource) throws Exception { return ((br[]) resource.perform_operation(client, "start"))[0]; }
java
public static br start(nitro_service client, br resource) throws Exception { return ((br[]) resource.perform_operation(client, "start"))[0]; }
[ "public", "static", "br", "start", "(", "nitro_service", "client", ",", "br", "resource", ")", "throws", "Exception", "{", "return", "(", "(", "br", "[", "]", ")", "resource", ".", "perform_operation", "(", "client", ",", "\"start\"", ")", ")", "[", "0",...
Use this operation to start Repeater Instance.
[ "Use", "this", "operation", "to", "start", "Repeater", "Instance", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/br/br.java#L759-L762
train
dejv78/javafx-commons
jfx-input/src/main/java/dejv/commons/jfx/input/properties/GestureEventProperties.java
GestureEventProperties.isMatching
public boolean isMatching(GestureEvent event) { return (event != null) && !event.isConsumed() && (gestureModifiers.isNone() || ((event.isAltDown() == gestureModifiers.isAlt()) && (event.isShiftDown() == gestureModifiers.isShift()) && (event.isControlDown() == gestureModifiers.isControl()) && (event.isMetaDown() == gestureModifiers.isMeta()) && (event.isShortcutDown() == gestureModifiers.isShortcut()))); }
java
public boolean isMatching(GestureEvent event) { return (event != null) && !event.isConsumed() && (gestureModifiers.isNone() || ((event.isAltDown() == gestureModifiers.isAlt()) && (event.isShiftDown() == gestureModifiers.isShift()) && (event.isControlDown() == gestureModifiers.isControl()) && (event.isMetaDown() == gestureModifiers.isMeta()) && (event.isShortcutDown() == gestureModifiers.isShortcut()))); }
[ "public", "boolean", "isMatching", "(", "GestureEvent", "event", ")", "{", "return", "(", "event", "!=", "null", ")", "&&", "!", "event", ".", "isConsumed", "(", ")", "&&", "(", "gestureModifiers", ".", "isNone", "(", ")", "||", "(", "(", "event", ".",...
Check, whether the given GestureEvent is matching the current properties. @param event GestureEvent to test. @return True, if no modifiers are set, or the event matches exactly the properties. False, if some modifiers are set, and the event doesn't match them, or if the event is null.
[ "Check", "whether", "the", "given", "GestureEvent", "is", "matching", "the", "current", "properties", "." ]
ea846eeeb4ed43a7628a40931a3e6f27d513592f
https://github.com/dejv78/javafx-commons/blob/ea846eeeb4ed43a7628a40931a3e6f27d513592f/jfx-input/src/main/java/dejv/commons/jfx/input/properties/GestureEventProperties.java#L50-L58
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/mps/prune_policy.java
prune_policy.get
public static prune_policy get(nitro_service client, prune_policy resource) throws Exception { resource.validate("get"); return ((prune_policy[]) resource.get_resources(client))[0]; }
java
public static prune_policy get(nitro_service client, prune_policy resource) throws Exception { resource.validate("get"); return ((prune_policy[]) resource.get_resources(client))[0]; }
[ "public", "static", "prune_policy", "get", "(", "nitro_service", "client", ",", "prune_policy", "resource", ")", "throws", "Exception", "{", "resource", ".", "validate", "(", "\"get\"", ")", ";", "return", "(", "(", "prune_policy", "[", "]", ")", "resource", ...
Use this operation to get the prune policy to view number of days data to retain.
[ "Use", "this", "operation", "to", "get", "the", "prune", "policy", "to", "view", "number", "of", "days", "data", "to", "retain", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/prune_policy.java#L104-L108
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/search/support/BinarySearch.java
BinarySearch.search
@Override @SuppressWarnings("unchecked") public <E> E search(final Collection<E> collection) { Assert.isInstanceOf(collection, List.class, "The collection {0} must be an instance of java.util.List!", ClassUtils.getClassName(collection)); return doSearch((List<E>) collection); }
java
@Override @SuppressWarnings("unchecked") public <E> E search(final Collection<E> collection) { Assert.isInstanceOf(collection, List.class, "The collection {0} must be an instance of java.util.List!", ClassUtils.getClassName(collection)); return doSearch((List<E>) collection); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "E", ">", "E", "search", "(", "final", "Collection", "<", "E", ">", "collection", ")", "{", "Assert", ".", "isInstanceOf", "(", "collection", ",", "List", ".", "class", "...
Searches the Collection of elements in order to find the element or elements matching the criteria defined by the Matcher. The search operation expects the collection of elements to an instance of java.util.List, an ordered collection of elements that are sorted according the natural ordering of the element's Comparable Class type. @param <E> the Class type of elements in the Collection. @param collection the Collection of elements to search. @return the element in the Collection matching the search criteria defined by the Matcher. @throws IllegalArgumentException if the collection of elements is not an instance of java.util.List. @see #getMatcher() @see #search(Object[]) @see #doSearch(java.util.List) @see java.util.List
[ "Searches", "the", "Collection", "of", "elements", "in", "order", "to", "find", "the", "element", "or", "elements", "matching", "the", "criteria", "defined", "by", "the", "Matcher", ".", "The", "search", "operation", "expects", "the", "collection", "of", "elem...
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/search/support/BinarySearch.java#L52-L59
train
jsilland/piezo
src/main/java/io/soliton/protobuf/quartz/QuartzClient.java
QuartzClient.close
public void close() { refuseNewRequests.set(true); channel.close().awaitUninterruptibly(); channel.eventLoop().shutdownGracefully().awaitUninterruptibly(); }
java
public void close() { refuseNewRequests.set(true); channel.close().awaitUninterruptibly(); channel.eventLoop().shutdownGracefully().awaitUninterruptibly(); }
[ "public", "void", "close", "(", ")", "{", "refuseNewRequests", ".", "set", "(", "true", ")", ";", "channel", ".", "close", "(", ")", ".", "awaitUninterruptibly", "(", ")", ";", "channel", ".", "eventLoop", "(", ")", ".", "shutdownGracefully", "(", ")", ...
Shuts down this client and releases the underlying associated resources. <p>This operation is synchronous.</p>
[ "Shuts", "down", "this", "client", "and", "releases", "the", "underlying", "associated", "resources", "." ]
9a340f1460d25e07ec475dd24128b838667c959b
https://github.com/jsilland/piezo/blob/9a340f1460d25e07ec475dd24128b838667c959b/src/main/java/io/soliton/protobuf/quartz/QuartzClient.java#L144-L148
train
Sefford/fraggle
fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java
FraggleManager.peek
protected FraggleFragment peek(String tag) { if (fm != null) { return (FraggleFragment) fm.findFragmentByTag(tag); } return new EmptyFragment(); }
java
protected FraggleFragment peek(String tag) { if (fm != null) { return (FraggleFragment) fm.findFragmentByTag(tag); } return new EmptyFragment(); }
[ "protected", "FraggleFragment", "peek", "(", "String", "tag", ")", "{", "if", "(", "fm", "!=", "null", ")", "{", "return", "(", "FraggleFragment", ")", "fm", ".", "findFragmentByTag", "(", "tag", ")", ";", "}", "return", "new", "EmptyFragment", "(", ")",...
Returns the first fragment in the stack with the tag "tag". @param tag Tag to look for in the Fragment stack @return First fragment in the stack with the name Tag
[ "Returns", "the", "first", "fragment", "in", "the", "stack", "with", "the", "tag", "tag", "." ]
d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3
https://github.com/Sefford/fraggle/blob/d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3/fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java#L182-L187
train
Sefford/fraggle
fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java
FraggleManager.processAnimations
protected void processAnimations(FragmentAnimation animation, FragmentTransaction ft) { if (animation != null) { if (animation.isCompletedAnimation()) { ft.setCustomAnimations(animation.getEnterAnim(), animation.getExitAnim(), animation.getPushInAnim(), animation.getPopOutAnim()); } else { ft.setCustomAnimations(animation.getEnterAnim(), animation.getExitAnim()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) for (LollipopAnim sharedElement : animation.getSharedViews()) { ft.addSharedElement(sharedElement.view, sharedElement.name); } } }
java
protected void processAnimations(FragmentAnimation animation, FragmentTransaction ft) { if (animation != null) { if (animation.isCompletedAnimation()) { ft.setCustomAnimations(animation.getEnterAnim(), animation.getExitAnim(), animation.getPushInAnim(), animation.getPopOutAnim()); } else { ft.setCustomAnimations(animation.getEnterAnim(), animation.getExitAnim()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) for (LollipopAnim sharedElement : animation.getSharedViews()) { ft.addSharedElement(sharedElement.view, sharedElement.name); } } }
[ "protected", "void", "processAnimations", "(", "FragmentAnimation", "animation", ",", "FragmentTransaction", "ft", ")", "{", "if", "(", "animation", "!=", "null", ")", "{", "if", "(", "animation", ".", "isCompletedAnimation", "(", ")", ")", "{", "ft", ".", "...
Processes the custom animations element, adding them as required @param animation Animation object to process @param ft Fragment transaction to add to the transition
[ "Processes", "the", "custom", "animations", "element", "adding", "them", "as", "required" ]
d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3
https://github.com/Sefford/fraggle/blob/d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3/fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java#L229-L242
train
Sefford/fraggle
fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java
FraggleManager.configureAdditionMode
protected void configureAdditionMode(Fragment frag, int flags, FragmentTransaction ft, int containerId) { if ((flags & DO_NOT_REPLACE_FRAGMENT) != DO_NOT_REPLACE_FRAGMENT) { ft.replace(containerId, frag, ((FraggleFragment) frag).getFragmentTag()); } else { ft.add(containerId, frag, ((FraggleFragment) frag).getFragmentTag()); peek().onFragmentNotVisible(); } }
java
protected void configureAdditionMode(Fragment frag, int flags, FragmentTransaction ft, int containerId) { if ((flags & DO_NOT_REPLACE_FRAGMENT) != DO_NOT_REPLACE_FRAGMENT) { ft.replace(containerId, frag, ((FraggleFragment) frag).getFragmentTag()); } else { ft.add(containerId, frag, ((FraggleFragment) frag).getFragmentTag()); peek().onFragmentNotVisible(); } }
[ "protected", "void", "configureAdditionMode", "(", "Fragment", "frag", ",", "int", "flags", ",", "FragmentTransaction", "ft", ",", "int", "containerId", ")", "{", "if", "(", "(", "flags", "&", "DO_NOT_REPLACE_FRAGMENT", ")", "!=", "DO_NOT_REPLACE_FRAGMENT", ")", ...
Configures the way to add the Fragment into the transaction. It can vary from adding a new fragment, to using a previous instance and refresh it, or replacing the last one. @param frag Fragment to add @param flags Added flags to the Fragment configuration @param ft Transaction to add the fragment @param containerId Target container ID
[ "Configures", "the", "way", "to", "add", "the", "Fragment", "into", "the", "transaction", ".", "It", "can", "vary", "from", "adding", "a", "new", "fragment", "to", "using", "a", "previous", "instance", "and", "refresh", "it", "or", "replacing", "the", "las...
d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3
https://github.com/Sefford/fraggle/blob/d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3/fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java#L253-L260
train
Sefford/fraggle
fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java
FraggleManager.performTransaction
protected void performTransaction(Fragment frag, int flags, FragmentTransaction ft, int containerId) { configureAdditionMode(frag, flags, ft, containerId); ft.commitAllowingStateLoss(); }
java
protected void performTransaction(Fragment frag, int flags, FragmentTransaction ft, int containerId) { configureAdditionMode(frag, flags, ft, containerId); ft.commitAllowingStateLoss(); }
[ "protected", "void", "performTransaction", "(", "Fragment", "frag", ",", "int", "flags", ",", "FragmentTransaction", "ft", ",", "int", "containerId", ")", "{", "configureAdditionMode", "(", "frag", ",", "flags", ",", "ft", ",", "containerId", ")", ";", "ft", ...
Commits the transaction to the Fragment Manager. @param frag Fragment to add @param flags Added flags to the Fragment configuration @param ft Transaction to add the fragment @param containerId Target containerID
[ "Commits", "the", "transaction", "to", "the", "Fragment", "Manager", "." ]
d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3
https://github.com/Sefford/fraggle/blob/d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3/fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java#L270-L273
train
Sefford/fraggle
fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java
FraggleManager.peek
protected FraggleFragment peek() { if (fm.getBackStackEntryCount() > 0) { return ((FraggleFragment) fm.findFragmentByTag( fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName())); } else { return new EmptyFragment(); } }
java
protected FraggleFragment peek() { if (fm.getBackStackEntryCount() > 0) { return ((FraggleFragment) fm.findFragmentByTag( fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName())); } else { return new EmptyFragment(); } }
[ "protected", "FraggleFragment", "peek", "(", ")", "{", "if", "(", "fm", ".", "getBackStackEntryCount", "(", ")", ">", "0", ")", "{", "return", "(", "(", "FraggleFragment", ")", "fm", ".", "findFragmentByTag", "(", "fm", ".", "getBackStackEntryAt", "(", "fm...
Peeks the last fragment in the Fragment stack. @return Last Fragment in the fragment stack @throws java.lang.NullPointerException if there is no Fragment Added
[ "Peeks", "the", "last", "fragment", "in", "the", "Fragment", "stack", "." ]
d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3
https://github.com/Sefford/fraggle/blob/d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3/fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java#L281-L288
train
Sefford/fraggle
fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java
FraggleManager.clear
public void clear() { if (fm != null) { fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); } fm = null; }
java
public void clear() { if (fm != null) { fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); } fm = null; }
[ "public", "void", "clear", "(", ")", "{", "if", "(", "fm", "!=", "null", ")", "{", "fm", ".", "popBackStack", "(", "null", ",", "FragmentManager", ".", "POP_BACK_STACK_INCLUSIVE", ")", ";", "}", "fm", "=", "null", ";", "}" ]
Clears fragment manager backstack and the fragment manager itself.
[ "Clears", "fragment", "manager", "backstack", "and", "the", "fragment", "manager", "itself", "." ]
d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3
https://github.com/Sefford/fraggle/blob/d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3/fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java#L347-L352
train
Sefford/fraggle
fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java
FraggleManager.reattach
public void reattach(String tag) { final Fragment currentFragment = (Fragment) peek(tag); FragmentTransaction fragTransaction = fm.beginTransaction(); fragTransaction.detach(currentFragment); fragTransaction.attach(currentFragment); fragTransaction.commit(); }
java
public void reattach(String tag) { final Fragment currentFragment = (Fragment) peek(tag); FragmentTransaction fragTransaction = fm.beginTransaction(); fragTransaction.detach(currentFragment); fragTransaction.attach(currentFragment); fragTransaction.commit(); }
[ "public", "void", "reattach", "(", "String", "tag", ")", "{", "final", "Fragment", "currentFragment", "=", "(", "Fragment", ")", "peek", "(", "tag", ")", ";", "FragmentTransaction", "fragTransaction", "=", "fm", ".", "beginTransaction", "(", ")", ";", "fragT...
Reattaches a Fragment @param tag Tag of the Fragment to reattach
[ "Reattaches", "a", "Fragment" ]
d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3
https://github.com/Sefford/fraggle/blob/d1b65a99ecc3c3faeef8f288ca6225bbf475c3a3/fraggle/src/main/java/com/sefford/fraggle/FraggleManager.java#L359-L365
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/util/Parameters.java
Parameters.keys
public Set<String> keys(String pattern) { Set<String> result = new TreeSet<String>(); for (String key : keys()) { if (key.matches(pattern)) result.add(key); } return result; }
java
public Set<String> keys(String pattern) { Set<String> result = new TreeSet<String>(); for (String key : keys()) { if (key.matches(pattern)) result.add(key); } return result; }
[ "public", "Set", "<", "String", ">", "keys", "(", "String", "pattern", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "TreeSet", "<", "String", ">", "(", ")", ";", "for", "(", "String", "key", ":", "keys", "(", ")", ")", "{", "if", ...
Returns all keys matching the given pattern. @param pattern key pattern @return set of keys
[ "Returns", "all", "keys", "matching", "the", "given", "pattern", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/util/Parameters.java#L59-L65
train
loadimpact/loadimpact-sdk-java
src/main/java/com/loadimpact/util/Parameters.java
Parameters.get
public String get(String key, String defaultValue) { String value = parameters.get(key); return StringUtils.isBlank(value) ? defaultValue : value; }
java
public String get(String key, String defaultValue) { String value = parameters.get(key); return StringUtils.isBlank(value) ? defaultValue : value; }
[ "public", "String", "get", "(", "String", "key", ",", "String", "defaultValue", ")", "{", "String", "value", "=", "parameters", ".", "get", "(", "key", ")", ";", "return", "StringUtils", ".", "isBlank", "(", "value", ")", "?", "defaultValue", ":", "value...
Returns the value associated with the key, or the given default value. @param key key to find @param defaultValue if not found @return value
[ "Returns", "the", "value", "associated", "with", "the", "key", "or", "the", "given", "default", "value", "." ]
49af80b768c5453266414108b0d30a0fc01b8cef
https://github.com/loadimpact/loadimpact-sdk-java/blob/49af80b768c5453266414108b0d30a0fc01b8cef/src/main/java/com/loadimpact/util/Parameters.java#L84-L87
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/mps/system_settings.java
system_settings.get
public static system_settings get(nitro_service client) throws Exception { system_settings resource = new system_settings(); resource.validate("get"); return ((system_settings[]) resource.get_resources(client))[0]; }
java
public static system_settings get(nitro_service client) throws Exception { system_settings resource = new system_settings(); resource.validate("get"); return ((system_settings[]) resource.get_resources(client))[0]; }
[ "public", "static", "system_settings", "get", "(", "nitro_service", "client", ")", "throws", "Exception", "{", "system_settings", "resource", "=", "new", "system_settings", "(", ")", ";", "resource", ".", "validate", "(", "\"get\"", ")", ";", "return", "(", "(...
Use this operation to get SDX system settings.
[ "Use", "this", "operation", "to", "get", "SDX", "system", "settings", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/system_settings.java#L209-L214
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/sort/AbstractSorter.java
AbstractSorter.getOrderBy
@Override @SuppressWarnings("unchecked") public <E> Comparator<E> getOrderBy() { return ObjectUtils.defaultIfNull(ComparatorHolder.get(), ObjectUtils.defaultIfNull( orderBy, ComparableComparator.INSTANCE)); }
java
@Override @SuppressWarnings("unchecked") public <E> Comparator<E> getOrderBy() { return ObjectUtils.defaultIfNull(ComparatorHolder.get(), ObjectUtils.defaultIfNull( orderBy, ComparableComparator.INSTANCE)); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "E", ">", "Comparator", "<", "E", ">", "getOrderBy", "(", ")", "{", "return", "ObjectUtils", ".", "defaultIfNull", "(", "ComparatorHolder", ".", "get", "(", ")", ",", "Obje...
Gets the Comparator used to order the elements in the collection. @param <E> the type of elements in the Collection to compare. @return the Comparator used to order the collection elements. @see java.util.Comparator
[ "Gets", "the", "Comparator", "used", "to", "order", "the", "elements", "in", "the", "collection", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/sort/AbstractSorter.java#L76-L81
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/sort/AbstractSorter.java
AbstractSorter.sort
@Override @SuppressWarnings("unchecked") public <E> E[] sort(final E... elements) { sort(new SortableArrayList(elements)); return elements; }
java
@Override @SuppressWarnings("unchecked") public <E> E[] sort(final E... elements) { sort(new SortableArrayList(elements)); return elements; }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "E", ">", "E", "[", "]", "sort", "(", "final", "E", "...", "elements", ")", "{", "sort", "(", "new", "SortableArrayList", "(", "elements", ")", ")", ";", "return", "ele...
Sorts an array of elements as defined by the Comparator, or as determined by the elements in the array if the elements are Comparable. @param <E> the type of elements in the array. @param elements the array of elements to sort. @return the array of elements sorted. @see #sort(java.util.List) @see java.util.Arrays#asList(Object[]) @see java.util.ArrayList
[ "Sorts", "an", "array", "of", "elements", "as", "defined", "by", "the", "Comparator", "or", "as", "determined", "by", "the", "elements", "in", "the", "array", "if", "the", "elements", "are", "Comparable", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/sort/AbstractSorter.java#L104-L109
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/sort/AbstractSorter.java
AbstractSorter.sort
@Override public <E> Sortable<E> sort(final Sortable<E> sortable) { try { sort(configureComparator(sortable).asList()); return sortable; } finally { ComparatorHolder.unset(); } }
java
@Override public <E> Sortable<E> sort(final Sortable<E> sortable) { try { sort(configureComparator(sortable).asList()); return sortable; } finally { ComparatorHolder.unset(); } }
[ "@", "Override", "public", "<", "E", ">", "Sortable", "<", "E", ">", "sort", "(", "final", "Sortable", "<", "E", ">", "sortable", ")", "{", "try", "{", "sort", "(", "configureComparator", "(", "sortable", ")", ".", "asList", "(", ")", ")", ";", "re...
Sorts the List representation of the Sortable implementing object as defined by the 'orderBy' Comparator, or as determined by elements in the Sortable collection if the elements are Comparable. @param <E> the Class type of elements in the Sortable. @param sortable the Sortable implementing object containing the collection of elements to sort. @return the Sortable implementing object sorted. @see #configureComparator(Sortable) @see #getOrderBy() @see #sort(java.util.List) @see org.cp.elements.util.sort.Sortable#asList()
[ "Sorts", "the", "List", "representation", "of", "the", "Sortable", "implementing", "object", "as", "defined", "by", "the", "orderBy", "Comparator", "or", "as", "determined", "by", "elements", "in", "the", "Sortable", "collection", "if", "the", "elements", "are",...
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/sort/AbstractSorter.java#L123-L132
train
KyoriPowered/lunar
src/main/java/net/kyori/lunar/Optionals.java
Optionals.first
@SafeVarargs public static <T> @NonNull Optional<T> first(final @NonNull Optional<T>... optionals) { return Arrays.stream(optionals) .filter(Optional::isPresent) .findFirst() .orElse(Optional.empty()); }
java
@SafeVarargs public static <T> @NonNull Optional<T> first(final @NonNull Optional<T>... optionals) { return Arrays.stream(optionals) .filter(Optional::isPresent) .findFirst() .orElse(Optional.empty()); }
[ "@", "SafeVarargs", "public", "static", "<", "T", ">", "@", "NonNull", "Optional", "<", "T", ">", "first", "(", "final", "@", "NonNull", "Optional", "<", "T", ">", "...", "optionals", ")", "{", "return", "Arrays", ".", "stream", "(", "optionals", ")", ...
Gets the first optional with a present value. @param optionals the optionals @param <T> the type @return an optional
[ "Gets", "the", "first", "optional", "with", "a", "present", "value", "." ]
6856747d9034a2fe0c8d0a8a0150986797732b5c
https://github.com/KyoriPowered/lunar/blob/6856747d9034a2fe0c8d0a8a0150986797732b5c/src/main/java/net/kyori/lunar/Optionals.java#L72-L78
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/search/SearcherFactory.java
SearcherFactory.createSearcher
@SuppressWarnings("unchecked") public static <T extends Searcher> T createSearcher(final SearchType type) { switch (ObjectUtils.defaultIfNull(type, SearchType.UNKNOWN_SEARCH)) { case BINARY_SEARCH: return (T) new BinarySearch(); case LINEAR_SEARCH: return (T) new LinearSearch(); default: throw new IllegalArgumentException(String.format("The SearchType (%1$s) is not supported by the %2$s!", type, SearcherFactory.class.getSimpleName())); } }
java
@SuppressWarnings("unchecked") public static <T extends Searcher> T createSearcher(final SearchType type) { switch (ObjectUtils.defaultIfNull(type, SearchType.UNKNOWN_SEARCH)) { case BINARY_SEARCH: return (T) new BinarySearch(); case LINEAR_SEARCH: return (T) new LinearSearch(); default: throw new IllegalArgumentException(String.format("The SearchType (%1$s) is not supported by the %2$s!", type, SearcherFactory.class.getSimpleName())); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", "extends", "Searcher", ">", "T", "createSearcher", "(", "final", "SearchType", "type", ")", "{", "switch", "(", "ObjectUtils", ".", "defaultIfNull", "(", "type", ",", "SearchType...
Creates an instance of the Searcher interface implementing the searching algorithm based on the SearchType. @param <T> the Class type of the actual Searcher implementation based on the SearchType. @param type the type of searching algorithm Searcher implementation to create. @return a Searcher implementation subclass that implements the searching algorithm based on the SearchType. @see org.cp.elements.util.search.Searcher @see org.cp.elements.util.search.SearchType
[ "Creates", "an", "instance", "of", "the", "Searcher", "interface", "implementing", "the", "searching", "algorithm", "based", "on", "the", "SearchType", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/search/SearcherFactory.java#L46-L57
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/search/SearcherFactory.java
SearcherFactory.createSearcherElseDefault
public static <T extends Searcher> T createSearcherElseDefault(final SearchType type, final T defaultSearcher) { try { return createSearcher(type); } catch (IllegalArgumentException ignore) { return defaultSearcher; } }
java
public static <T extends Searcher> T createSearcherElseDefault(final SearchType type, final T defaultSearcher) { try { return createSearcher(type); } catch (IllegalArgumentException ignore) { return defaultSearcher; } }
[ "public", "static", "<", "T", "extends", "Searcher", ">", "T", "createSearcherElseDefault", "(", "final", "SearchType", "type", ",", "final", "T", "defaultSearcher", ")", "{", "try", "{", "return", "createSearcher", "(", "type", ")", ";", "}", "catch", "(", ...
Creates an instance of the Searcher interface implementing the searching algorithm based on the SearchType, otherwise returns the provided default Searcher implementation if a Searcher based on the specified SearchType is not available. @param <T> the Class type of the actual Searcher implementation based on the SearchType. @param type the type of searching algorithm Searcher implementation to create. @param defaultSearcher the default Searcher implementation to use if a Searcher based on the specified SearchType is not available. @return a Searcher implementation subclass that implements the searching algorithm based on the SearchType, or the provided default Searcher implementation if the Searcher based on the SearchType is not available. @see #createSearcher(SearchType) @see org.cp.elements.util.search.Searcher @see org.cp.elements.util.search.SearchType
[ "Creates", "an", "instance", "of", "the", "Searcher", "interface", "implementing", "the", "searching", "algorithm", "based", "on", "the", "SearchType", "otherwise", "returns", "the", "provided", "default", "Searcher", "implementation", "if", "a", "Searcher", "based"...
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/search/SearcherFactory.java#L74-L81
train
rholder/moar-concurrent
src/main/java/com/github/rholder/moar/concurrent/thread/BalancingThreadPoolExecutor.java
BalancingThreadPoolExecutor.balance
private void balance() { // only try to balance when we're not terminating if(!isTerminated()) { Set<Map.Entry<Thread, Tracking>> threads = liveThreads.entrySet(); long liveAvgTimeTotal = 0; long liveAvgCpuTotal = 0; long liveCount = 0; for (Map.Entry<Thread, Tracking> e : threads) { if (!e.getKey().isAlive()) { // thread is dead or otherwise hosed threads.remove(e); } else { liveAvgTimeTotal += e.getValue().avgTotalTime; liveAvgCpuTotal += e.getValue().avgCpuTime; liveCount++; } } long waitTime = 1; long cpuTime = 1; if(liveCount > 0) { waitTime = liveAvgTimeTotal / liveCount; cpuTime = liveAvgCpuTotal / liveCount; } int size = 1; if(cpuTime > 0) { size = (int) ceil((CPUS * targetUtilization * (1 + (waitTime / cpuTime)))); } size = Math.min(size, threadPoolExecutor.getMaximumPoolSize()); // TODO remove debugging //System.out.println(waitTime / 1000000 + " ms"); //System.out.println(cpuTime / 1000000 + " ms"); //System.out.println(size); threadPoolExecutor.setCorePoolSize(size); } }
java
private void balance() { // only try to balance when we're not terminating if(!isTerminated()) { Set<Map.Entry<Thread, Tracking>> threads = liveThreads.entrySet(); long liveAvgTimeTotal = 0; long liveAvgCpuTotal = 0; long liveCount = 0; for (Map.Entry<Thread, Tracking> e : threads) { if (!e.getKey().isAlive()) { // thread is dead or otherwise hosed threads.remove(e); } else { liveAvgTimeTotal += e.getValue().avgTotalTime; liveAvgCpuTotal += e.getValue().avgCpuTime; liveCount++; } } long waitTime = 1; long cpuTime = 1; if(liveCount > 0) { waitTime = liveAvgTimeTotal / liveCount; cpuTime = liveAvgCpuTotal / liveCount; } int size = 1; if(cpuTime > 0) { size = (int) ceil((CPUS * targetUtilization * (1 + (waitTime / cpuTime)))); } size = Math.min(size, threadPoolExecutor.getMaximumPoolSize()); // TODO remove debugging //System.out.println(waitTime / 1000000 + " ms"); //System.out.println(cpuTime / 1000000 + " ms"); //System.out.println(size); threadPoolExecutor.setCorePoolSize(size); } }
[ "private", "void", "balance", "(", ")", "{", "// only try to balance when we're not terminating", "if", "(", "!", "isTerminated", "(", ")", ")", "{", "Set", "<", "Map", ".", "Entry", "<", "Thread", ",", "Tracking", ">", ">", "threads", "=", "liveThreads", "....
Compute and set the optimal number of threads to use in this pool.
[ "Compute", "and", "set", "the", "optimal", "number", "of", "threads", "to", "use", "in", "this", "pool", "." ]
c28facbf02e628cc37266c051c23d4a7654b4eba
https://github.com/rholder/moar-concurrent/blob/c28facbf02e628cc37266c051c23d4a7654b4eba/src/main/java/com/github/rholder/moar/concurrent/thread/BalancingThreadPoolExecutor.java#L138-L175
train
dejv78/javafx-commons
jfx-controls/src/main/java/dejv/jfx/controls/radialmenu1/RadialMenu.java
RadialMenu.setMenu
public void setMenu(Menu menu) { this.menu = menu; RadialMenuItem.setupMenuButton(this, radialMenuParams, (menu != null) ? menu.getGraphic() : null, (menu != null) ? menu.getText() : null, true); }
java
public void setMenu(Menu menu) { this.menu = menu; RadialMenuItem.setupMenuButton(this, radialMenuParams, (menu != null) ? menu.getGraphic() : null, (menu != null) ? menu.getText() : null, true); }
[ "public", "void", "setMenu", "(", "Menu", "menu", ")", "{", "this", ".", "menu", "=", "menu", ";", "RadialMenuItem", ".", "setupMenuButton", "(", "this", ",", "radialMenuParams", ",", "(", "menu", "!=", "null", ")", "?", "menu", ".", "getGraphic", "(", ...
Sets the menu model. @param menu Structure of {@link MenuItem}s to display.
[ "Sets", "the", "menu", "model", "." ]
ea846eeeb4ed43a7628a40931a3e6f27d513592f
https://github.com/dejv78/javafx-commons/blob/ea846eeeb4ed43a7628a40931a3e6f27d513592f/jfx-controls/src/main/java/dejv/jfx/controls/radialmenu1/RadialMenu.java#L70-L74
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/sort/support/HeapSort.java
HeapSort.sort
@Override public <E> List<E> sort(final List<E> elements) { int size = elements.size(); // create the heap for (int parentIndex = ((size - 2) / 2); parentIndex >= 0; parentIndex--) { siftDown(elements, parentIndex, size - 1); } // swap the first and last elements in the heap of array since the first is the largest value in the heap, // and then heapify the heap again for (int count = (size - 1); count > 0; count--) { swap(elements, 0, count); siftDown(elements, 0, count - 1); } return elements; }
java
@Override public <E> List<E> sort(final List<E> elements) { int size = elements.size(); // create the heap for (int parentIndex = ((size - 2) / 2); parentIndex >= 0; parentIndex--) { siftDown(elements, parentIndex, size - 1); } // swap the first and last elements in the heap of array since the first is the largest value in the heap, // and then heapify the heap again for (int count = (size - 1); count > 0; count--) { swap(elements, 0, count); siftDown(elements, 0, count - 1); } return elements; }
[ "@", "Override", "public", "<", "E", ">", "List", "<", "E", ">", "sort", "(", "final", "List", "<", "E", ">", "elements", ")", "{", "int", "size", "=", "elements", ".", "size", "(", ")", ";", "// create the heap", "for", "(", "int", "parentIndex", ...
Uses the Heap Sort algorithm to sort a List of elements as defined by the Comparator, or as determined by the elements in the collection if the elements are Comparable. @param <E> the type of elements in the List. @param elements the List of elements to sort. @return the collection of elements sorted. @see #siftDown(java.util.List, int, int) @see java.util.List
[ "Uses", "the", "Heap", "Sort", "algorithm", "to", "sort", "a", "List", "of", "elements", "as", "defined", "by", "the", "Comparator", "or", "as", "determined", "by", "the", "elements", "in", "the", "collection", "if", "the", "elements", "are", "Comparable", ...
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/sort/support/HeapSort.java#L47-L64
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/sort/support/HeapSort.java
HeapSort.siftDown
protected <E> void siftDown(final List<E> elements, final int startIndex, final int endIndex) { int rootIndex = startIndex; while ((rootIndex * 2 + 1) <= endIndex) { int swapIndex = rootIndex; int leftChildIndex = (rootIndex * 2 + 1); int rightChildIndex = (leftChildIndex + 1); if (getOrderBy().compare(elements.get(swapIndex), elements.get(leftChildIndex)) < 0) { swapIndex = leftChildIndex; } if (rightChildIndex <= endIndex && getOrderBy().compare(elements.get(swapIndex), elements.get(rightChildIndex)) < 0) { swapIndex = rightChildIndex; } if (swapIndex != rootIndex) { swap(elements, rootIndex, swapIndex); rootIndex = swapIndex; } else { return; } } }
java
protected <E> void siftDown(final List<E> elements, final int startIndex, final int endIndex) { int rootIndex = startIndex; while ((rootIndex * 2 + 1) <= endIndex) { int swapIndex = rootIndex; int leftChildIndex = (rootIndex * 2 + 1); int rightChildIndex = (leftChildIndex + 1); if (getOrderBy().compare(elements.get(swapIndex), elements.get(leftChildIndex)) < 0) { swapIndex = leftChildIndex; } if (rightChildIndex <= endIndex && getOrderBy().compare(elements.get(swapIndex), elements.get(rightChildIndex)) < 0) { swapIndex = rightChildIndex; } if (swapIndex != rootIndex) { swap(elements, rootIndex, swapIndex); rootIndex = swapIndex; } else { return; } } }
[ "protected", "<", "E", ">", "void", "siftDown", "(", "final", "List", "<", "E", ">", "elements", ",", "final", "int", "startIndex", ",", "final", "int", "endIndex", ")", "{", "int", "rootIndex", "=", "startIndex", ";", "while", "(", "(", "rootIndex", "...
Creates a binary heap with the list of elements with the largest valued element at the root followed by the next largest valued elements as parents down to the leafs. @param <E> the Class type of the elements in the List. @param elements the List of elements to heapify. @param startIndex an integer value indicating the starting index in the heap in the List of elements. @param endIndex an integer value indicating the ending index in the heap in the List of elements.
[ "Creates", "a", "binary", "heap", "with", "the", "list", "of", "elements", "with", "the", "largest", "valued", "element", "at", "the", "root", "followed", "by", "the", "next", "largest", "valued", "elements", "as", "parents", "down", "to", "the", "leafs", ...
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/sort/support/HeapSort.java#L75-L99
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/beans/event/ChangeSupport.java
ChangeSupport.fireChangeEvent
public void fireChangeEvent() { ChangeEvent event = createChangeEvent(getSource()); for (ChangeListener listener : this) { listener.stateChanged(event); } }
java
public void fireChangeEvent() { ChangeEvent event = createChangeEvent(getSource()); for (ChangeListener listener : this) { listener.stateChanged(event); } }
[ "public", "void", "fireChangeEvent", "(", ")", "{", "ChangeEvent", "event", "=", "createChangeEvent", "(", "getSource", "(", ")", ")", ";", "for", "(", "ChangeListener", "listener", ":", "this", ")", "{", "listener", ".", "stateChanged", "(", "event", ")", ...
Fires a ChangeEvent for the source Object notifying each registered ChangeListener of the change. @see org.cp.elements.beans.event.ChangeEvent @see org.cp.elements.beans.event.ChangeListener @see #iterator()
[ "Fires", "a", "ChangeEvent", "for", "the", "source", "Object", "notifying", "each", "registered", "ChangeListener", "of", "the", "change", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/beans/event/ChangeSupport.java#L110-L116
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/sort/support/QuickSort.java
QuickSort.sort
@Override public <E> List<E> sort(final List<E> elements) { int elementsSize = elements.size(); if (elementsSize <= getSizeThreshold()) { return getSorter().sort(elements); } else { int beginIndex = 1; int endIndex = (elementsSize - 1); E pivotElement = elements.get(0); while (beginIndex < endIndex) { while (beginIndex < endIndex && getOrderBy().compare(elements.get(beginIndex), pivotElement) <= 0) { beginIndex++; } while (endIndex >= beginIndex && getOrderBy().compare(elements.get(endIndex), pivotElement) >= 0) { endIndex--; } if (beginIndex < endIndex) { swap(elements, beginIndex, endIndex); } } swap(elements, 0, endIndex); sort(elements.subList(0, endIndex)); sort(elements.subList(endIndex + 1, elementsSize)); return elements; } }
java
@Override public <E> List<E> sort(final List<E> elements) { int elementsSize = elements.size(); if (elementsSize <= getSizeThreshold()) { return getSorter().sort(elements); } else { int beginIndex = 1; int endIndex = (elementsSize - 1); E pivotElement = elements.get(0); while (beginIndex < endIndex) { while (beginIndex < endIndex && getOrderBy().compare(elements.get(beginIndex), pivotElement) <= 0) { beginIndex++; } while (endIndex >= beginIndex && getOrderBy().compare(elements.get(endIndex), pivotElement) >= 0) { endIndex--; } if (beginIndex < endIndex) { swap(elements, beginIndex, endIndex); } } swap(elements, 0, endIndex); sort(elements.subList(0, endIndex)); sort(elements.subList(endIndex + 1, elementsSize)); return elements; } }
[ "@", "Override", "public", "<", "E", ">", "List", "<", "E", ">", "sort", "(", "final", "List", "<", "E", ">", "elements", ")", "{", "int", "elementsSize", "=", "elements", ".", "size", "(", ")", ";", "if", "(", "elementsSize", "<=", "getSizeThreshold...
Uses the Quick Sort algorithm to sort a List of elements as defined by the Comparator, or as determined by the elements in the collection if the elements are Comparable. @param <E> the type of elements in the List. @param elements the List of elements to sort. @return the collection of elements sorted. @see java.util.List
[ "Uses", "the", "Quick", "Sort", "algorithm", "to", "sort", "a", "List", "of", "elements", "as", "defined", "by", "the", "Comparator", "or", "as", "determined", "by", "the", "elements", "in", "the", "collection", "if", "the", "elements", "are", "Comparable", ...
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/sort/support/QuickSort.java#L112-L145
train
rholder/moar-concurrent
src/main/java/com/github/rholder/moar/concurrent/HeapQueueingStrategy.java
HeapQueueingStrategy.onBeforeAdd
public void onBeforeAdd(E value) { long freeHeapSpace = RUNTIME.freeMemory() + (RUNTIME.maxMemory() - RUNTIME.totalMemory()); // start flow control if we cross the threshold if (freeHeapSpace < minimumHeapSpaceBeforeFlowControl) { // x indicates how close we are to overflowing the heap long x = minimumHeapSpaceBeforeFlowControl - freeHeapSpace; long delay = Math.round(x * (x * c)); // delay = x^2 * c try { Thread.sleep(delay); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
java
public void onBeforeAdd(E value) { long freeHeapSpace = RUNTIME.freeMemory() + (RUNTIME.maxMemory() - RUNTIME.totalMemory()); // start flow control if we cross the threshold if (freeHeapSpace < minimumHeapSpaceBeforeFlowControl) { // x indicates how close we are to overflowing the heap long x = minimumHeapSpaceBeforeFlowControl - freeHeapSpace; long delay = Math.round(x * (x * c)); // delay = x^2 * c try { Thread.sleep(delay); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
[ "public", "void", "onBeforeAdd", "(", "E", "value", ")", "{", "long", "freeHeapSpace", "=", "RUNTIME", ".", "freeMemory", "(", ")", "+", "(", "RUNTIME", ".", "maxMemory", "(", ")", "-", "RUNTIME", ".", "totalMemory", "(", ")", ")", ";", "// start flow co...
Block for a varying amount based on how close the system is to the max heap space. Only kick in when we have passed the percentOfHeapBeforeFlowControl threshold. @param value value that is to be added to the queue
[ "Block", "for", "a", "varying", "amount", "based", "on", "how", "close", "the", "system", "is", "to", "the", "max", "heap", "space", ".", "Only", "kick", "in", "when", "we", "have", "passed", "the", "percentOfHeapBeforeFlowControl", "threshold", "." ]
c28facbf02e628cc37266c051c23d4a7654b4eba
https://github.com/rholder/moar-concurrent/blob/c28facbf02e628cc37266c051c23d4a7654b4eba/src/main/java/com/github/rholder/moar/concurrent/HeapQueueingStrategy.java#L67-L84
train
rholder/moar-concurrent
src/main/java/com/github/rholder/moar/concurrent/HeapQueueingStrategy.java
HeapQueueingStrategy.onAfterRemove
public void onAfterRemove(E value) { if (value != null) { dequeued++; if (dequeued % dequeueHint == 0) { RUNTIME.gc(); } } }
java
public void onAfterRemove(E value) { if (value != null) { dequeued++; if (dequeued % dequeueHint == 0) { RUNTIME.gc(); } } }
[ "public", "void", "onAfterRemove", "(", "E", "value", ")", "{", "if", "(", "value", "!=", "null", ")", "{", "dequeued", "++", ";", "if", "(", "dequeued", "%", "dequeueHint", "==", "0", ")", "{", "RUNTIME", ".", "gc", "(", ")", ";", "}", "}", "}" ...
Increment the count of removed items from the queue. Calling this will optionally request that the garbage collector run to free up heap space for every nth dequeue, where n is the value set for the dequeueHint. @param value value that was removed from the queue
[ "Increment", "the", "count", "of", "removed", "items", "from", "the", "queue", ".", "Calling", "this", "will", "optionally", "request", "that", "the", "garbage", "collector", "run", "to", "free", "up", "heap", "space", "for", "every", "nth", "dequeue", "wher...
c28facbf02e628cc37266c051c23d4a7654b4eba
https://github.com/rholder/moar-concurrent/blob/c28facbf02e628cc37266c051c23d4a7654b4eba/src/main/java/com/github/rholder/moar/concurrent/HeapQueueingStrategy.java#L101-L108
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/beans/event/ChangeTracker.java
ChangeTracker.propertyChange
public void propertyChange(final PropertyChangeEvent event) { if (objectStateMap.containsKey(event.getPropertyName())) { if (objectStateMap.get(event.getPropertyName()) == ObjectUtils.hashCode(event.getNewValue())) { // NOTE the state of the property identified by the event has been reverted to it's original, persisted value. objectStateMap.remove(event.getPropertyName()); } } else { if (!ObjectUtils.equalsIgnoreNull(event.getOldValue(), event.getNewValue())) { objectStateMap.put(event.getPropertyName(), ObjectUtils.hashCode(event.getOldValue())); } } }
java
public void propertyChange(final PropertyChangeEvent event) { if (objectStateMap.containsKey(event.getPropertyName())) { if (objectStateMap.get(event.getPropertyName()) == ObjectUtils.hashCode(event.getNewValue())) { // NOTE the state of the property identified by the event has been reverted to it's original, persisted value. objectStateMap.remove(event.getPropertyName()); } } else { if (!ObjectUtils.equalsIgnoreNull(event.getOldValue(), event.getNewValue())) { objectStateMap.put(event.getPropertyName(), ObjectUtils.hashCode(event.getOldValue())); } } }
[ "public", "void", "propertyChange", "(", "final", "PropertyChangeEvent", "event", ")", "{", "if", "(", "objectStateMap", ".", "containsKey", "(", "event", ".", "getPropertyName", "(", ")", ")", ")", "{", "if", "(", "objectStateMap", ".", "get", "(", "event",...
The event handler method that gets fired when a property of the Bean tracked by this ChangeTracker has been modified. The PropertyChangeEvent encapsulates all the information pertaining to the property change including the name of the property, it's old and new value and the source Bean of the targeted change. @param event the PropertyChangeEvent encapsulating information about the property change. @see java.beans.PropertyChangeEvent
[ "The", "event", "handler", "method", "that", "gets", "fired", "when", "a", "property", "of", "the", "Bean", "tracked", "by", "this", "ChangeTracker", "has", "been", "modified", ".", "The", "PropertyChangeEvent", "encapsulates", "all", "the", "information", "pert...
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/beans/event/ChangeTracker.java#L74-L86
train
jsilland/piezo
src/main/java/io/soliton/protobuf/json/JsonResponseFuture.java
JsonResponseFuture.setResponse
public void setResponse(JsonRpcResponse response) { if (response.isError()) { setException(response.error()); return; } try { set((V) Messages.fromJson(method.outputBuilder(), response.result())); } catch (Exception e) { setException(e); } }
java
public void setResponse(JsonRpcResponse response) { if (response.isError()) { setException(response.error()); return; } try { set((V) Messages.fromJson(method.outputBuilder(), response.result())); } catch (Exception e) { setException(e); } }
[ "public", "void", "setResponse", "(", "JsonRpcResponse", "response", ")", "{", "if", "(", "response", ".", "isError", "(", ")", ")", "{", "setException", "(", "response", ".", "error", "(", ")", ")", ";", "return", ";", "}", "try", "{", "set", "(", "...
Sets the JSON response of this promise. @param response the RPC response
[ "Sets", "the", "JSON", "response", "of", "this", "promise", "." ]
9a340f1460d25e07ec475dd24128b838667c959b
https://github.com/jsilland/piezo/blob/9a340f1460d25e07ec475dd24128b838667c959b/src/main/java/io/soliton/protobuf/json/JsonResponseFuture.java#L49-L60
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/factory/AbstractObjectFactory.java
AbstractObjectFactory.getArgumentTypes
@SuppressWarnings("unchecked") protected Class[] getArgumentTypes(final Object... arguments) { Class[] argumentTypes = new Class[arguments.length]; int index = 0; for (Object argument : arguments) { argumentTypes[index++] = ObjectUtils.defaultIfNull(ClassUtils.getClass(argument), Object.class); } return argumentTypes; }
java
@SuppressWarnings("unchecked") protected Class[] getArgumentTypes(final Object... arguments) { Class[] argumentTypes = new Class[arguments.length]; int index = 0; for (Object argument : arguments) { argumentTypes[index++] = ObjectUtils.defaultIfNull(ClassUtils.getClass(argument), Object.class); } return argumentTypes; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "Class", "[", "]", "getArgumentTypes", "(", "final", "Object", "...", "arguments", ")", "{", "Class", "[", "]", "argumentTypes", "=", "new", "Class", "[", "arguments", ".", "length", "]", ";", ...
Determines the class types of the array of object arguments. @param arguments the array of Object arguments to determine the class types for. @return an array of Class types for each of the arguments in the array. @see org.cp.elements.lang.ClassUtils#getClass(Object)
[ "Determines", "the", "class", "types", "of", "the", "array", "of", "object", "arguments", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/factory/AbstractObjectFactory.java#L113-L123
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/factory/AbstractObjectFactory.java
AbstractObjectFactory.resolveConstructor
protected Constructor resolveConstructor(final Class<?> objectType, final Class... parameterTypes) { try { return objectType.getConstructor(parameterTypes); } catch (NoSuchMethodException e) { if (!ArrayUtils.isEmpty(parameterTypes)) { Constructor constructor = resolveCompatibleConstructor(objectType, parameterTypes); // if the "compatible" constructor is null, resolve to finding the public, default no-arg constructor return (constructor != null ? constructor : resolveConstructor(objectType)); } throw new NoSuchConstructorException(String.format( "Failed to find a constructor with signature (%1$s) in Class (%2$s)", from(parameterTypes).toString(), objectType.getName()), e); } }
java
protected Constructor resolveConstructor(final Class<?> objectType, final Class... parameterTypes) { try { return objectType.getConstructor(parameterTypes); } catch (NoSuchMethodException e) { if (!ArrayUtils.isEmpty(parameterTypes)) { Constructor constructor = resolveCompatibleConstructor(objectType, parameterTypes); // if the "compatible" constructor is null, resolve to finding the public, default no-arg constructor return (constructor != null ? constructor : resolveConstructor(objectType)); } throw new NoSuchConstructorException(String.format( "Failed to find a constructor with signature (%1$s) in Class (%2$s)", from(parameterTypes).toString(), objectType.getName()), e); } }
[ "protected", "Constructor", "resolveConstructor", "(", "final", "Class", "<", "?", ">", "objectType", ",", "final", "Class", "...", "parameterTypes", ")", "{", "try", "{", "return", "objectType", ".", "getConstructor", "(", "parameterTypes", ")", ";", "}", "ca...
Resolves the Class constructor with the given signature as determined by the parameter types. @param objectType the Class from which the constructor is resolved. @param parameterTypes the array of Class types determining the resolved constructor's signature. @return a Constructor from the specified class with a matching signature based on the parameter types. @throws NullPointerException if either the objectType or parameterTypes are null. @see #resolveCompatibleConstructor(Class, Class[]) @see java.lang.Class @see java.lang.reflect.Constructor
[ "Resolves", "the", "Class", "constructor", "with", "the", "given", "signature", "as", "determined", "by", "the", "parameter", "types", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/factory/AbstractObjectFactory.java#L136-L151
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/factory/AbstractObjectFactory.java
AbstractObjectFactory.resolveCompatibleConstructor
@SuppressWarnings("unchecked") protected Constructor resolveCompatibleConstructor(final Class<?> objectType, final Class<?>[] parameterTypes) { for (Constructor constructor : objectType.getConstructors()) { Class[] constructorParameterTypes = constructor.getParameterTypes(); if (parameterTypes.length == constructorParameterTypes.length) { boolean match = true; for (int index = 0; index < constructorParameterTypes.length; index++) { match &= constructorParameterTypes[index].isAssignableFrom(parameterTypes[index]); } if (match) { return constructor; } } } return null; }
java
@SuppressWarnings("unchecked") protected Constructor resolveCompatibleConstructor(final Class<?> objectType, final Class<?>[] parameterTypes) { for (Constructor constructor : objectType.getConstructors()) { Class[] constructorParameterTypes = constructor.getParameterTypes(); if (parameterTypes.length == constructorParameterTypes.length) { boolean match = true; for (int index = 0; index < constructorParameterTypes.length; index++) { match &= constructorParameterTypes[index].isAssignableFrom(parameterTypes[index]); } if (match) { return constructor; } } } return null; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "Constructor", "resolveCompatibleConstructor", "(", "final", "Class", "<", "?", ">", "objectType", ",", "final", "Class", "<", "?", ">", "[", "]", "parameterTypes", ")", "{", "for", "(", "Constru...
Resolves the matching constructor for the specified Class type who's actual public constructor argument types are assignment compatible with the expected parameter types. @param objectType the Class from which the constructor is resolved. @param parameterTypes the array of Class types determining the resolved constructor's signature. @return a matching constructor from the specified Class type who's actual public constructor argument types are assignment compatible with the expected parameter types. @throws NullPointerException if either the objectType or parameterTypes are null. @see #resolveConstructor(Class, Class[]) @see java.lang.Class @see java.lang.reflect.Constructor
[ "Resolves", "the", "matching", "constructor", "for", "the", "specified", "Class", "type", "who", "s", "actual", "public", "constructor", "argument", "types", "are", "assignment", "compatible", "with", "the", "expected", "parameter", "types", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/factory/AbstractObjectFactory.java#L166-L185
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/factory/AbstractObjectFactory.java
AbstractObjectFactory.create
@Override @SuppressWarnings("unchecked") public <T> T create(final String objectTypeName, final Object... args) { return (T) create(ClassUtils.loadClass(objectTypeName), getArgumentTypes(args), args); }
java
@Override @SuppressWarnings("unchecked") public <T> T create(final String objectTypeName, final Object... args) { return (T) create(ClassUtils.loadClass(objectTypeName), getArgumentTypes(args), args); }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "create", "(", "final", "String", "objectTypeName", ",", "final", "Object", "...", "args", ")", "{", "return", "(", "T", ")", "create", "(", "ClassUtils", ...
Creates an object given the fully qualified class name, initialized with the specified constructor arguments. The parameter types of the constructor used to construct the object are determined from the arguments. @param <T> the Class type of the created object. @param objectTypeName a String indicating the fully qualified class name for the type of object to create. @param args an array of Objects used as constructor arguments to initialize the object. @return a newly created object of the given class type initialized with the specified arguments. @see #create(String, Class[], Object...) @see #getArgumentTypes(Object...) @see org.cp.elements.lang.ClassUtils#loadClass(String)
[ "Creates", "an", "object", "given", "the", "fully", "qualified", "class", "name", "initialized", "with", "the", "specified", "constructor", "arguments", ".", "The", "parameter", "types", "of", "the", "constructor", "used", "to", "construct", "the", "object", "ar...
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/factory/AbstractObjectFactory.java#L199-L203
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/factory/AbstractObjectFactory.java
AbstractObjectFactory.create
@Override public <T> T create(final Class<T> objectType, final Object... args) { return create(objectType, getArgumentTypes(args), args); }
java
@Override public <T> T create(final Class<T> objectType, final Object... args) { return create(objectType, getArgumentTypes(args), args); }
[ "@", "Override", "public", "<", "T", ">", "T", "create", "(", "final", "Class", "<", "T", ">", "objectType", ",", "final", "Object", "...", "args", ")", "{", "return", "create", "(", "objectType", ",", "getArgumentTypes", "(", "args", ")", ",", "args",...
Creates an object given the class type, initialized with the specified constructor arguments. The parameter types of the constructor used to construct the object are determined from the arguments. @param <T> the Class type of the created object. @param objectType the Class type from which the instance is created. @param args an array of Objects used as constructor arguments to initialize the object. @return a newly created object of the given class type initialized with the specified arguments. @throws ObjectInstantiationException if an error occurs during object creation. @see #create(Class, Class[], Object...) @see #getArgumentTypes(Object...) @see java.lang.Class
[ "Creates", "an", "object", "given", "the", "class", "type", "initialized", "with", "the", "specified", "constructor", "arguments", ".", "The", "parameter", "types", "of", "the", "constructor", "used", "to", "construct", "the", "object", "are", "determined", "fro...
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/factory/AbstractObjectFactory.java#L239-L242
train
mbaechler/proxy-servlet
src/main/java/com/woonoz/proxy/servlet/UrlRewriterImpl.java
UrlRewriterImpl.copyPathFragment
private static int copyPathFragment(char[] input, int beginIndex, StringBuilder output) { int inputCharIndex = beginIndex; while (inputCharIndex < input.length) { final char inputChar = input[inputCharIndex]; if (inputChar == '/') { break; } output.append(inputChar); inputCharIndex += 1; } return inputCharIndex; }
java
private static int copyPathFragment(char[] input, int beginIndex, StringBuilder output) { int inputCharIndex = beginIndex; while (inputCharIndex < input.length) { final char inputChar = input[inputCharIndex]; if (inputChar == '/') { break; } output.append(inputChar); inputCharIndex += 1; } return inputCharIndex; }
[ "private", "static", "int", "copyPathFragment", "(", "char", "[", "]", "input", ",", "int", "beginIndex", ",", "StringBuilder", "output", ")", "{", "int", "inputCharIndex", "=", "beginIndex", ";", "while", "(", "inputCharIndex", "<", "input", ".", "length", ...
Copy path fragment @param input input string @param beginIndex character index from which we look for '/' in input @param output where path fragments are appended @return last character in fragment + 1
[ "Copy", "path", "fragment" ]
0aa56fbf41b356222d4e2e257e92f2dd8ce0c6af
https://github.com/mbaechler/proxy-servlet/blob/0aa56fbf41b356222d4e2e257e92f2dd8ce0c6af/src/main/java/com/woonoz/proxy/servlet/UrlRewriterImpl.java#L266-L282
train
jsilland/piezo
src/main/java/io/soliton/protobuf/json/JsonRpcRequestInvoker.java
JsonRpcRequestInvoker.invoke
public ListenableFuture<JsonRpcResponse> invoke(JsonRpcRequest request) { Service service = services.lookupByName(request.service()); if (service == null) { JsonRpcError error = new JsonRpcError(HttpResponseStatus.BAD_REQUEST, "Unknown service: " + request.service()); JsonRpcResponse response = JsonRpcResponse.error(error); return Futures.immediateFuture(response); } ServerMethod<? extends Message, ? extends Message> method = service.lookup(request.method()); serverLogger.logMethodCall(service, method); if (method == null) { JsonRpcError error = new JsonRpcError(HttpResponseStatus.BAD_REQUEST, "Unknown method: " + request.service()); JsonRpcResponse response = JsonRpcResponse.error(error); return Futures.immediateFuture(response); } return invoke(method, request.parameter(), request.id()); }
java
public ListenableFuture<JsonRpcResponse> invoke(JsonRpcRequest request) { Service service = services.lookupByName(request.service()); if (service == null) { JsonRpcError error = new JsonRpcError(HttpResponseStatus.BAD_REQUEST, "Unknown service: " + request.service()); JsonRpcResponse response = JsonRpcResponse.error(error); return Futures.immediateFuture(response); } ServerMethod<? extends Message, ? extends Message> method = service.lookup(request.method()); serverLogger.logMethodCall(service, method); if (method == null) { JsonRpcError error = new JsonRpcError(HttpResponseStatus.BAD_REQUEST, "Unknown method: " + request.service()); JsonRpcResponse response = JsonRpcResponse.error(error); return Futures.immediateFuture(response); } return invoke(method, request.parameter(), request.id()); }
[ "public", "ListenableFuture", "<", "JsonRpcResponse", ">", "invoke", "(", "JsonRpcRequest", "request", ")", "{", "Service", "service", "=", "services", ".", "lookupByName", "(", "request", ".", "service", "(", ")", ")", ";", "if", "(", "service", "==", "null...
Executes a request. @param request the request to invoke @return a handle on the future result of the invocation
[ "Executes", "a", "request", "." ]
9a340f1460d25e07ec475dd24128b838667c959b
https://github.com/jsilland/piezo/blob/9a340f1460d25e07ec475dd24128b838667c959b/src/main/java/io/soliton/protobuf/json/JsonRpcRequestInvoker.java#L56-L77
train
jsilland/piezo
src/main/java/io/soliton/protobuf/json/JsonRpcRequestInvoker.java
JsonRpcRequestInvoker.invoke
private <I extends Message, O extends Message> ListenableFuture<JsonRpcResponse> invoke( ServerMethod<I, O> method, JsonObject parameter, JsonElement id) { I request; try { request = (I) Messages.fromJson(method.inputBuilder(), parameter); } catch (Exception e) { serverLogger.logServerFailure(method, e); SettableFuture<JsonRpcResponse> future = SettableFuture.create(); future.setException(e); return future; } ListenableFuture<O> response = method.invoke(request); return Futures.transform(response, new JsonConverter(id), TRANSFORM_EXECUTOR); }
java
private <I extends Message, O extends Message> ListenableFuture<JsonRpcResponse> invoke( ServerMethod<I, O> method, JsonObject parameter, JsonElement id) { I request; try { request = (I) Messages.fromJson(method.inputBuilder(), parameter); } catch (Exception e) { serverLogger.logServerFailure(method, e); SettableFuture<JsonRpcResponse> future = SettableFuture.create(); future.setException(e); return future; } ListenableFuture<O> response = method.invoke(request); return Futures.transform(response, new JsonConverter(id), TRANSFORM_EXECUTOR); }
[ "private", "<", "I", "extends", "Message", ",", "O", "extends", "Message", ">", "ListenableFuture", "<", "JsonRpcResponse", ">", "invoke", "(", "ServerMethod", "<", "I", ",", "O", ">", "method", ",", "JsonObject", "parameter", ",", "JsonElement", "id", ")", ...
Actually invokes the server method. @param method the method to invoke @param parameter the request's parameter @param id the request's client-side identifier @param <I> the method's input proto-type @param <O> the method's output proto-type
[ "Actually", "invokes", "the", "server", "method", "." ]
9a340f1460d25e07ec475dd24128b838667c959b
https://github.com/jsilland/piezo/blob/9a340f1460d25e07ec475dd24128b838667c959b/src/main/java/io/soliton/protobuf/json/JsonRpcRequestInvoker.java#L88-L101
train
victims/victims-lib-java
src/main/java/com/redhat/victims/fingerprint/JarFile.java
JarFile.addContent
protected synchronized void addContent(Artifact record, String filename) { if (record != null) { if (filename.endsWith(".jar")) { // this is an embedded archive embedded.add(record); } else { contents.add(record); } } }
java
protected synchronized void addContent(Artifact record, String filename) { if (record != null) { if (filename.endsWith(".jar")) { // this is an embedded archive embedded.add(record); } else { contents.add(record); } } }
[ "protected", "synchronized", "void", "addContent", "(", "Artifact", "record", ",", "String", "filename", ")", "{", "if", "(", "record", "!=", "null", ")", "{", "if", "(", "filename", ".", "endsWith", "(", "\".jar\"", ")", ")", "{", "// this is an embedded ar...
Synchronized method for adding a new conent @param record @param filename
[ "Synchronized", "method", "for", "adding", "a", "new", "conent" ]
ccd0e2fcc409bb6cdfc5de411c3bb202c9095f8b
https://github.com/victims/victims-lib-java/blob/ccd0e2fcc409bb6cdfc5de411c3bb202c9095f8b/src/main/java/com/redhat/victims/fingerprint/JarFile.java#L74-L83
train
victims/victims-lib-java
src/main/java/com/redhat/victims/fingerprint/JarFile.java
JarFile.submitJob
protected void submitJob(ExecutorService executor, Content file) { // lifted from http://stackoverflow.com/a/5853198/1874604 class OneShotTask implements Runnable { Content file; OneShotTask(Content file) { this.file = file; } public void run() { processContent(file); } } // we do not care about Future executor.submit(new OneShotTask(file)); }
java
protected void submitJob(ExecutorService executor, Content file) { // lifted from http://stackoverflow.com/a/5853198/1874604 class OneShotTask implements Runnable { Content file; OneShotTask(Content file) { this.file = file; } public void run() { processContent(file); } } // we do not care about Future executor.submit(new OneShotTask(file)); }
[ "protected", "void", "submitJob", "(", "ExecutorService", "executor", ",", "Content", "file", ")", "{", "// lifted from http://stackoverflow.com/a/5853198/1874604", "class", "OneShotTask", "implements", "Runnable", "{", "Content", "file", ";", "OneShotTask", "(", "Content...
Helper method to sumit a new threaded tast to a given executor. @param executor @param file
[ "Helper", "method", "to", "sumit", "a", "new", "threaded", "tast", "to", "a", "given", "executor", "." ]
ccd0e2fcc409bb6cdfc5de411c3bb202c9095f8b
https://github.com/victims/victims-lib-java/blob/ccd0e2fcc409bb6cdfc5de411c3bb202c9095f8b/src/main/java/com/redhat/victims/fingerprint/JarFile.java#L114-L129
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/ValueHolder.java
ValueHolder.withComparableValue
public static <T extends Comparable<T>> ComparableValueHolder<T> withComparableValue(final T value) { return new ComparableValueHolder<>(value); }
java
public static <T extends Comparable<T>> ComparableValueHolder<T> withComparableValue(final T value) { return new ComparableValueHolder<>(value); }
[ "public", "static", "<", "T", "extends", "Comparable", "<", "T", ">", ">", "ComparableValueHolder", "<", "T", ">", "withComparableValue", "(", "final", "T", "value", ")", "{", "return", "new", "ComparableValueHolder", "<>", "(", "value", ")", ";", "}" ]
Factory method to construct an instance of the ValueHolder class with a Comparable value. The ValueHolder implementation itself implements the Comparable interface. @param <T> the Class type of the Comparable value. @param value the Comparable value to hold. @return a ValueHolder implementation that holds Comparable values. @see java.lang.Comparable
[ "Factory", "method", "to", "construct", "an", "instance", "of", "the", "ValueHolder", "class", "with", "a", "Comparable", "value", ".", "The", "ValueHolder", "implementation", "itself", "implements", "the", "Comparable", "interface", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ValueHolder.java#L48-L50
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/ValueHolder.java
ValueHolder.withImmutableValue
public static <T extends Cloneable> ValueHolder<T> withImmutableValue(final T value) { return new ValueHolder<T>(ObjectUtils.clone(value)) { @Override public T getValue() { return ObjectUtils.clone(super.getValue()); } @Override public void setValue(final T value) { super.setValue(ObjectUtils.clone(value)); } }; }
java
public static <T extends Cloneable> ValueHolder<T> withImmutableValue(final T value) { return new ValueHolder<T>(ObjectUtils.clone(value)) { @Override public T getValue() { return ObjectUtils.clone(super.getValue()); } @Override public void setValue(final T value) { super.setValue(ObjectUtils.clone(value)); } }; }
[ "public", "static", "<", "T", "extends", "Cloneable", ">", "ValueHolder", "<", "T", ">", "withImmutableValue", "(", "final", "T", "value", ")", "{", "return", "new", "ValueHolder", "<", "T", ">", "(", "ObjectUtils", ".", "clone", "(", "value", ")", ")", ...
Factory method to construct an instance of the ValueHolder class with an immutable Object value. @param <T> the Class type of the Cloneable value. @param value the Cloneable, immutable value to hold. @return a ValueHolder implementation that enforces the immutability of values it holds by way of the Object.clone() method for values that implement the java.lang.Cloneable interface. @see java.lang.Cloneable
[ "Factory", "method", "to", "construct", "an", "instance", "of", "the", "ValueHolder", "class", "with", "an", "immutable", "Object", "value", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ValueHolder.java#L61-L71
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/ValueHolder.java
ValueHolder.withNonNullValue
public static <T> ValueHolder<T> withNonNullValue(final T value) { Assert.notNull(value, "The value must not be null!"); return new ValueHolder<T>(value) { @Override public void setValue(final T value) { Assert.notNull(value, "The value must not be null!"); super.setValue(value); } }; }
java
public static <T> ValueHolder<T> withNonNullValue(final T value) { Assert.notNull(value, "The value must not be null!"); return new ValueHolder<T>(value) { @Override public void setValue(final T value) { Assert.notNull(value, "The value must not be null!"); super.setValue(value); } }; }
[ "public", "static", "<", "T", ">", "ValueHolder", "<", "T", ">", "withNonNullValue", "(", "final", "T", "value", ")", "{", "Assert", ".", "notNull", "(", "value", ",", "\"The value must not be null!\"", ")", ";", "return", "new", "ValueHolder", "<", "T", "...
Factory method to construct an instance of the ValueHolder class with a non-null value. @param <T> the Class type of the Object value. @param value the non-null value to hold. @return a ValueHolder instance that enforces non-null values. @throws NullPointerException if the value is null.
[ "Factory", "method", "to", "construct", "an", "instance", "of", "the", "ValueHolder", "class", "with", "a", "non", "-", "null", "value", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/ValueHolder.java#L81-L91
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen.java
xen.reboot
public static xen reboot(nitro_service client, xen resource) throws Exception { return ((xen[]) resource.perform_operation(client, "reboot"))[0]; }
java
public static xen reboot(nitro_service client, xen resource) throws Exception { return ((xen[]) resource.perform_operation(client, "reboot"))[0]; }
[ "public", "static", "xen", "reboot", "(", "nitro_service", "client", ",", "xen", "resource", ")", "throws", "Exception", "{", "return", "(", "(", "xen", "[", "]", ")", "resource", ".", "perform_operation", "(", "client", ",", "\"reboot\"", ")", ")", "[", ...
Use this operation to reboot XenServer.
[ "Use", "this", "operation", "to", "reboot", "XenServer", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen.java#L260-L263
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen.java
xen.stop
public static xen stop(nitro_service client, xen resource) throws Exception { return ((xen[]) resource.perform_operation(client, "stop"))[0]; }
java
public static xen stop(nitro_service client, xen resource) throws Exception { return ((xen[]) resource.perform_operation(client, "stop"))[0]; }
[ "public", "static", "xen", "stop", "(", "nitro_service", "client", ",", "xen", "resource", ")", "throws", "Exception", "{", "return", "(", "(", "xen", "[", "]", ")", "resource", ".", "perform_operation", "(", "client", ",", "\"stop\"", ")", ")", "[", "0"...
Use this operation to shutdown XenServer.
[ "Use", "this", "operation", "to", "shutdown", "XenServer", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen.java#L291-L294
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen.java
xen.get_filtered
public static xen[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { xen obj = new xen(); options option = new options(); option.set_filter(filter); xen[] response = (xen[]) obj.getfiltered(service, option); return response; }
java
public static xen[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { xen obj = new xen(); options option = new options(); option.set_filter(filter); xen[] response = (xen[]) obj.getfiltered(service, option); return response; }
[ "public", "static", "xen", "[", "]", "get_filtered", "(", "nitro_service", "service", ",", "filtervalue", "[", "]", "filter", ")", "throws", "Exception", "{", "xen", "obj", "=", "new", "xen", "(", ")", ";", "options", "option", "=", "new", "options", "("...
Use this API to fetch filtered set of xen resources. set the filter parameter values in filtervalue object.
[ "Use", "this", "API", "to", "fetch", "filtered", "set", "of", "xen", "resources", ".", "set", "the", "filter", "parameter", "values", "in", "filtervalue", "object", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/xen/xen.java#L357-L364
train
netscaler/sdx_nitro
src/main/java/com/citrix/sdx/nitro/resource/config/mps/sdx_license.java
sdx_license.get
public static sdx_license get(nitro_service client) throws Exception { sdx_license resource = new sdx_license(); resource.validate("get"); return ((sdx_license[]) resource.get_resources(client))[0]; }
java
public static sdx_license get(nitro_service client) throws Exception { sdx_license resource = new sdx_license(); resource.validate("get"); return ((sdx_license[]) resource.get_resources(client))[0]; }
[ "public", "static", "sdx_license", "get", "(", "nitro_service", "client", ")", "throws", "Exception", "{", "sdx_license", "resource", "=", "new", "sdx_license", "(", ")", ";", "resource", ".", "validate", "(", "\"get\"", ")", ";", "return", "(", "(", "sdx_li...
Use this operation to get SDX license information.
[ "Use", "this", "operation", "to", "get", "SDX", "license", "information", "." ]
c840919f1a8f7c0a5634c0f23d34fa14d1765ff1
https://github.com/netscaler/sdx_nitro/blob/c840919f1a8f7c0a5634c0f23d34fa14d1765ff1/src/main/java/com/citrix/sdx/nitro/resource/config/mps/sdx_license.java#L202-L207
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/support/IsModifiedVisitor.java
IsModifiedVisitor.visit
@Override public void visit(final Visitable visitable) { if (visitable instanceof Auditable) { modified |= ((Auditable) visitable).isModified(); } }
java
@Override public void visit(final Visitable visitable) { if (visitable instanceof Auditable) { modified |= ((Auditable) visitable).isModified(); } }
[ "@", "Override", "public", "void", "visit", "(", "final", "Visitable", "visitable", ")", "{", "if", "(", "visitable", "instanceof", "Auditable", ")", "{", "modified", "|=", "(", "(", "Auditable", ")", "visitable", ")", ".", "isModified", "(", ")", ";", "...
Visits all Auditable, Visitable objects in an object graph hierarchy in search of any modified objects. @param visitable the Visitable object visited by this Visitor. @see org.cp.elements.lang.Auditable#isModified()
[ "Visits", "all", "Auditable", "Visitable", "objects", "in", "an", "object", "graph", "hierarchy", "in", "search", "of", "any", "modified", "objects", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/support/IsModifiedVisitor.java#L54-L59
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/support/FilterBuilder.java
FilterBuilder.addWithAnd
public FilterBuilder<T> addWithAnd(final Filter<T> filter) { filterInstance = ComposableFilter.and(filterInstance, filter); return this; }
java
public FilterBuilder<T> addWithAnd(final Filter<T> filter) { filterInstance = ComposableFilter.and(filterInstance, filter); return this; }
[ "public", "FilterBuilder", "<", "T", ">", "addWithAnd", "(", "final", "Filter", "<", "T", ">", "filter", ")", "{", "filterInstance", "=", "ComposableFilter", ".", "and", "(", "filterInstance", ",", "filter", ")", ";", "return", "this", ";", "}" ]
Adds the specified Filter to the composition of Filters joined using the AND operator. @param filter the Filter to add to the composition joined using the AND operator. @return this FilterBuilder instance. @see org.cp.elements.lang.Filter
[ "Adds", "the", "specified", "Filter", "to", "the", "composition", "of", "Filters", "joined", "using", "the", "AND", "operator", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/support/FilterBuilder.java#L46-L49
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/lang/support/FilterBuilder.java
FilterBuilder.addWithOr
public FilterBuilder<T> addWithOr(final Filter<T> filter) { filterInstance = ComposableFilter.or(filterInstance, filter); return this; }
java
public FilterBuilder<T> addWithOr(final Filter<T> filter) { filterInstance = ComposableFilter.or(filterInstance, filter); return this; }
[ "public", "FilterBuilder", "<", "T", ">", "addWithOr", "(", "final", "Filter", "<", "T", ">", "filter", ")", "{", "filterInstance", "=", "ComposableFilter", ".", "or", "(", "filterInstance", ",", "filter", ")", ";", "return", "this", ";", "}" ]
Adds the specified Filter to the composition of Filters joined using the OR operator. @param filter the Filter to add to the composition joined using the OR operator. @return this FilterBuilder instance. @see org.cp.elements.lang.Filter
[ "Adds", "the", "specified", "Filter", "to", "the", "composition", "of", "Filters", "joined", "using", "the", "OR", "operator", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/lang/support/FilterBuilder.java#L58-L61
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/ArrayUtils.java
ArrayUtils.filter
@SuppressWarnings("unchecked") public static <T> T[] filter(T[] array, Filter<T> filter) { Assert.notNull(array, "Array is required"); Assert.notNull(filter, "Filter is required"); List<T> arrayList = stream(array).filter(filter::accept).collect(Collectors.toList()); return arrayList.toArray((T[]) Array.newInstance(array.getClass().getComponentType(), arrayList.size())); }
java
@SuppressWarnings("unchecked") public static <T> T[] filter(T[] array, Filter<T> filter) { Assert.notNull(array, "Array is required"); Assert.notNull(filter, "Filter is required"); List<T> arrayList = stream(array).filter(filter::accept).collect(Collectors.toList()); return arrayList.toArray((T[]) Array.newInstance(array.getClass().getComponentType(), arrayList.size())); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "[", "]", "filter", "(", "T", "[", "]", "array", ",", "Filter", "<", "T", ">", "filter", ")", "{", "Assert", ".", "notNull", "(", "array", ",", "\"Array is re...
Filters the elements in the array. @param <T> Class type of the elements in the array. @param array array to filter. @param filter {@link Filter} used to filter the array elements. @return a new array of the array class component type containing only elements from the given array accepted by the {@link Filter}. @throws IllegalArgumentException if either the array or {@link Filter} are null. @see #filterAndTransform(Object[], FilteringTransformer) @see org.cp.elements.lang.Filter
[ "Filters", "the", "elements", "in", "the", "array", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/ArrayUtils.java#L348-L357
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/ArrayUtils.java
ArrayUtils.filterAndTransform
@SuppressWarnings("unchecked") public static <T> T[] filterAndTransform(T[] array, FilteringTransformer<T> filteringTransformer) { return transform(filter(array, filteringTransformer), filteringTransformer); }
java
@SuppressWarnings("unchecked") public static <T> T[] filterAndTransform(T[] array, FilteringTransformer<T> filteringTransformer) { return transform(filter(array, filteringTransformer), filteringTransformer); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "[", "]", "filterAndTransform", "(", "T", "[", "]", "array", ",", "FilteringTransformer", "<", "T", ">", "filteringTransformer", ")", "{", "return", "transform", "(",...
Filters and transforms the elements in the array. @param <T> Class type of the elements in the array. @param array array to filter and transform. @param filteringTransformer {@link FilteringTransformer} used to filter and transform the array elements. @return a new array of the array class component type containing elements from the given array filtered (accepted) and transformed by the {@link FilteringTransformer}. @throws IllegalArgumentException if either the array or {@link FilteringTransformer} are null. @see org.cp.elements.lang.FilteringTransformer @see #filter(Object[], Filter) @see #transform(Object[], Transformer)
[ "Filters", "and", "transforms", "the", "elements", "in", "the", "array", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/ArrayUtils.java#L372-L375
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/ArrayUtils.java
ArrayUtils.insert
@SuppressWarnings("unchecked") public static <T> T[] insert(T element, T[] array, int index) { Assert.notNull(array, "Array is required"); assertThat(index).throwing(new ArrayIndexOutOfBoundsException( String.format("[%1$d] is not a valid index [0, %2$d] in the array", index, array.length))) .isGreaterThanEqualToAndLessThanEqualTo(0, array.length); Class<?> componentType = array.getClass().getComponentType(); componentType = defaultIfNull(componentType, ObjectUtils.getClass(element)); componentType = defaultIfNull(componentType, Object.class); T[] newArray = (T[]) Array.newInstance(componentType, array.length + 1); if (index > 0) { System.arraycopy(array, 0, newArray, 0, index); } newArray[index] = element; if (index < array.length) { System.arraycopy(array, index, newArray, index + 1, array.length - index); } return newArray; }
java
@SuppressWarnings("unchecked") public static <T> T[] insert(T element, T[] array, int index) { Assert.notNull(array, "Array is required"); assertThat(index).throwing(new ArrayIndexOutOfBoundsException( String.format("[%1$d] is not a valid index [0, %2$d] in the array", index, array.length))) .isGreaterThanEqualToAndLessThanEqualTo(0, array.length); Class<?> componentType = array.getClass().getComponentType(); componentType = defaultIfNull(componentType, ObjectUtils.getClass(element)); componentType = defaultIfNull(componentType, Object.class); T[] newArray = (T[]) Array.newInstance(componentType, array.length + 1); if (index > 0) { System.arraycopy(array, 0, newArray, 0, index); } newArray[index] = element; if (index < array.length) { System.arraycopy(array, index, newArray, index + 1, array.length - index); } return newArray; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "[", "]", "insert", "(", "T", "element", ",", "T", "[", "]", "array", ",", "int", "index", ")", "{", "Assert", ".", "notNull", "(", "array", ",", "\"Array is ...
Inserts element into the array at index. @param <T> Class type of the elements in the array. @param element element to insert into the array. @param array array in which the element is inserted. @param index an integer indicating the index into the array at which the element will be inserted. @return a new array with element inserted at index. @throws IllegalArgumentException if array is null. @throws ArrayIndexOutOfBoundsException if given index is not a valid index in the array. @see #prepend(Object, Object[]) @see #append(Object, Object[])
[ "Inserts", "element", "into", "the", "array", "at", "index", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/ArrayUtils.java#L535-L562
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/ArrayUtils.java
ArrayUtils.remove
@SuppressWarnings("unchecked") public static <T> T[] remove(T[] array, int index) { Assert.notNull(array, "Array is required"); assertThat(index).throwing(new ArrayIndexOutOfBoundsException( String.format("[%1$d] is not a valid index [0, %2$d] in the array", index, array.length))) .isGreaterThanEqualToAndLessThan(0, array.length); Class<?> componentType = defaultIfNull(array.getClass().getComponentType(), Object.class); T[] newArray = (T[]) Array.newInstance(componentType, array.length - 1); if (index > 0) { System.arraycopy(array, 0, newArray, 0, index); } if (index + 1 < array.length) { System.arraycopy(array, index + 1, newArray, index, (array.length - index - 1)); } return newArray; }
java
@SuppressWarnings("unchecked") public static <T> T[] remove(T[] array, int index) { Assert.notNull(array, "Array is required"); assertThat(index).throwing(new ArrayIndexOutOfBoundsException( String.format("[%1$d] is not a valid index [0, %2$d] in the array", index, array.length))) .isGreaterThanEqualToAndLessThan(0, array.length); Class<?> componentType = defaultIfNull(array.getClass().getComponentType(), Object.class); T[] newArray = (T[]) Array.newInstance(componentType, array.length - 1); if (index > 0) { System.arraycopy(array, 0, newArray, 0, index); } if (index + 1 < array.length) { System.arraycopy(array, index + 1, newArray, index, (array.length - index - 1)); } return newArray; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "[", "]", "remove", "(", "T", "[", "]", "array", ",", "int", "index", ")", "{", "Assert", ".", "notNull", "(", "array", ",", "\"Array is required\"", ")", ";", ...
Removes the element at index from the given array. @param <T> {@link Class} type of the elements in the array. @param array array from which to remove the element at index. @param index index of the element to remove from the array. @return a new array with the element at index removed. @throws IllegalArgumentException if the given array is {@literal null}. @throws ArrayIndexOutOfBoundsException if the {@code index} is not valid.
[ "Removes", "the", "element", "at", "index", "from", "the", "given", "array", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/ArrayUtils.java#L676-L698
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/ArrayUtils.java
ArrayUtils.sort
public static <T> T[] sort(T[] array, Comparator<T> comparator) { Arrays.sort(array, comparator); return array; }
java
public static <T> T[] sort(T[] array, Comparator<T> comparator) { Arrays.sort(array, comparator); return array; }
[ "public", "static", "<", "T", ">", "T", "[", "]", "sort", "(", "T", "[", "]", "array", ",", "Comparator", "<", "T", ">", "comparator", ")", "{", "Arrays", ".", "sort", "(", "array", ",", "comparator", ")", ";", "return", "array", ";", "}" ]
Sorts the elements in the given array. @param <T> {@link Class} type of the elements in the array. @param array array of elements to sort. @param comparator {@link Comparator} used to sort (order) the elements in the array. @return the given array sorted. @see java.util.Comparator
[ "Sorts", "the", "elements", "in", "the", "given", "array", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/ArrayUtils.java#L770-L775
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/ArrayUtils.java
ArrayUtils.subArray
@SuppressWarnings("unchecked") public static <T> T[] subArray(T[] array, int... indices) { List<T> subArrayList = new ArrayList<>(indices.length); for (int index : indices) { subArrayList.add(array[index]); } return subArrayList.toArray((T[]) Array.newInstance(array.getClass().getComponentType(), subArrayList.size())); }
java
@SuppressWarnings("unchecked") public static <T> T[] subArray(T[] array, int... indices) { List<T> subArrayList = new ArrayList<>(indices.length); for (int index : indices) { subArrayList.add(array[index]); } return subArrayList.toArray((T[]) Array.newInstance(array.getClass().getComponentType(), subArrayList.size())); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "[", "]", "subArray", "(", "T", "[", "]", "array", ",", "int", "...", "indices", ")", "{", "List", "<", "T", ">", "subArrayList", "=", "new", "ArrayList", "<>...
Creates a sub-array from the given array with elements at the specified indices in the given array. @param <T> the Class type of the elements in the array. @param array the source array. @param indices an array of indexes to elements in the given array to include in the sub-array. @return a sub-array from the given array with elements at the specified indices in the given array. @throws ArrayIndexOutOfBoundsException if the indices are not valid indexes in the array. @throws NullPointerException if either the array or indices are null.
[ "Creates", "a", "sub", "-", "array", "from", "the", "given", "array", "with", "elements", "at", "the", "specified", "indices", "in", "the", "given", "array", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/ArrayUtils.java#L787-L797
train
codeprimate-software/cp-elements
src/main/java/org/cp/elements/util/ArrayUtils.java
ArrayUtils.swap
public static <T> T[] swap(T[] array, int indexOne, int indexTwo) { T elementAtIndexOne = array[indexOne]; array[indexOne] = array[indexTwo]; array[indexTwo] = elementAtIndexOne; return array; }
java
public static <T> T[] swap(T[] array, int indexOne, int indexTwo) { T elementAtIndexOne = array[indexOne]; array[indexOne] = array[indexTwo]; array[indexTwo] = elementAtIndexOne; return array; }
[ "public", "static", "<", "T", ">", "T", "[", "]", "swap", "(", "T", "[", "]", "array", ",", "int", "indexOne", ",", "int", "indexTwo", ")", "{", "T", "elementAtIndexOne", "=", "array", "[", "indexOne", "]", ";", "array", "[", "indexOne", "]", "=", ...
Swaps elements in the array at indexOne and indexTwo. @param <T> Class type of the elements in the array. @param array array with the elements to swap. @param indexOne index of the first element to swap. @param indexTwo index of the second element to swap. @return the array with the specified elements at indexOne and indexTwo swapped. @throws ArrayIndexOutOfBoundsException if the indexes are not valid indexes in the array. @throws NullPointerException if the array is null.
[ "Swaps", "elements", "in", "the", "array", "at", "indexOne", "and", "indexTwo", "." ]
f2163c149fbbef05015e688132064ebcac7c49ab
https://github.com/codeprimate-software/cp-elements/blob/f2163c149fbbef05015e688132064ebcac7c49ab/src/main/java/org/cp/elements/util/ArrayUtils.java#L810-L818
train
uaihebert/uaiMockServer
src/main/java/com/uaihebert/uaimockserver/log/backend/Log.java
Log.warnFormatted
public static void warnFormatted(final Exception exception) { logWriterInstance.warn(exception); UaiWebSocketLogManager.addLogText("[WARN] An exception just happened: " + exception.getMessage()); }
java
public static void warnFormatted(final Exception exception) { logWriterInstance.warn(exception); UaiWebSocketLogManager.addLogText("[WARN] An exception just happened: " + exception.getMessage()); }
[ "public", "static", "void", "warnFormatted", "(", "final", "Exception", "exception", ")", "{", "logWriterInstance", ".", "warn", "(", "exception", ")", ";", "UaiWebSocketLogManager", ".", "addLogText", "(", "\"[WARN] An exception just happened: \"", "+", "exception", ...
Wil log a text with the WARN level.
[ "Wil", "log", "a", "text", "with", "the", "WARN", "level", "." ]
8b0090d4018c2f430cfbbb3ae249347652802f2b
https://github.com/uaihebert/uaiMockServer/blob/8b0090d4018c2f430cfbbb3ae249347652802f2b/src/main/java/com/uaihebert/uaimockserver/log/backend/Log.java#L74-L78
train
jsilland/piezo
src/main/java/io/soliton/protobuf/json/Messages.java
Messages.toJson
public static JsonObject toJson(Message output) { JsonObject object = new JsonObject(); for (Map.Entry<Descriptors.FieldDescriptor, Object> field : output.getAllFields().entrySet()) { String jsonName = CaseFormat.LOWER_UNDERSCORE.to( CaseFormat.LOWER_CAMEL, field.getKey().getName()); if (field.getKey().isRepeated()) { JsonArray array = new JsonArray(); List<?> items = (List<?>) field.getValue(); for (Object item : items) { array.add(serializeField(field.getKey(), item)); } object.add(jsonName, array); } else { object.add(jsonName, serializeField(field.getKey(), field.getValue())); } } return object; }
java
public static JsonObject toJson(Message output) { JsonObject object = new JsonObject(); for (Map.Entry<Descriptors.FieldDescriptor, Object> field : output.getAllFields().entrySet()) { String jsonName = CaseFormat.LOWER_UNDERSCORE.to( CaseFormat.LOWER_CAMEL, field.getKey().getName()); if (field.getKey().isRepeated()) { JsonArray array = new JsonArray(); List<?> items = (List<?>) field.getValue(); for (Object item : items) { array.add(serializeField(field.getKey(), item)); } object.add(jsonName, array); } else { object.add(jsonName, serializeField(field.getKey(), field.getValue())); } } return object; }
[ "public", "static", "JsonObject", "toJson", "(", "Message", "output", ")", "{", "JsonObject", "object", "=", "new", "JsonObject", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "Descriptors", ".", "FieldDescriptor", ",", "Object", ">", "field", ":", ...
Converts a proto-message into an equivalent JSON representation. @param output
[ "Converts", "a", "proto", "-", "message", "into", "an", "equivalent", "JSON", "representation", "." ]
9a340f1460d25e07ec475dd24128b838667c959b
https://github.com/jsilland/piezo/blob/9a340f1460d25e07ec475dd24128b838667c959b/src/main/java/io/soliton/protobuf/json/Messages.java#L50-L67
train
jsilland/piezo
src/main/java/io/soliton/protobuf/json/Messages.java
Messages.fromJson
public static Message fromJson(Message.Builder builder, JsonObject input) throws Exception { Descriptors.Descriptor descriptor = builder.getDescriptorForType(); for (Map.Entry<String, JsonElement> entry : input.entrySet()) { String protoName = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entry.getKey()); Descriptors.FieldDescriptor field = descriptor.findFieldByName(protoName); if (field == null) { throw new Exception("Can't find descriptor for field " + protoName); } if (field.isRepeated()) { if (!entry.getValue().isJsonArray()) { // fail } JsonArray array = entry.getValue().getAsJsonArray(); for (JsonElement item : array) { builder.addRepeatedField(field, parseField(field, item, builder)); } } else { builder.setField(field, parseField(field, entry.getValue(), builder)); } } return builder.build(); }
java
public static Message fromJson(Message.Builder builder, JsonObject input) throws Exception { Descriptors.Descriptor descriptor = builder.getDescriptorForType(); for (Map.Entry<String, JsonElement> entry : input.entrySet()) { String protoName = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entry.getKey()); Descriptors.FieldDescriptor field = descriptor.findFieldByName(protoName); if (field == null) { throw new Exception("Can't find descriptor for field " + protoName); } if (field.isRepeated()) { if (!entry.getValue().isJsonArray()) { // fail } JsonArray array = entry.getValue().getAsJsonArray(); for (JsonElement item : array) { builder.addRepeatedField(field, parseField(field, item, builder)); } } else { builder.setField(field, parseField(field, entry.getValue(), builder)); } } return builder.build(); }
[ "public", "static", "Message", "fromJson", "(", "Message", ".", "Builder", "builder", ",", "JsonObject", "input", ")", "throws", "Exception", "{", "Descriptors", ".", "Descriptor", "descriptor", "=", "builder", ".", "getDescriptorForType", "(", ")", ";", "for", ...
Converts a JSON object to a protobuf message @param builder the proto message type builder @param input the JSON object to convert
[ "Converts", "a", "JSON", "object", "to", "a", "protobuf", "message" ]
9a340f1460d25e07ec475dd24128b838667c959b
https://github.com/jsilland/piezo/blob/9a340f1460d25e07ec475dd24128b838667c959b/src/main/java/io/soliton/protobuf/json/Messages.java#L110-L131
train