id
int32 0
165k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
154,800
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java
|
QueryCriterionSerializer.filterDelimeterElement
|
private static List<String> filterDelimeterElement(List<String> arr, char[] delimeter){
List<String> list = new ArrayList<String>();
for(String s : arr){
if(s == null || s.isEmpty()){
continue;
}
if(s.length() > 1){
list.add(s);
continue;
}
char strChar = s.charAt(0);
boolean find = false;
for(char c : delimeter){
if(c == strChar){
find = true;
break;
}
}
if(find == false){
list.add(s);
}
}
return list;
}
|
java
|
private static List<String> filterDelimeterElement(List<String> arr, char[] delimeter){
List<String> list = new ArrayList<String>();
for(String s : arr){
if(s == null || s.isEmpty()){
continue;
}
if(s.length() > 1){
list.add(s);
continue;
}
char strChar = s.charAt(0);
boolean find = false;
for(char c : delimeter){
if(c == strChar){
find = true;
break;
}
}
if(find == false){
list.add(s);
}
}
return list;
}
|
[
"private",
"static",
"List",
"<",
"String",
">",
"filterDelimeterElement",
"(",
"List",
"<",
"String",
">",
"arr",
",",
"char",
"[",
"]",
"delimeter",
")",
"{",
"List",
"<",
"String",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"String",
"s",
":",
"arr",
")",
"{",
"if",
"(",
"s",
"==",
"null",
"||",
"s",
".",
"isEmpty",
"(",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"s",
".",
"length",
"(",
")",
">",
"1",
")",
"{",
"list",
".",
"add",
"(",
"s",
")",
";",
"continue",
";",
"}",
"char",
"strChar",
"=",
"s",
".",
"charAt",
"(",
"0",
")",
";",
"boolean",
"find",
"=",
"false",
";",
"for",
"(",
"char",
"c",
":",
"delimeter",
")",
"{",
"if",
"(",
"c",
"==",
"strChar",
")",
"{",
"find",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"find",
"==",
"false",
")",
"{",
"list",
".",
"add",
"(",
"s",
")",
";",
"}",
"}",
"return",
"list",
";",
"}"
] |
Filter the delimeter from the String array.
remove the String element in the delimeter.
@param arr
the target array.
@param delimeter
the delimeter array need to remove.
@return
the array List.
|
[
"Filter",
"the",
"delimeter",
"from",
"the",
"String",
"array",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java#L261-L284
|
154,801
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java
|
QueryCriterionSerializer.splitStringByDelimeters
|
private static List<String> splitStringByDelimeters(String str, char[] delimeter, boolean includeDeli){
List<String> arr = new ArrayList<String>();
int i = 0, start = 0, quota = 0;
char pre = 0;
for(char c : str.toCharArray()){
if(c == '"' && pre != '\\'){
quota ++;
}
if(quota % 2 == 0){
for(char deli : delimeter){
if( c == deli){
if(includeDeli){
arr.add(str.substring(start, i).trim());
start = i;
}else if(i > start ){
arr.add(str.substring(start, i).trim());
start = i + 1;
}
}
}
}
i ++;
pre = c;
}
if(includeDeli){
arr.add(str.substring(start, i).trim());
start = i;
}else if(i > start ){
arr.add(str.substring(start, i).trim());
}
return arr;
}
|
java
|
private static List<String> splitStringByDelimeters(String str, char[] delimeter, boolean includeDeli){
List<String> arr = new ArrayList<String>();
int i = 0, start = 0, quota = 0;
char pre = 0;
for(char c : str.toCharArray()){
if(c == '"' && pre != '\\'){
quota ++;
}
if(quota % 2 == 0){
for(char deli : delimeter){
if( c == deli){
if(includeDeli){
arr.add(str.substring(start, i).trim());
start = i;
}else if(i > start ){
arr.add(str.substring(start, i).trim());
start = i + 1;
}
}
}
}
i ++;
pre = c;
}
if(includeDeli){
arr.add(str.substring(start, i).trim());
start = i;
}else if(i > start ){
arr.add(str.substring(start, i).trim());
}
return arr;
}
|
[
"private",
"static",
"List",
"<",
"String",
">",
"splitStringByDelimeters",
"(",
"String",
"str",
",",
"char",
"[",
"]",
"delimeter",
",",
"boolean",
"includeDeli",
")",
"{",
"List",
"<",
"String",
">",
"arr",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"int",
"i",
"=",
"0",
",",
"start",
"=",
"0",
",",
"quota",
"=",
"0",
";",
"char",
"pre",
"=",
"0",
";",
"for",
"(",
"char",
"c",
":",
"str",
".",
"toCharArray",
"(",
")",
")",
"{",
"if",
"(",
"c",
"==",
"'",
"'",
"&&",
"pre",
"!=",
"'",
"'",
")",
"{",
"quota",
"++",
";",
"}",
"if",
"(",
"quota",
"%",
"2",
"==",
"0",
")",
"{",
"for",
"(",
"char",
"deli",
":",
"delimeter",
")",
"{",
"if",
"(",
"c",
"==",
"deli",
")",
"{",
"if",
"(",
"includeDeli",
")",
"{",
"arr",
".",
"add",
"(",
"str",
".",
"substring",
"(",
"start",
",",
"i",
")",
".",
"trim",
"(",
")",
")",
";",
"start",
"=",
"i",
";",
"}",
"else",
"if",
"(",
"i",
">",
"start",
")",
"{",
"arr",
".",
"add",
"(",
"str",
".",
"substring",
"(",
"start",
",",
"i",
")",
".",
"trim",
"(",
")",
")",
";",
"start",
"=",
"i",
"+",
"1",
";",
"}",
"}",
"}",
"}",
"i",
"++",
";",
"pre",
"=",
"c",
";",
"}",
"if",
"(",
"includeDeli",
")",
"{",
"arr",
".",
"add",
"(",
"str",
".",
"substring",
"(",
"start",
",",
"i",
")",
".",
"trim",
"(",
")",
")",
";",
"start",
"=",
"i",
";",
"}",
"else",
"if",
"(",
"i",
">",
"start",
")",
"{",
"arr",
".",
"add",
"(",
"str",
".",
"substring",
"(",
"start",
",",
"i",
")",
".",
"trim",
"(",
")",
")",
";",
"}",
"return",
"arr",
";",
"}"
] |
Split a complete String to String array by the delimeter array.
This method used to split a command or a statement to sub elements.
It will trim the sub elements too.
@param str
the complete string.
@param delimeter
the delimeter array.
@param includeDeli
if true, include the delimeter in the return array.
@return
the splited String array.
|
[
"Split",
"a",
"complete",
"String",
"to",
"String",
"array",
"by",
"the",
"delimeter",
"array",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java#L301-L336
|
154,802
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrieSerializer.java
|
CharTrieSerializer.deserialize
|
public CharTrie deserialize(byte[] bytes) {
CharTrie trie = new CharTrie();
BitInputStream in = new BitInputStream(new ByteArrayInputStream(bytes));
int level = 0;
while (deserialize(trie.root(), in, level++) > 0) {
}
trie.recomputeCursorDetails();
return trie;
}
|
java
|
public CharTrie deserialize(byte[] bytes) {
CharTrie trie = new CharTrie();
BitInputStream in = new BitInputStream(new ByteArrayInputStream(bytes));
int level = 0;
while (deserialize(trie.root(), in, level++) > 0) {
}
trie.recomputeCursorDetails();
return trie;
}
|
[
"public",
"CharTrie",
"deserialize",
"(",
"byte",
"[",
"]",
"bytes",
")",
"{",
"CharTrie",
"trie",
"=",
"new",
"CharTrie",
"(",
")",
";",
"BitInputStream",
"in",
"=",
"new",
"BitInputStream",
"(",
"new",
"ByteArrayInputStream",
"(",
"bytes",
")",
")",
";",
"int",
"level",
"=",
"0",
";",
"while",
"(",
"deserialize",
"(",
"trie",
".",
"root",
"(",
")",
",",
"in",
",",
"level",
"++",
")",
">",
"0",
")",
"{",
"}",
"trie",
".",
"recomputeCursorDetails",
"(",
")",
";",
"return",
"trie",
";",
"}"
] |
Deserialize char trie.
@param bytes the bytes
@return the char trie
|
[
"Deserialize",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrieSerializer.java#L112-L120
|
154,803
|
iorga-group/iraj
|
irajblank-web/src/main/java/com/iorga/irajblank/ws/HomeWS.java
|
HomeWS.getFileName
|
private String getFileName(MultivaluedMap<String, String> header) {
String[] contentDisposition = header.getFirst("Content-Disposition").split(";");
for (String filename : contentDisposition) {
if ((filename.trim().startsWith("filename"))) {
String[] name = filename.split("=");
String finalFileName = name[1].trim().replaceAll("\"", "");
return finalFileName;
}
}
return "unknown";
}
|
java
|
private String getFileName(MultivaluedMap<String, String> header) {
String[] contentDisposition = header.getFirst("Content-Disposition").split(";");
for (String filename : contentDisposition) {
if ((filename.trim().startsWith("filename"))) {
String[] name = filename.split("=");
String finalFileName = name[1].trim().replaceAll("\"", "");
return finalFileName;
}
}
return "unknown";
}
|
[
"private",
"String",
"getFileName",
"(",
"MultivaluedMap",
"<",
"String",
",",
"String",
">",
"header",
")",
"{",
"String",
"[",
"]",
"contentDisposition",
"=",
"header",
".",
"getFirst",
"(",
"\"Content-Disposition\"",
")",
".",
"split",
"(",
"\";\"",
")",
";",
"for",
"(",
"String",
"filename",
":",
"contentDisposition",
")",
"{",
"if",
"(",
"(",
"filename",
".",
"trim",
"(",
")",
".",
"startsWith",
"(",
"\"filename\"",
")",
")",
")",
"{",
"String",
"[",
"]",
"name",
"=",
"filename",
".",
"split",
"(",
"\"=\"",
")",
";",
"String",
"finalFileName",
"=",
"name",
"[",
"1",
"]",
".",
"trim",
"(",
")",
".",
"replaceAll",
"(",
"\"\\\"\"",
",",
"\"\"",
")",
";",
"return",
"finalFileName",
";",
"}",
"}",
"return",
"\"unknown\"",
";",
"}"
] |
get uploaded filename, is there a easy way in RESTEasy?
|
[
"get",
"uploaded",
"filename",
"is",
"there",
"a",
"easy",
"way",
"in",
"RESTEasy?"
] |
5fdee26464248f29833610de402275eb64505542
|
https://github.com/iorga-group/iraj/blob/5fdee26464248f29833610de402275eb64505542/irajblank-web/src/main/java/com/iorga/irajblank/ws/HomeWS.java#L69-L83
|
154,804
|
ksclarke/vertx-pairtree
|
src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java
|
FsPairtree.checkVersion
|
private void checkVersion(final Future<Boolean> aFuture) {
final String versionFilePath = getVersionFilePath();
myFileSystem.exists(versionFilePath, result -> {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_007, versionFilePath);
}
if (result.succeeded()) {
if (result.result()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_008, versionFilePath);
}
checkPrefix(aFuture);
} else {
aFuture.complete(!result.result());
}
} else {
aFuture.fail(result.cause());
}
});
}
|
java
|
private void checkVersion(final Future<Boolean> aFuture) {
final String versionFilePath = getVersionFilePath();
myFileSystem.exists(versionFilePath, result -> {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_007, versionFilePath);
}
if (result.succeeded()) {
if (result.result()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_008, versionFilePath);
}
checkPrefix(aFuture);
} else {
aFuture.complete(!result.result());
}
} else {
aFuture.fail(result.cause());
}
});
}
|
[
"private",
"void",
"checkVersion",
"(",
"final",
"Future",
"<",
"Boolean",
">",
"aFuture",
")",
"{",
"final",
"String",
"versionFilePath",
"=",
"getVersionFilePath",
"(",
")",
";",
"myFileSystem",
".",
"exists",
"(",
"versionFilePath",
",",
"result",
"->",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"PT_DEBUG_007",
",",
"versionFilePath",
")",
";",
"}",
"if",
"(",
"result",
".",
"succeeded",
"(",
")",
")",
"{",
"if",
"(",
"result",
".",
"result",
"(",
")",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"PT_DEBUG_008",
",",
"versionFilePath",
")",
";",
"}",
"checkPrefix",
"(",
"aFuture",
")",
";",
"}",
"else",
"{",
"aFuture",
".",
"complete",
"(",
"!",
"result",
".",
"result",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"aFuture",
".",
"fail",
"(",
"result",
".",
"cause",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Checks that Pairtree version file exists.
@param aFuture The result of an action that may, or may not, have occurred yet.
|
[
"Checks",
"that",
"Pairtree",
"version",
"file",
"exists",
"."
] |
b2ea1e32057e5df262e9265540d346a732b718df
|
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java#L175-L197
|
154,805
|
ksclarke/vertx-pairtree
|
src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java
|
FsPairtree.checkPrefix
|
private void checkPrefix(final Future<Boolean> aFuture) {
final String prefixFilePath = getPrefixFilePath();
myFileSystem.exists(prefixFilePath, result -> {
if (result.succeeded()) {
if (hasPrefix()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_035, prefixFilePath);
}
if (result.result()) {
aFuture.complete(result.result());
} else {
aFuture.fail(new PairtreeException(MessageCodes.PT_013, prefixFilePath));
}
} else {
LOGGER.debug(MessageCodes.PT_DEBUG_009, prefixFilePath);
if (result.result()) {
aFuture.fail(new PairtreeException(MessageCodes.PT_014, prefixFilePath));
} else {
aFuture.complete(!result.result());
}
}
} else {
aFuture.fail(result.cause());
}
});
}
|
java
|
private void checkPrefix(final Future<Boolean> aFuture) {
final String prefixFilePath = getPrefixFilePath();
myFileSystem.exists(prefixFilePath, result -> {
if (result.succeeded()) {
if (hasPrefix()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_035, prefixFilePath);
}
if (result.result()) {
aFuture.complete(result.result());
} else {
aFuture.fail(new PairtreeException(MessageCodes.PT_013, prefixFilePath));
}
} else {
LOGGER.debug(MessageCodes.PT_DEBUG_009, prefixFilePath);
if (result.result()) {
aFuture.fail(new PairtreeException(MessageCodes.PT_014, prefixFilePath));
} else {
aFuture.complete(!result.result());
}
}
} else {
aFuture.fail(result.cause());
}
});
}
|
[
"private",
"void",
"checkPrefix",
"(",
"final",
"Future",
"<",
"Boolean",
">",
"aFuture",
")",
"{",
"final",
"String",
"prefixFilePath",
"=",
"getPrefixFilePath",
"(",
")",
";",
"myFileSystem",
".",
"exists",
"(",
"prefixFilePath",
",",
"result",
"->",
"{",
"if",
"(",
"result",
".",
"succeeded",
"(",
")",
")",
"{",
"if",
"(",
"hasPrefix",
"(",
")",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"PT_DEBUG_035",
",",
"prefixFilePath",
")",
";",
"}",
"if",
"(",
"result",
".",
"result",
"(",
")",
")",
"{",
"aFuture",
".",
"complete",
"(",
"result",
".",
"result",
"(",
")",
")",
";",
"}",
"else",
"{",
"aFuture",
".",
"fail",
"(",
"new",
"PairtreeException",
"(",
"MessageCodes",
".",
"PT_013",
",",
"prefixFilePath",
")",
")",
";",
"}",
"}",
"else",
"{",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"PT_DEBUG_009",
",",
"prefixFilePath",
")",
";",
"if",
"(",
"result",
".",
"result",
"(",
")",
")",
"{",
"aFuture",
".",
"fail",
"(",
"new",
"PairtreeException",
"(",
"MessageCodes",
".",
"PT_014",
",",
"prefixFilePath",
")",
")",
";",
"}",
"else",
"{",
"aFuture",
".",
"complete",
"(",
"!",
"result",
".",
"result",
"(",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"aFuture",
".",
"fail",
"(",
"result",
".",
"cause",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Checks whether a Pairtree prefix file exists.
@param aFuture The result of an action that may, or may not, have occurred yet.
|
[
"Checks",
"whether",
"a",
"Pairtree",
"prefix",
"file",
"exists",
"."
] |
b2ea1e32057e5df262e9265540d346a732b718df
|
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java#L204-L232
|
154,806
|
ksclarke/vertx-pairtree
|
src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java
|
FsPairtree.deleteVersion
|
private void deleteVersion(final Future<Void> aFuture) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_006, myPath);
}
myFileSystem.delete(getVersionFilePath(), result -> {
if (result.succeeded()) {
if (hasPrefix()) {
deletePrefix(aFuture);
} else {
aFuture.complete();
}
} else {
aFuture.fail(result.cause());
}
});
}
|
java
|
private void deleteVersion(final Future<Void> aFuture) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_006, myPath);
}
myFileSystem.delete(getVersionFilePath(), result -> {
if (result.succeeded()) {
if (hasPrefix()) {
deletePrefix(aFuture);
} else {
aFuture.complete();
}
} else {
aFuture.fail(result.cause());
}
});
}
|
[
"private",
"void",
"deleteVersion",
"(",
"final",
"Future",
"<",
"Void",
">",
"aFuture",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"PT_DEBUG_006",
",",
"myPath",
")",
";",
"}",
"myFileSystem",
".",
"delete",
"(",
"getVersionFilePath",
"(",
")",
",",
"result",
"->",
"{",
"if",
"(",
"result",
".",
"succeeded",
"(",
")",
")",
"{",
"if",
"(",
"hasPrefix",
"(",
")",
")",
"{",
"deletePrefix",
"(",
"aFuture",
")",
";",
"}",
"else",
"{",
"aFuture",
".",
"complete",
"(",
")",
";",
"}",
"}",
"else",
"{",
"aFuture",
".",
"fail",
"(",
"result",
".",
"cause",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Deletes a Pairtree version file.
@param aFuture The result of an action that may, or may not, have occurred yet.
|
[
"Deletes",
"a",
"Pairtree",
"version",
"file",
"."
] |
b2ea1e32057e5df262e9265540d346a732b718df
|
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java#L239-L255
|
154,807
|
ksclarke/vertx-pairtree
|
src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java
|
FsPairtree.deletePrefix
|
private void deletePrefix(final Future<Void> aFuture) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_034, myPath);
}
myFileSystem.delete(getPrefixFilePath(), result -> {
if (result.succeeded()) {
aFuture.complete();
} else {
aFuture.fail(result.cause());
}
});
}
|
java
|
private void deletePrefix(final Future<Void> aFuture) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_034, myPath);
}
myFileSystem.delete(getPrefixFilePath(), result -> {
if (result.succeeded()) {
aFuture.complete();
} else {
aFuture.fail(result.cause());
}
});
}
|
[
"private",
"void",
"deletePrefix",
"(",
"final",
"Future",
"<",
"Void",
">",
"aFuture",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"PT_DEBUG_034",
",",
"myPath",
")",
";",
"}",
"myFileSystem",
".",
"delete",
"(",
"getPrefixFilePath",
"(",
")",
",",
"result",
"->",
"{",
"if",
"(",
"result",
".",
"succeeded",
"(",
")",
")",
"{",
"aFuture",
".",
"complete",
"(",
")",
";",
"}",
"else",
"{",
"aFuture",
".",
"fail",
"(",
"result",
".",
"cause",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Deletes a Pairtree prefix file.
@param aFuture The result of an action that may, or may not, have occurred yet.
|
[
"Deletes",
"a",
"Pairtree",
"prefix",
"file",
"."
] |
b2ea1e32057e5df262e9265540d346a732b718df
|
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java#L262-L274
|
154,808
|
ksclarke/vertx-pairtree
|
src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java
|
FsPairtree.setVersion
|
private void setVersion(final Future<Void> aFuture) {
final StringBuilder specNote = new StringBuilder();
final String ptVersion = LOGGER.getMessage(MessageCodes.PT_011, PT_VERSION_NUM);
final String urlString = LOGGER.getMessage(MessageCodes.PT_012);
specNote.append(ptVersion).append(System.lineSeparator()).append(urlString);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_005, myPath);
}
myFileSystem.writeFile(getVersionFilePath(), Buffer.buffer(specNote.toString()), result -> {
if (result.succeeded()) {
if (hasPrefix()) {
setPrefix(aFuture);
} else {
aFuture.complete();
}
} else {
aFuture.fail(result.cause());
}
});
}
|
java
|
private void setVersion(final Future<Void> aFuture) {
final StringBuilder specNote = new StringBuilder();
final String ptVersion = LOGGER.getMessage(MessageCodes.PT_011, PT_VERSION_NUM);
final String urlString = LOGGER.getMessage(MessageCodes.PT_012);
specNote.append(ptVersion).append(System.lineSeparator()).append(urlString);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_005, myPath);
}
myFileSystem.writeFile(getVersionFilePath(), Buffer.buffer(specNote.toString()), result -> {
if (result.succeeded()) {
if (hasPrefix()) {
setPrefix(aFuture);
} else {
aFuture.complete();
}
} else {
aFuture.fail(result.cause());
}
});
}
|
[
"private",
"void",
"setVersion",
"(",
"final",
"Future",
"<",
"Void",
">",
"aFuture",
")",
"{",
"final",
"StringBuilder",
"specNote",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"String",
"ptVersion",
"=",
"LOGGER",
".",
"getMessage",
"(",
"MessageCodes",
".",
"PT_011",
",",
"PT_VERSION_NUM",
")",
";",
"final",
"String",
"urlString",
"=",
"LOGGER",
".",
"getMessage",
"(",
"MessageCodes",
".",
"PT_012",
")",
";",
"specNote",
".",
"append",
"(",
"ptVersion",
")",
".",
"append",
"(",
"System",
".",
"lineSeparator",
"(",
")",
")",
".",
"append",
"(",
"urlString",
")",
";",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"PT_DEBUG_005",
",",
"myPath",
")",
";",
"}",
"myFileSystem",
".",
"writeFile",
"(",
"getVersionFilePath",
"(",
")",
",",
"Buffer",
".",
"buffer",
"(",
"specNote",
".",
"toString",
"(",
")",
")",
",",
"result",
"->",
"{",
"if",
"(",
"result",
".",
"succeeded",
"(",
")",
")",
"{",
"if",
"(",
"hasPrefix",
"(",
")",
")",
"{",
"setPrefix",
"(",
"aFuture",
")",
";",
"}",
"else",
"{",
"aFuture",
".",
"complete",
"(",
")",
";",
"}",
"}",
"else",
"{",
"aFuture",
".",
"fail",
"(",
"result",
".",
"cause",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates a Pairtree version file.
@param aFuture The result of an action that may, or may not, have occurred yet.
|
[
"Creates",
"a",
"Pairtree",
"version",
"file",
"."
] |
b2ea1e32057e5df262e9265540d346a732b718df
|
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java#L281-L303
|
154,809
|
ksclarke/vertx-pairtree
|
src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java
|
FsPairtree.setPrefix
|
private void setPrefix(final Future<Void> aFuture) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_033, myPath);
}
myFileSystem.writeFile(getPrefixFilePath(), Buffer.buffer(myPrefix.get()), result -> {
if (result.succeeded()) {
aFuture.complete();
} else {
aFuture.fail(result.cause());
}
});
}
|
java
|
private void setPrefix(final Future<Void> aFuture) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(MessageCodes.PT_DEBUG_033, myPath);
}
myFileSystem.writeFile(getPrefixFilePath(), Buffer.buffer(myPrefix.get()), result -> {
if (result.succeeded()) {
aFuture.complete();
} else {
aFuture.fail(result.cause());
}
});
}
|
[
"private",
"void",
"setPrefix",
"(",
"final",
"Future",
"<",
"Void",
">",
"aFuture",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"MessageCodes",
".",
"PT_DEBUG_033",
",",
"myPath",
")",
";",
"}",
"myFileSystem",
".",
"writeFile",
"(",
"getPrefixFilePath",
"(",
")",
",",
"Buffer",
".",
"buffer",
"(",
"myPrefix",
".",
"get",
"(",
")",
")",
",",
"result",
"->",
"{",
"if",
"(",
"result",
".",
"succeeded",
"(",
")",
")",
"{",
"aFuture",
".",
"complete",
"(",
")",
";",
"}",
"else",
"{",
"aFuture",
".",
"fail",
"(",
"result",
".",
"cause",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Creates a Pairtree prefix file.
@param aFuture The result of an action that may, or may not, have occurred yet.
|
[
"Creates",
"a",
"Pairtree",
"prefix",
"file",
"."
] |
b2ea1e32057e5df262e9265540d346a732b718df
|
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/fs/FsPairtree.java#L310-L322
|
154,810
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/FileWatcher.java
|
FileWatcher.weakAddWatcher
|
@Deprecated
public void weakAddWatcher(Listener watcher) {
if (watcher == null) {
throw new IllegalArgumentException("Null watcher added");
}
synchronized (mutex) {
if (watcherExecutor.isShutdown()) {
throw new IllegalStateException("Adding watcher on closed FileWatcher");
}
watchers.add(new WeakReference<>(watcher)::get);
}
}
|
java
|
@Deprecated
public void weakAddWatcher(Listener watcher) {
if (watcher == null) {
throw new IllegalArgumentException("Null watcher added");
}
synchronized (mutex) {
if (watcherExecutor.isShutdown()) {
throw new IllegalStateException("Adding watcher on closed FileWatcher");
}
watchers.add(new WeakReference<>(watcher)::get);
}
}
|
[
"@",
"Deprecated",
"public",
"void",
"weakAddWatcher",
"(",
"Listener",
"watcher",
")",
"{",
"if",
"(",
"watcher",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Null watcher added\"",
")",
";",
"}",
"synchronized",
"(",
"mutex",
")",
"{",
"if",
"(",
"watcherExecutor",
".",
"isShutdown",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Adding watcher on closed FileWatcher\"",
")",
";",
"}",
"watchers",
".",
"add",
"(",
"new",
"WeakReference",
"<>",
"(",
"watcher",
")",
"::",
"get",
")",
";",
"}",
"}"
] |
Add a non-persistent file watcher.
@param watcher The watcher to add.
@deprecated Use {@link #weakAddWatcher(File, Listener)}.
|
[
"Add",
"a",
"non",
"-",
"persistent",
"file",
"watcher",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/FileWatcher.java#L313-L325
|
154,811
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/FileWatcher.java
|
FileWatcher.removeWatcher
|
public boolean removeWatcher(Listener watcher) {
if (watcher == null) {
throw new IllegalArgumentException("Null watcher removed");
}
synchronized (mutex) {
AtomicBoolean removed = new AtomicBoolean(removeFromListeners(watchers, watcher));
watchedFiles.forEach((path, suppliers) -> {
if (removeFromListeners(suppliers, watcher)) {
removed.set(true);
}
});
return removed.get();
}
}
|
java
|
public boolean removeWatcher(Listener watcher) {
if (watcher == null) {
throw new IllegalArgumentException("Null watcher removed");
}
synchronized (mutex) {
AtomicBoolean removed = new AtomicBoolean(removeFromListeners(watchers, watcher));
watchedFiles.forEach((path, suppliers) -> {
if (removeFromListeners(suppliers, watcher)) {
removed.set(true);
}
});
return removed.get();
}
}
|
[
"public",
"boolean",
"removeWatcher",
"(",
"Listener",
"watcher",
")",
"{",
"if",
"(",
"watcher",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Null watcher removed\"",
")",
";",
"}",
"synchronized",
"(",
"mutex",
")",
"{",
"AtomicBoolean",
"removed",
"=",
"new",
"AtomicBoolean",
"(",
"removeFromListeners",
"(",
"watchers",
",",
"watcher",
")",
")",
";",
"watchedFiles",
".",
"forEach",
"(",
"(",
"path",
",",
"suppliers",
")",
"->",
"{",
"if",
"(",
"removeFromListeners",
"(",
"suppliers",
",",
"watcher",
")",
")",
"{",
"removed",
".",
"set",
"(",
"true",
")",
";",
"}",
"}",
")",
";",
"return",
"removed",
".",
"get",
"(",
")",
";",
"}",
"}"
] |
Remove a watcher from the list of listeners.
@param watcher The watcher to be removed.
@return True if the watcher was removed from the list.
|
[
"Remove",
"a",
"watcher",
"from",
"the",
"list",
"of",
"listeners",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/FileWatcher.java#L344-L358
|
154,812
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/FileWatcher.java
|
FileWatcher.startWatching
|
@Deprecated
public void startWatching(File file) {
if (file == null) {
throw new IllegalArgumentException("Null file argument");
}
synchronized (mutex) {
startWatchingInternal(file.toPath());
}
}
|
java
|
@Deprecated
public void startWatching(File file) {
if (file == null) {
throw new IllegalArgumentException("Null file argument");
}
synchronized (mutex) {
startWatchingInternal(file.toPath());
}
}
|
[
"@",
"Deprecated",
"public",
"void",
"startWatching",
"(",
"File",
"file",
")",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Null file argument\"",
")",
";",
"}",
"synchronized",
"(",
"mutex",
")",
"{",
"startWatchingInternal",
"(",
"file",
".",
"toPath",
"(",
")",
")",
";",
"}",
"}"
] |
Start watching a specific file. Note that this will watch the
file as seen in the directory as it is pointed to. This means that
if the file itself is a symlink, then change events will notify
changes to the symlink definition, not the content of the file.
@param file The file to be watched.
@deprecated Use {@link #addWatcher(File, Listener)} or {@link #weakAddWatcher(File, Listener)}
|
[
"Start",
"watching",
"a",
"specific",
"file",
".",
"Note",
"that",
"this",
"will",
"watch",
"the",
"file",
"as",
"seen",
"in",
"the",
"directory",
"as",
"it",
"is",
"pointed",
"to",
".",
"This",
"means",
"that",
"if",
"the",
"file",
"itself",
"is",
"a",
"symlink",
"then",
"change",
"events",
"will",
"notify",
"changes",
"to",
"the",
"symlink",
"definition",
"not",
"the",
"content",
"of",
"the",
"file",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/FileWatcher.java#L369-L377
|
154,813
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/FileWatcher.java
|
FileWatcher.stopWatching
|
@Deprecated
public void stopWatching(File file) {
if (file == null) {
throw new IllegalArgumentException("Null file argument");
}
synchronized (mutex) {
stopWatchingInternal(file.toPath());
}
}
|
java
|
@Deprecated
public void stopWatching(File file) {
if (file == null) {
throw new IllegalArgumentException("Null file argument");
}
synchronized (mutex) {
stopWatchingInternal(file.toPath());
}
}
|
[
"@",
"Deprecated",
"public",
"void",
"stopWatching",
"(",
"File",
"file",
")",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Null file argument\"",
")",
";",
"}",
"synchronized",
"(",
"mutex",
")",
"{",
"stopWatchingInternal",
"(",
"file",
".",
"toPath",
"(",
")",
")",
";",
"}",
"}"
] |
Stop watching a specific file.
@param file The file to be watched.
@deprecated Use {@link #removeWatcher(Listener)} and let it clean up watched
files itself.
|
[
"Stop",
"watching",
"a",
"specific",
"file",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/FileWatcher.java#L386-L394
|
154,814
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/random/RandomText.java
|
RandomText.phrase
|
public static String phrase(int minSize, int maxSize) {
maxSize = Math.max(minSize, maxSize);
int size = RandomInteger.nextInteger(minSize, maxSize);
if (size <= 0) return "";
StringBuilder result = new StringBuilder();
result.append(RandomString.pick(_allWords));
while (result.length() < size) {
result.append(" ").append(RandomString.pick(_allWords).toLowerCase());
}
return result.toString();
}
|
java
|
public static String phrase(int minSize, int maxSize) {
maxSize = Math.max(minSize, maxSize);
int size = RandomInteger.nextInteger(minSize, maxSize);
if (size <= 0) return "";
StringBuilder result = new StringBuilder();
result.append(RandomString.pick(_allWords));
while (result.length() < size) {
result.append(" ").append(RandomString.pick(_allWords).toLowerCase());
}
return result.toString();
}
|
[
"public",
"static",
"String",
"phrase",
"(",
"int",
"minSize",
",",
"int",
"maxSize",
")",
"{",
"maxSize",
"=",
"Math",
".",
"max",
"(",
"minSize",
",",
"maxSize",
")",
";",
"int",
"size",
"=",
"RandomInteger",
".",
"nextInteger",
"(",
"minSize",
",",
"maxSize",
")",
";",
"if",
"(",
"size",
"<=",
"0",
")",
"return",
"\"\"",
";",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"result",
".",
"append",
"(",
"RandomString",
".",
"pick",
"(",
"_allWords",
")",
")",
";",
"while",
"(",
"result",
".",
"length",
"(",
")",
"<",
"size",
")",
"{",
"result",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"RandomString",
".",
"pick",
"(",
"_allWords",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Generates a random phrase which consists of few words separated by spaces.
The first word is capitalized, others are not.
@param minSize (optional) minimum string length.
@param maxSize maximum string length.
@return a random phrase.
|
[
"Generates",
"a",
"random",
"phrase",
"which",
"consists",
"of",
"few",
"words",
"separated",
"by",
"spaces",
".",
"The",
"first",
"word",
"is",
"capitalized",
"others",
"are",
"not",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/random/RandomText.java#L143-L155
|
154,815
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/random/RandomText.java
|
RandomText.fullName
|
public static String fullName() {
StringBuilder result = new StringBuilder();
if (RandomBoolean.chance(3, 5))
result.append(RandomString.pick(_namePrefixes)).append(" ");
result.append(RandomString.pick(_firstNames))
.append(" ")
.append(RandomString.pick(_lastNames));
if (RandomBoolean.chance(5, 10))
result.append(" ").append(RandomString.pick(_nameSuffixes));
return result.toString();
}
|
java
|
public static String fullName() {
StringBuilder result = new StringBuilder();
if (RandomBoolean.chance(3, 5))
result.append(RandomString.pick(_namePrefixes)).append(" ");
result.append(RandomString.pick(_firstNames))
.append(" ")
.append(RandomString.pick(_lastNames));
if (RandomBoolean.chance(5, 10))
result.append(" ").append(RandomString.pick(_nameSuffixes));
return result.toString();
}
|
[
"public",
"static",
"String",
"fullName",
"(",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"RandomBoolean",
".",
"chance",
"(",
"3",
",",
"5",
")",
")",
"result",
".",
"append",
"(",
"RandomString",
".",
"pick",
"(",
"_namePrefixes",
")",
")",
".",
"append",
"(",
"\" \"",
")",
";",
"result",
".",
"append",
"(",
"RandomString",
".",
"pick",
"(",
"_firstNames",
")",
")",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"RandomString",
".",
"pick",
"(",
"_lastNames",
")",
")",
";",
"if",
"(",
"RandomBoolean",
".",
"chance",
"(",
"5",
",",
"10",
")",
")",
"result",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"RandomString",
".",
"pick",
"(",
"_nameSuffixes",
")",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Generates a random person's name which has the following structure
optional prefix - first name - second name - optional suffix
@return a random name.
|
[
"Generates",
"a",
"random",
"person",
"s",
"name",
"which",
"has",
"the",
"following",
"structure",
"optional",
"prefix",
"-",
"first",
"name",
"-",
"second",
"name",
"-",
"optional",
"suffix"
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/random/RandomText.java#L163-L177
|
154,816
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/random/RandomText.java
|
RandomText.words
|
public static String words(int min, int max) {
StringBuilder result = new StringBuilder();
int count = RandomInteger.nextInteger(min, max);
for(int i = 0; i <count; i++)
result.append(RandomString.pick(_allWords));
return result.toString();
}
|
java
|
public static String words(int min, int max) {
StringBuilder result = new StringBuilder();
int count = RandomInteger.nextInteger(min, max);
for(int i = 0; i <count; i++)
result.append(RandomString.pick(_allWords));
return result.toString();
}
|
[
"public",
"static",
"String",
"words",
"(",
"int",
"min",
",",
"int",
"max",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"count",
"=",
"RandomInteger",
".",
"nextInteger",
"(",
"min",
",",
"max",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"result",
".",
"append",
"(",
"RandomString",
".",
"pick",
"(",
"_allWords",
")",
")",
";",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Generates a random text that consists of random number of random words separated by spaces.
@param min (optional) a minimum number of words.
@param max a maximum number of words.
@return a random text.
|
[
"Generates",
"a",
"random",
"text",
"that",
"consists",
"of",
"random",
"number",
"of",
"random",
"words",
"separated",
"by",
"spaces",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/random/RandomText.java#L195-L203
|
154,817
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/random/RandomText.java
|
RandomText.text
|
public static String text(int minSize, int maxSize) {
maxSize = Math.max(minSize, maxSize);
int size = RandomInteger.nextInteger(minSize, maxSize);
StringBuilder result = new StringBuilder();
result.append(RandomString.pick(_allWords));
while (result.length() < size) {
String next = RandomString.pick(_allWords);
if (RandomBoolean.chance(4, 6))
next = " " + next.toLowerCase();
else if (RandomBoolean.chance(2, 5))
next = RandomString.pickChar(":,-") + next.toLowerCase();
else if (RandomBoolean.chance(3, 5))
next = RandomString.pickChar(":,-") + " " + next.toLowerCase();
else
next = RandomString.pickChar(".!?") + " " + next;
result.append(next);
}
return result.toString();
}
|
java
|
public static String text(int minSize, int maxSize) {
maxSize = Math.max(minSize, maxSize);
int size = RandomInteger.nextInteger(minSize, maxSize);
StringBuilder result = new StringBuilder();
result.append(RandomString.pick(_allWords));
while (result.length() < size) {
String next = RandomString.pick(_allWords);
if (RandomBoolean.chance(4, 6))
next = " " + next.toLowerCase();
else if (RandomBoolean.chance(2, 5))
next = RandomString.pickChar(":,-") + next.toLowerCase();
else if (RandomBoolean.chance(3, 5))
next = RandomString.pickChar(":,-") + " " + next.toLowerCase();
else
next = RandomString.pickChar(".!?") + " " + next;
result.append(next);
}
return result.toString();
}
|
[
"public",
"static",
"String",
"text",
"(",
"int",
"minSize",
",",
"int",
"maxSize",
")",
"{",
"maxSize",
"=",
"Math",
".",
"max",
"(",
"minSize",
",",
"maxSize",
")",
";",
"int",
"size",
"=",
"RandomInteger",
".",
"nextInteger",
"(",
"minSize",
",",
"maxSize",
")",
";",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"result",
".",
"append",
"(",
"RandomString",
".",
"pick",
"(",
"_allWords",
")",
")",
";",
"while",
"(",
"result",
".",
"length",
"(",
")",
"<",
"size",
")",
"{",
"String",
"next",
"=",
"RandomString",
".",
"pick",
"(",
"_allWords",
")",
";",
"if",
"(",
"RandomBoolean",
".",
"chance",
"(",
"4",
",",
"6",
")",
")",
"next",
"=",
"\" \"",
"+",
"next",
".",
"toLowerCase",
"(",
")",
";",
"else",
"if",
"(",
"RandomBoolean",
".",
"chance",
"(",
"2",
",",
"5",
")",
")",
"next",
"=",
"RandomString",
".",
"pickChar",
"(",
"\":,-\"",
")",
"+",
"next",
".",
"toLowerCase",
"(",
")",
";",
"else",
"if",
"(",
"RandomBoolean",
".",
"chance",
"(",
"3",
",",
"5",
")",
")",
"next",
"=",
"RandomString",
".",
"pickChar",
"(",
"\":,-\"",
")",
"+",
"\" \"",
"+",
"next",
".",
"toLowerCase",
"(",
")",
";",
"else",
"next",
"=",
"RandomString",
".",
"pickChar",
"(",
"\".!?\"",
")",
"+",
"\" \"",
"+",
"next",
";",
"result",
".",
"append",
"(",
"next",
")",
";",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"}"
] |
Generates a random text, consisting of first names, last names, colors, stuffs, adjectives, verbs, and punctuation marks.
@param minSize minimum amount of words to generate. Text will contain 'minSize' words if 'maxSize' is omitted.
@param maxSize (optional) maximum amount of words to generate.
@return a random text.
|
[
"Generates",
"a",
"random",
"text",
"consisting",
"of",
"first",
"names",
"last",
"names",
"colors",
"stuffs",
"adjectives",
"verbs",
"and",
"punctuation",
"marks",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/random/RandomText.java#L240-L262
|
154,818
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.set
|
public StringGrabber set(String str) {
if (str == null)
{
str = "";
}
return set(new StringBuilder(str));
}
|
java
|
public StringGrabber set(String str) {
if (str == null)
{
str = "";
}
return set(new StringBuilder(str));
}
|
[
"public",
"StringGrabber",
"set",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"{",
"str",
"=",
"\"\"",
";",
"}",
"return",
"set",
"(",
"new",
"StringBuilder",
"(",
"str",
")",
")",
";",
"}"
] |
set new source of string to this class
@param str
@return
|
[
"set",
"new",
"source",
"of",
"string",
"to",
"this",
"class"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L99-L105
|
154,819
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.set
|
public StringGrabber set(StringBuilder stringBuilder) {
if (stringBuilder == null) {
stringBuilder = new StringBuilder();
}
sb = stringBuilder;
return StringGrabber.this;
}
|
java
|
public StringGrabber set(StringBuilder stringBuilder) {
if (stringBuilder == null) {
stringBuilder = new StringBuilder();
}
sb = stringBuilder;
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"set",
"(",
"StringBuilder",
"stringBuilder",
")",
"{",
"if",
"(",
"stringBuilder",
"==",
"null",
")",
"{",
"stringBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"}",
"sb",
"=",
"stringBuilder",
";",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
set new source of stringbuilder to this class
@param stringBuilder
@return
|
[
"set",
"new",
"source",
"of",
"stringbuilder",
"to",
"this",
"class"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L113-L119
|
154,820
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.removeHead
|
public StringGrabber removeHead(int cnt) {
try {
sb.delete(0, cnt);
} catch (Exception e) {
e.printStackTrace();
}
return StringGrabber.this;
}
|
java
|
public StringGrabber removeHead(int cnt) {
try {
sb.delete(0, cnt);
} catch (Exception e) {
e.printStackTrace();
}
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"removeHead",
"(",
"int",
"cnt",
")",
"{",
"try",
"{",
"sb",
".",
"delete",
"(",
"0",
",",
"cnt",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
remove N chars from head
@see StringGrabber#carryHead()
@param cnt
count of chars
@return
|
[
"remove",
"N",
"chars",
"from",
"head"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L140-L147
|
154,821
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.removeTail
|
public StringGrabber removeTail(int cnt) {
int leng = sb.length();
try {
sb.delete(leng - cnt, leng);
} catch (Exception e) {
}
return StringGrabber.this;
}
|
java
|
public StringGrabber removeTail(int cnt) {
int leng = sb.length();
try {
sb.delete(leng - cnt, leng);
} catch (Exception e) {
}
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"removeTail",
"(",
"int",
"cnt",
")",
"{",
"int",
"leng",
"=",
"sb",
".",
"length",
"(",
")",
";",
"try",
"{",
"sb",
".",
"delete",
"(",
"leng",
"-",
"cnt",
",",
"leng",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
remove N chars from tail
@see StringGrabber#carryTail()
@param cnt
count of chars
@return
|
[
"remove",
"N",
"chars",
"from",
"tail"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L157-L164
|
154,822
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.removeHeadConsecutiveChars
|
public StringGrabber removeHeadConsecutiveChars(char charToRemove) {
boolean loop = true;
if (sb.length() > 0) {
while (loop) {
if (sb.charAt(0) == charToRemove) {
removeHead(1);
} else {
loop = false;
}
}
}
return StringGrabber.this;
}
|
java
|
public StringGrabber removeHeadConsecutiveChars(char charToRemove) {
boolean loop = true;
if (sb.length() > 0) {
while (loop) {
if (sb.charAt(0) == charToRemove) {
removeHead(1);
} else {
loop = false;
}
}
}
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"removeHeadConsecutiveChars",
"(",
"char",
"charToRemove",
")",
"{",
"boolean",
"loop",
"=",
"true",
";",
"if",
"(",
"sb",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"while",
"(",
"loop",
")",
"{",
"if",
"(",
"sb",
".",
"charAt",
"(",
"0",
")",
"==",
"charToRemove",
")",
"{",
"removeHead",
"(",
"1",
")",
";",
"}",
"else",
"{",
"loop",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
remove consecutive chars placed at the head
@param charToRemove
|
[
"remove",
"consecutive",
"chars",
"placed",
"at",
"the",
"head"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L171-L184
|
154,823
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.removeTailConsecutiveChars
|
public StringGrabber removeTailConsecutiveChars(char charToRemove) {
boolean loop = true;
if (sb.length() > 0) {
while (loop) {
if (sb.charAt(sb.length() - 1) == charToRemove) {
removeTail(1);
} else {
loop = false;
}
}
}
return StringGrabber.this;
}
|
java
|
public StringGrabber removeTailConsecutiveChars(char charToRemove) {
boolean loop = true;
if (sb.length() > 0) {
while (loop) {
if (sb.charAt(sb.length() - 1) == charToRemove) {
removeTail(1);
} else {
loop = false;
}
}
}
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"removeTailConsecutiveChars",
"(",
"char",
"charToRemove",
")",
"{",
"boolean",
"loop",
"=",
"true",
";",
"if",
"(",
"sb",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"while",
"(",
"loop",
")",
"{",
"if",
"(",
"sb",
".",
"charAt",
"(",
"sb",
".",
"length",
"(",
")",
"-",
"1",
")",
"==",
"charToRemove",
")",
"{",
"removeTail",
"(",
"1",
")",
";",
"}",
"else",
"{",
"loop",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
remove consecutive chars placed at tail end.
@param charToRemove
|
[
"remove",
"consecutive",
"chars",
"placed",
"at",
"tail",
"end",
"."
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L191-L204
|
154,824
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.insertIntoHead
|
public StringGrabber insertIntoHead(String str) {
if (str != null) {
try {
sb.insert(0, str);
} catch (Exception e) {
e.printStackTrace();
}
}
return StringGrabber.this;
}
|
java
|
public StringGrabber insertIntoHead(String str) {
if (str != null) {
try {
sb.insert(0, str);
} catch (Exception e) {
e.printStackTrace();
}
}
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"insertIntoHead",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"!=",
"null",
")",
"{",
"try",
"{",
"sb",
".",
"insert",
"(",
"0",
",",
"str",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
Insert string into the first
@param str
@return
|
[
"Insert",
"string",
"into",
"the",
"first"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L305-L316
|
154,825
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.left
|
public StringGrabber left(int charCount) {
String str = getCropper().getLeftOf(sb.toString(), charCount);
sb = new StringBuilder(str);
return StringGrabber.this;
}
|
java
|
public StringGrabber left(int charCount) {
String str = getCropper().getLeftOf(sb.toString(), charCount);
sb = new StringBuilder(str);
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"left",
"(",
"int",
"charCount",
")",
"{",
"String",
"str",
"=",
"getCropper",
"(",
")",
".",
"getLeftOf",
"(",
"sb",
".",
"toString",
"(",
")",
",",
"charCount",
")",
";",
"sb",
"=",
"new",
"StringBuilder",
"(",
"str",
")",
";",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
returns a new string that is a substring of this string from left.
@param cnt
@return
|
[
"returns",
"a",
"new",
"string",
"that",
"is",
"a",
"substring",
"of",
"this",
"string",
"from",
"left",
"."
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L360-L365
|
154,826
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.right
|
public StringGrabber right(int charCount) {
String str = getCropper().getRightOf(sb.toString(), charCount);
sb = new StringBuilder(str);
return StringGrabber.this;
}
|
java
|
public StringGrabber right(int charCount) {
String str = getCropper().getRightOf(sb.toString(), charCount);
sb = new StringBuilder(str);
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"right",
"(",
"int",
"charCount",
")",
"{",
"String",
"str",
"=",
"getCropper",
"(",
")",
".",
"getRightOf",
"(",
"sb",
".",
"toString",
"(",
")",
",",
"charCount",
")",
";",
"sb",
"=",
"new",
"StringBuilder",
"(",
"str",
")",
";",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
returns a new string that is a substring of this string from right.
@param charCount
@return
|
[
"returns",
"a",
"new",
"string",
"that",
"is",
"a",
"substring",
"of",
"this",
"string",
"from",
"right",
"."
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L373-L378
|
154,827
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.replace
|
public StringGrabber replace(String target, String replacement) {
sb = new StringBuilder(sb.toString().replace(target, replacement));
return StringGrabber.this;
}
|
java
|
public StringGrabber replace(String target, String replacement) {
sb = new StringBuilder(sb.toString().replace(target, replacement));
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"replace",
"(",
"String",
"target",
",",
"String",
"replacement",
")",
"{",
"sb",
"=",
"new",
"StringBuilder",
"(",
"sb",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"target",
",",
"replacement",
")",
")",
";",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
replace specified string
@param target
@param replacement
@return
|
[
"replace",
"specified",
"string"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L387-L390
|
154,828
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.replaceEnclosedIn
|
public StringGrabber replaceEnclosedIn(String startToken, String endToken, String replacement) {
StringCropper cropper = getCropper();
final List<StrPosition> stringEnclosedInWithDetails = cropper.getStringEnclosedInWithDetails(sb.toString(), startToken, endToken);
final List<Integer> splitList = new ArrayList<Integer>();
for (StrPosition sp : stringEnclosedInWithDetails) {
int splitPointFirst = sp.startIndex - 1;
int splitPointSecond = sp.endIndex;
splitList.add(splitPointFirst);
splitList.add(splitPointSecond);
}
final Integer[] splitIndexes = splitList.toArray(new Integer[] {});
List<String> splitStringList = cropper.splitByIndex(sb.toString(), splitIndexes);
final StringBuilder tempSb = new StringBuilder();
final int strNum = splitStringList.size();
boolean nextIsValue = false;
int countOfReplacement = 0;
for (int i = 0; i < strNum; i++) {
String strPart = splitStringList.get(i);
if (nextIsValue) {
// position to add into replacement
tempSb.append(replacement);
countOfReplacement++;
if (strPart.startsWith(endToken)) {
// is string Blank
tempSb.append(strPart);
}
} else {
tempSb.append(strPart);
}
if (strPart.endsWith(startToken)) {
nextIsValue = true;
} else {
nextIsValue = false;
}
}
sb = tempSb;
return StringGrabber.this;
}
|
java
|
public StringGrabber replaceEnclosedIn(String startToken, String endToken, String replacement) {
StringCropper cropper = getCropper();
final List<StrPosition> stringEnclosedInWithDetails = cropper.getStringEnclosedInWithDetails(sb.toString(), startToken, endToken);
final List<Integer> splitList = new ArrayList<Integer>();
for (StrPosition sp : stringEnclosedInWithDetails) {
int splitPointFirst = sp.startIndex - 1;
int splitPointSecond = sp.endIndex;
splitList.add(splitPointFirst);
splitList.add(splitPointSecond);
}
final Integer[] splitIndexes = splitList.toArray(new Integer[] {});
List<String> splitStringList = cropper.splitByIndex(sb.toString(), splitIndexes);
final StringBuilder tempSb = new StringBuilder();
final int strNum = splitStringList.size();
boolean nextIsValue = false;
int countOfReplacement = 0;
for (int i = 0; i < strNum; i++) {
String strPart = splitStringList.get(i);
if (nextIsValue) {
// position to add into replacement
tempSb.append(replacement);
countOfReplacement++;
if (strPart.startsWith(endToken)) {
// is string Blank
tempSb.append(strPart);
}
} else {
tempSb.append(strPart);
}
if (strPart.endsWith(startToken)) {
nextIsValue = true;
} else {
nextIsValue = false;
}
}
sb = tempSb;
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"replaceEnclosedIn",
"(",
"String",
"startToken",
",",
"String",
"endToken",
",",
"String",
"replacement",
")",
"{",
"StringCropper",
"cropper",
"=",
"getCropper",
"(",
")",
";",
"final",
"List",
"<",
"StrPosition",
">",
"stringEnclosedInWithDetails",
"=",
"cropper",
".",
"getStringEnclosedInWithDetails",
"(",
"sb",
".",
"toString",
"(",
")",
",",
"startToken",
",",
"endToken",
")",
";",
"final",
"List",
"<",
"Integer",
">",
"splitList",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")",
";",
"for",
"(",
"StrPosition",
"sp",
":",
"stringEnclosedInWithDetails",
")",
"{",
"int",
"splitPointFirst",
"=",
"sp",
".",
"startIndex",
"-",
"1",
";",
"int",
"splitPointSecond",
"=",
"sp",
".",
"endIndex",
";",
"splitList",
".",
"add",
"(",
"splitPointFirst",
")",
";",
"splitList",
".",
"add",
"(",
"splitPointSecond",
")",
";",
"}",
"final",
"Integer",
"[",
"]",
"splitIndexes",
"=",
"splitList",
".",
"toArray",
"(",
"new",
"Integer",
"[",
"]",
"{",
"}",
")",
";",
"List",
"<",
"String",
">",
"splitStringList",
"=",
"cropper",
".",
"splitByIndex",
"(",
"sb",
".",
"toString",
"(",
")",
",",
"splitIndexes",
")",
";",
"final",
"StringBuilder",
"tempSb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"int",
"strNum",
"=",
"splitStringList",
".",
"size",
"(",
")",
";",
"boolean",
"nextIsValue",
"=",
"false",
";",
"int",
"countOfReplacement",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"strNum",
";",
"i",
"++",
")",
"{",
"String",
"strPart",
"=",
"splitStringList",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"nextIsValue",
")",
"{",
"// position to add into replacement",
"tempSb",
".",
"append",
"(",
"replacement",
")",
";",
"countOfReplacement",
"++",
";",
"if",
"(",
"strPart",
".",
"startsWith",
"(",
"endToken",
")",
")",
"{",
"// is string Blank",
"tempSb",
".",
"append",
"(",
"strPart",
")",
";",
"}",
"}",
"else",
"{",
"tempSb",
".",
"append",
"(",
"strPart",
")",
";",
"}",
"if",
"(",
"strPart",
".",
"endsWith",
"(",
"startToken",
")",
")",
"{",
"nextIsValue",
"=",
"true",
";",
"}",
"else",
"{",
"nextIsValue",
"=",
"false",
";",
"}",
"}",
"sb",
"=",
"tempSb",
";",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
replace specified string enclosed in speficied token
@param startToken
@param endToken
@param replacement
@return
|
[
"replace",
"specified",
"string",
"enclosed",
"in",
"speficied",
"token"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L400-L460
|
154,829
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.substring
|
public StringGrabber substring(int startIdx, int endIndex) {
if (startIdx < 0) {
startIdx = 0;
}
if (endIndex > length() - 1) {
endIndex = length() - 1;
}
sb = new StringBuilder(substringInternally(startIdx, endIndex));
return StringGrabber.this;
}
|
java
|
public StringGrabber substring(int startIdx, int endIndex) {
if (startIdx < 0) {
startIdx = 0;
}
if (endIndex > length() - 1) {
endIndex = length() - 1;
}
sb = new StringBuilder(substringInternally(startIdx, endIndex));
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"substring",
"(",
"int",
"startIdx",
",",
"int",
"endIndex",
")",
"{",
"if",
"(",
"startIdx",
"<",
"0",
")",
"{",
"startIdx",
"=",
"0",
";",
"}",
"if",
"(",
"endIndex",
">",
"length",
"(",
")",
"-",
"1",
")",
"{",
"endIndex",
"=",
"length",
"(",
")",
"-",
"1",
";",
"}",
"sb",
"=",
"new",
"StringBuilder",
"(",
"substringInternally",
"(",
"startIdx",
",",
"endIndex",
")",
")",
";",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
returns substring specified with start index and endIndex
@param startIdx
@param endIndex
@return
|
[
"returns",
"substring",
"specified",
"with",
"start",
"index",
"and",
"endIndex"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L469-L479
|
154,830
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.toInt
|
public int toInt(int defaultValue) {
try {
return Integer.parseInt(sb.toString());
} catch (java.lang.NumberFormatException e) {
e.printStackTrace();
}
return defaultValue;
}
|
java
|
public int toInt(int defaultValue) {
try {
return Integer.parseInt(sb.toString());
} catch (java.lang.NumberFormatException e) {
e.printStackTrace();
}
return defaultValue;
}
|
[
"public",
"int",
"toInt",
"(",
"int",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"java",
".",
"lang",
".",
"NumberFormatException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"defaultValue",
";",
"}"
] |
returns int value ,when format error occurred ,returns default value
@param defaultValue
@return
|
[
"returns",
"int",
"value",
"when",
"format",
"error",
"occurred",
"returns",
"default",
"value"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L509-L516
|
154,831
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.toDouble
|
public double toDouble(double defaultValue) {
try {
return Double.parseDouble(sb.toString());
} catch (java.lang.NumberFormatException e) {
}
return defaultValue;
}
|
java
|
public double toDouble(double defaultValue) {
try {
return Double.parseDouble(sb.toString());
} catch (java.lang.NumberFormatException e) {
}
return defaultValue;
}
|
[
"public",
"double",
"toDouble",
"(",
"double",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"Double",
".",
"parseDouble",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"java",
".",
"lang",
".",
"NumberFormatException",
"e",
")",
"{",
"}",
"return",
"defaultValue",
";",
"}"
] |
returns double value ,when format error occurred ,returns default value
@param defaultValue
@return
|
[
"returns",
"double",
"value",
"when",
"format",
"error",
"occurred",
"returns",
"default",
"value"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L524-L530
|
154,832
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.toFloat
|
public float toFloat(float defaultValue) {
try {
return Float.parseFloat(sb.toString());
} catch (java.lang.NumberFormatException e) {
}
return defaultValue;
}
|
java
|
public float toFloat(float defaultValue) {
try {
return Float.parseFloat(sb.toString());
} catch (java.lang.NumberFormatException e) {
}
return defaultValue;
}
|
[
"public",
"float",
"toFloat",
"(",
"float",
"defaultValue",
")",
"{",
"try",
"{",
"return",
"Float",
".",
"parseFloat",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"java",
".",
"lang",
".",
"NumberFormatException",
"e",
")",
"{",
"}",
"return",
"defaultValue",
";",
"}"
] |
returns float value ,when format error occurred ,returns default value
@param defaultValue
@return
|
[
"returns",
"float",
"value",
"when",
"format",
"error",
"occurred",
"returns",
"default",
"value"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L538-L544
|
154,833
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.appendRepeat
|
public StringGrabber appendRepeat(String str, int repeatCount) {
for (int i = 0; i < repeatCount; i++) {
if (str != null) {
sb.append(str);
}
}
return StringGrabber.this;
}
|
java
|
public StringGrabber appendRepeat(String str, int repeatCount) {
for (int i = 0; i < repeatCount; i++) {
if (str != null) {
sb.append(str);
}
}
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"appendRepeat",
"(",
"String",
"str",
",",
"int",
"repeatCount",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"repeatCount",
";",
"i",
"++",
")",
"{",
"if",
"(",
"str",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"str",
")",
";",
"}",
"}",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
Append a string to be repeated
@see StringGrabber#insertRepeat(String);
@param str
@param repeatCount
@return
|
[
"Append",
"a",
"string",
"to",
"be",
"repeated"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L569-L576
|
154,834
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.insertRepeat
|
public StringGrabber insertRepeat(String str, int repeatCount) {
for (int i = 0; i < repeatCount; i++) {
insertIntoHead(str);
}
return StringGrabber.this;
}
|
java
|
public StringGrabber insertRepeat(String str, int repeatCount) {
for (int i = 0; i < repeatCount; i++) {
insertIntoHead(str);
}
return StringGrabber.this;
}
|
[
"public",
"StringGrabber",
"insertRepeat",
"(",
"String",
"str",
",",
"int",
"repeatCount",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"repeatCount",
";",
"i",
"++",
")",
"{",
"insertIntoHead",
"(",
"str",
")",
";",
"}",
"return",
"StringGrabber",
".",
"this",
";",
"}"
] |
Append a string to be repeated into head
@see StringGrabber#insertRepeat(String);
@param str
@param repeatCount
@return
|
[
"Append",
"a",
"string",
"to",
"be",
"repeated",
"into",
"head"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L586-L591
|
154,835
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringGrabber.java
|
StringGrabber.split
|
public StringGrabberList split(String regexp) {
final StringGrabberList retList = new StringGrabberList();
final String string = sb.toString();
String[] splitedStrings = string.split(regexp);
for (String str : splitedStrings) {
retList.add(new StringGrabber(str));
}
return retList;
}
|
java
|
public StringGrabberList split(String regexp) {
final StringGrabberList retList = new StringGrabberList();
final String string = sb.toString();
String[] splitedStrings = string.split(regexp);
for (String str : splitedStrings) {
retList.add(new StringGrabber(str));
}
return retList;
}
|
[
"public",
"StringGrabberList",
"split",
"(",
"String",
"regexp",
")",
"{",
"final",
"StringGrabberList",
"retList",
"=",
"new",
"StringGrabberList",
"(",
")",
";",
"final",
"String",
"string",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"String",
"[",
"]",
"splitedStrings",
"=",
"string",
".",
"split",
"(",
"regexp",
")",
";",
"for",
"(",
"String",
"str",
":",
"splitedStrings",
")",
"{",
"retList",
".",
"add",
"(",
"new",
"StringGrabber",
"(",
"str",
")",
")",
";",
"}",
"return",
"retList",
";",
"}"
] |
Splits this string around matches of the given regular expression.
@param regexp
@return
|
[
"Splits",
"this",
"string",
"around",
"matches",
"of",
"the",
"given",
"regular",
"expression",
"."
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringGrabber.java#L669-L683
|
154,836
|
gnagy/webhejj-commons
|
src/main/java/hu/webhejj/commons/diff/DiffUtils.java
|
DiffUtils.dump
|
public static <T> void dump(Iterable<Difference<T>> diffs) {
for(Difference<T> diff: diffs) {
System.out.println(diff);
}
}
|
java
|
public static <T> void dump(Iterable<Difference<T>> diffs) {
for(Difference<T> diff: diffs) {
System.out.println(diff);
}
}
|
[
"public",
"static",
"<",
"T",
">",
"void",
"dump",
"(",
"Iterable",
"<",
"Difference",
"<",
"T",
">",
">",
"diffs",
")",
"{",
"for",
"(",
"Difference",
"<",
"T",
">",
"diff",
":",
"diffs",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"diff",
")",
";",
"}",
"}"
] |
prints to stdout all differences on a new line
|
[
"prints",
"to",
"stdout",
"all",
"differences",
"on",
"a",
"new",
"line"
] |
270bc6f111ec5761af31d39bd38c40fd914d2eba
|
https://github.com/gnagy/webhejj-commons/blob/270bc6f111ec5761af31d39bd38c40fd914d2eba/src/main/java/hu/webhejj/commons/diff/DiffUtils.java#L32-L36
|
154,837
|
gnagy/webhejj-commons
|
src/main/java/hu/webhejj/commons/diff/DiffUtils.java
|
DiffUtils.dumpUnchanged
|
public static <T> void dumpUnchanged(Iterable<Difference<T>> diffs) {
for(Difference<T> diff: diffs) {
if(Difference.Type.UNCHANGED.equals(diff.getType())) {
System.out.println(diff);
}
}
}
|
java
|
public static <T> void dumpUnchanged(Iterable<Difference<T>> diffs) {
for(Difference<T> diff: diffs) {
if(Difference.Type.UNCHANGED.equals(diff.getType())) {
System.out.println(diff);
}
}
}
|
[
"public",
"static",
"<",
"T",
">",
"void",
"dumpUnchanged",
"(",
"Iterable",
"<",
"Difference",
"<",
"T",
">",
">",
"diffs",
")",
"{",
"for",
"(",
"Difference",
"<",
"T",
">",
"diff",
":",
"diffs",
")",
"{",
"if",
"(",
"Difference",
".",
"Type",
".",
"UNCHANGED",
".",
"equals",
"(",
"diff",
".",
"getType",
"(",
")",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"diff",
")",
";",
"}",
"}",
"}"
] |
prints to stdout all UNCHANGED differences on a new line
|
[
"prints",
"to",
"stdout",
"all",
"UNCHANGED",
"differences",
"on",
"a",
"new",
"line"
] |
270bc6f111ec5761af31d39bd38c40fd914d2eba
|
https://github.com/gnagy/webhejj-commons/blob/270bc6f111ec5761af31d39bd38c40fd914d2eba/src/main/java/hu/webhejj/commons/diff/DiffUtils.java#L39-L45
|
154,838
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/stats/StringCounter.java
|
StringCounter.getCountMap
|
public static Map<String, Long> getCountMap(
Collection<String> stringCollection) {
return unmodifiableMap(countBy(stringCollection));
}
|
java
|
public static Map<String, Long> getCountMap(
Collection<String> stringCollection) {
return unmodifiableMap(countBy(stringCollection));
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Long",
">",
"getCountMap",
"(",
"Collection",
"<",
"String",
">",
"stringCollection",
")",
"{",
"return",
"unmodifiableMap",
"(",
"countBy",
"(",
"stringCollection",
")",
")",
";",
"}"
] |
Gets count map.
@param stringCollection the string collection
@return the count map
|
[
"Gets",
"count",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/StringCounter.java#L38-L41
|
154,839
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/stats/StringCounter.java
|
StringCounter.getSortedStringList
|
public static List<String> getSortedStringList(
Collection<String> stringCollection) {
return unmodifiableList(sort(new ArrayList<>(stringCollection)));
}
|
java
|
public static List<String> getSortedStringList(
Collection<String> stringCollection) {
return unmodifiableList(sort(new ArrayList<>(stringCollection)));
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"getSortedStringList",
"(",
"Collection",
"<",
"String",
">",
"stringCollection",
")",
"{",
"return",
"unmodifiableList",
"(",
"sort",
"(",
"new",
"ArrayList",
"<>",
"(",
"stringCollection",
")",
")",
")",
";",
"}"
] |
Gets sorted string list.
@param stringCollection the string collection
@return the sorted string list
|
[
"Gets",
"sorted",
"string",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/StringCounter.java#L49-L52
|
154,840
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/Descriptor.java
|
Descriptor.exactMatch
|
public boolean exactMatch(Descriptor descriptor) {
return exactMatchField(_group, descriptor.getGroup()) && exactMatchField(_type, descriptor.getType())
&& exactMatchField(_kind, descriptor.getKind()) && exactMatchField(_name, descriptor.getName())
&& exactMatchField(_version, descriptor.getVersion());
}
|
java
|
public boolean exactMatch(Descriptor descriptor) {
return exactMatchField(_group, descriptor.getGroup()) && exactMatchField(_type, descriptor.getType())
&& exactMatchField(_kind, descriptor.getKind()) && exactMatchField(_name, descriptor.getName())
&& exactMatchField(_version, descriptor.getVersion());
}
|
[
"public",
"boolean",
"exactMatch",
"(",
"Descriptor",
"descriptor",
")",
"{",
"return",
"exactMatchField",
"(",
"_group",
",",
"descriptor",
".",
"getGroup",
"(",
")",
")",
"&&",
"exactMatchField",
"(",
"_type",
",",
"descriptor",
".",
"getType",
"(",
")",
")",
"&&",
"exactMatchField",
"(",
"_kind",
",",
"descriptor",
".",
"getKind",
"(",
")",
")",
"&&",
"exactMatchField",
"(",
"_name",
",",
"descriptor",
".",
"getName",
"(",
")",
")",
"&&",
"exactMatchField",
"(",
"_version",
",",
"descriptor",
".",
"getVersion",
"(",
")",
")",
";",
"}"
] |
Matches this descriptor to another descriptor by all fields. No exceptions
are made.
@param descriptor the descriptor to match this one against.
@return true if descriptors match and false otherwise.
@see #match(Descriptor)
|
[
"Matches",
"this",
"descriptor",
"to",
"another",
"descriptor",
"by",
"all",
"fields",
".",
"No",
"exceptions",
"are",
"made",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/Descriptor.java#L154-L158
|
154,841
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/Descriptor.java
|
Descriptor.fromString
|
public static Descriptor fromString(String value) throws ConfigException {
if (value == null || value.length() == 0)
return null;
String[] tokens = value.split(":");
if (tokens.length != 5) {
throw (ConfigException) new ConfigException(null, "BAD_DESCRIPTOR",
"Descriptor " + value + " is in wrong format").withDetails("descriptor", value);
}
return new Descriptor(tokens[0].trim(), tokens[1].trim(), tokens[2].trim(), tokens[3].trim(), tokens[4].trim());
}
|
java
|
public static Descriptor fromString(String value) throws ConfigException {
if (value == null || value.length() == 0)
return null;
String[] tokens = value.split(":");
if (tokens.length != 5) {
throw (ConfigException) new ConfigException(null, "BAD_DESCRIPTOR",
"Descriptor " + value + " is in wrong format").withDetails("descriptor", value);
}
return new Descriptor(tokens[0].trim(), tokens[1].trim(), tokens[2].trim(), tokens[3].trim(), tokens[4].trim());
}
|
[
"public",
"static",
"Descriptor",
"fromString",
"(",
"String",
"value",
")",
"throws",
"ConfigException",
"{",
"if",
"(",
"value",
"==",
"null",
"||",
"value",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"null",
";",
"String",
"[",
"]",
"tokens",
"=",
"value",
".",
"split",
"(",
"\":\"",
")",
";",
"if",
"(",
"tokens",
".",
"length",
"!=",
"5",
")",
"{",
"throw",
"(",
"ConfigException",
")",
"new",
"ConfigException",
"(",
"null",
",",
"\"BAD_DESCRIPTOR\"",
",",
"\"Descriptor \"",
"+",
"value",
"+",
"\" is in wrong format\"",
")",
".",
"withDetails",
"(",
"\"descriptor\"",
",",
"value",
")",
";",
"}",
"return",
"new",
"Descriptor",
"(",
"tokens",
"[",
"0",
"]",
".",
"trim",
"(",
")",
",",
"tokens",
"[",
"1",
"]",
".",
"trim",
"(",
")",
",",
"tokens",
"[",
"2",
"]",
".",
"trim",
"(",
")",
",",
"tokens",
"[",
"3",
"]",
".",
"trim",
"(",
")",
",",
"tokens",
"[",
"4",
"]",
".",
"trim",
"(",
")",
")",
";",
"}"
] |
Parses colon-separated list of descriptor fields and returns them as a
Descriptor.
@param value colon-separated descriptor fields to initialize Descriptor.
@return a newly created Descriptor.
@throws ConfigException if the descriptor string is of a wrong format.
|
[
"Parses",
"colon",
"-",
"separated",
"list",
"of",
"descriptor",
"fields",
"and",
"returns",
"them",
"as",
"a",
"Descriptor",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/Descriptor.java#L209-L220
|
154,842
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLog.java
|
JMLog.infoAndDebug
|
public static void infoAndDebug(Logger log, String methodName,
Object... params) {
if (!log.isInfoEnabled())
return;
int length = params.length;
Object[] newParams = new Object[length];
boolean hasCollection = false;
for (int i = 0; i < length; i++) {
if (params[i] instanceof Collection) {
newParams[i] = (((Collection<?>) params[i]).size());
hasCollection = true;
} else
newParams[i] = params[i];
}
if (hasCollection)
log.info(buildMethodLogString(methodName, newParams));
log.debug(buildMethodLogString(methodName, params));
}
|
java
|
public static void infoAndDebug(Logger log, String methodName,
Object... params) {
if (!log.isInfoEnabled())
return;
int length = params.length;
Object[] newParams = new Object[length];
boolean hasCollection = false;
for (int i = 0; i < length; i++) {
if (params[i] instanceof Collection) {
newParams[i] = (((Collection<?>) params[i]).size());
hasCollection = true;
} else
newParams[i] = params[i];
}
if (hasCollection)
log.info(buildMethodLogString(methodName, newParams));
log.debug(buildMethodLogString(methodName, params));
}
|
[
"public",
"static",
"void",
"infoAndDebug",
"(",
"Logger",
"log",
",",
"String",
"methodName",
",",
"Object",
"...",
"params",
")",
"{",
"if",
"(",
"!",
"log",
".",
"isInfoEnabled",
"(",
")",
")",
"return",
";",
"int",
"length",
"=",
"params",
".",
"length",
";",
"Object",
"[",
"]",
"newParams",
"=",
"new",
"Object",
"[",
"length",
"]",
";",
"boolean",
"hasCollection",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"params",
"[",
"i",
"]",
"instanceof",
"Collection",
")",
"{",
"newParams",
"[",
"i",
"]",
"=",
"(",
"(",
"(",
"Collection",
"<",
"?",
">",
")",
"params",
"[",
"i",
"]",
")",
".",
"size",
"(",
")",
")",
";",
"hasCollection",
"=",
"true",
";",
"}",
"else",
"newParams",
"[",
"i",
"]",
"=",
"params",
"[",
"i",
"]",
";",
"}",
"if",
"(",
"hasCollection",
")",
"log",
".",
"info",
"(",
"buildMethodLogString",
"(",
"methodName",
",",
"newParams",
")",
")",
";",
"log",
".",
"debug",
"(",
"buildMethodLogString",
"(",
"methodName",
",",
"params",
")",
")",
";",
"}"
] |
Info and debug.
@param log the log
@param methodName the method name
@param params the params
|
[
"Info",
"and",
"debug",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLog.java#L45-L62
|
154,843
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLog.java
|
JMLog.errorForException
|
public static void errorForException(Logger log, Throwable throwable,
String methodName) {
log.error(buildMethodLogString(methodName), throwable);
}
|
java
|
public static void errorForException(Logger log, Throwable throwable,
String methodName) {
log.error(buildMethodLogString(methodName), throwable);
}
|
[
"public",
"static",
"void",
"errorForException",
"(",
"Logger",
"log",
",",
"Throwable",
"throwable",
",",
"String",
"methodName",
")",
"{",
"log",
".",
"error",
"(",
"buildMethodLogString",
"(",
"methodName",
")",
",",
"throwable",
")",
";",
"}"
] |
Error for exception.
@param log the log
@param throwable the throwable
@param methodName the method name
|
[
"Error",
"for",
"exception",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLog.java#L92-L95
|
154,844
|
opencb/datastore
|
datastore-core/src/main/java/org/opencb/datastore/core/QueryOptions.java
|
QueryOptions.addToListOption
|
public Object addToListOption(String key, Object value) {
if (key != null && !key.equals("")) {
if (this.containsKey(key) && this.get(key) != null) {
if (!(this.get(key) instanceof List)) { //If was not a list, getAsList returns an Unmodifiable List.
// Create new modifiable List with the content, and replace.
this.put(key, new ArrayList<>(this.getAsList(key)));
}
try {
this.getList(key).add(value);
} catch (UnsupportedOperationException e) {
List<Object> list = new ArrayList<>(this.getList(key));
list.add(value);
this.put(key, list);
}
} else {
List<Object> list = new ArrayList<>(); //New List instead of "Arrays.asList" or "Collections.singletonList" to avoid unmodifiable list.
list.add(value);
this.put(key, list);
}
return this.getList(key);
}
return null;
}
|
java
|
public Object addToListOption(String key, Object value) {
if (key != null && !key.equals("")) {
if (this.containsKey(key) && this.get(key) != null) {
if (!(this.get(key) instanceof List)) { //If was not a list, getAsList returns an Unmodifiable List.
// Create new modifiable List with the content, and replace.
this.put(key, new ArrayList<>(this.getAsList(key)));
}
try {
this.getList(key).add(value);
} catch (UnsupportedOperationException e) {
List<Object> list = new ArrayList<>(this.getList(key));
list.add(value);
this.put(key, list);
}
} else {
List<Object> list = new ArrayList<>(); //New List instead of "Arrays.asList" or "Collections.singletonList" to avoid unmodifiable list.
list.add(value);
this.put(key, list);
}
return this.getList(key);
}
return null;
}
|
[
"public",
"Object",
"addToListOption",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"key",
"!=",
"null",
"&&",
"!",
"key",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"if",
"(",
"this",
".",
"containsKey",
"(",
"key",
")",
"&&",
"this",
".",
"get",
"(",
"key",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"this",
".",
"get",
"(",
"key",
")",
"instanceof",
"List",
")",
")",
"{",
"//If was not a list, getAsList returns an Unmodifiable List.",
"// Create new modifiable List with the content, and replace.",
"this",
".",
"put",
"(",
"key",
",",
"new",
"ArrayList",
"<>",
"(",
"this",
".",
"getAsList",
"(",
"key",
")",
")",
")",
";",
"}",
"try",
"{",
"this",
".",
"getList",
"(",
"key",
")",
".",
"add",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"UnsupportedOperationException",
"e",
")",
"{",
"List",
"<",
"Object",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
"this",
".",
"getList",
"(",
"key",
")",
")",
";",
"list",
".",
"add",
"(",
"value",
")",
";",
"this",
".",
"put",
"(",
"key",
",",
"list",
")",
";",
"}",
"}",
"else",
"{",
"List",
"<",
"Object",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"//New List instead of \"Arrays.asList\" or \"Collections.singletonList\" to avoid unmodifiable list.",
"list",
".",
"add",
"(",
"value",
")",
";",
"this",
".",
"put",
"(",
"key",
",",
"list",
")",
";",
"}",
"return",
"this",
".",
"getList",
"(",
"key",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
This method safely add a new Object to an exiting option which type is List.
@param key
@param value
@return the list with the new Object inserted.
|
[
"This",
"method",
"safely",
"add",
"a",
"new",
"Object",
"to",
"an",
"exiting",
"option",
"which",
"type",
"is",
"List",
"."
] |
c6b92b30385d5fc5cc191e2db96c46b0389a88c7
|
https://github.com/opencb/datastore/blob/c6b92b30385d5fc5cc191e2db96c46b0389a88c7/datastore-core/src/main/java/org/opencb/datastore/core/QueryOptions.java#L86-L108
|
154,845
|
ludovicianul/selenium-on-steroids
|
src/main/java/com/insidecoding/sos/junit/TakeScreenshotOnFailureRule.java
|
TakeScreenshotOnFailureRule.setScreenshotFolder
|
public void setScreenshotFolder(final File folder) {
this.directory = folder;
boolean created = directory.mkdirs();
LOG.info("Screenshot folder created succsessfully: " + created);
}
|
java
|
public void setScreenshotFolder(final File folder) {
this.directory = folder;
boolean created = directory.mkdirs();
LOG.info("Screenshot folder created succsessfully: " + created);
}
|
[
"public",
"void",
"setScreenshotFolder",
"(",
"final",
"File",
"folder",
")",
"{",
"this",
".",
"directory",
"=",
"folder",
";",
"boolean",
"created",
"=",
"directory",
".",
"mkdirs",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Screenshot folder created succsessfully: \"",
"+",
"created",
")",
";",
"}"
] |
Set the folder where we save screenshots.
@param folder
the folder
|
[
"Set",
"the",
"folder",
"where",
"we",
"save",
"screenshots",
"."
] |
f89d91c59f686114f94624bfc55712f278005bfa
|
https://github.com/ludovicianul/selenium-on-steroids/blob/f89d91c59f686114f94624bfc55712f278005bfa/src/main/java/com/insidecoding/sos/junit/TakeScreenshotOnFailureRule.java#L53-L57
|
154,846
|
ludovicianul/selenium-on-steroids
|
src/main/java/com/insidecoding/sos/junit/TakeScreenshotOnFailureRule.java
|
TakeScreenshotOnFailureRule.filenameFor
|
private File filenameFor(final Description method) {
String className = method.getClassName();
String methodName = method.getMethodName();
return new File(directory, className + "_" + methodName + ".png");
}
|
java
|
private File filenameFor(final Description method) {
String className = method.getClassName();
String methodName = method.getMethodName();
return new File(directory, className + "_" + methodName + ".png");
}
|
[
"private",
"File",
"filenameFor",
"(",
"final",
"Description",
"method",
")",
"{",
"String",
"className",
"=",
"method",
".",
"getClassName",
"(",
")",
";",
"String",
"methodName",
"=",
"method",
".",
"getMethodName",
"(",
")",
";",
"return",
"new",
"File",
"(",
"directory",
",",
"className",
"+",
"\"_\"",
"+",
"methodName",
"+",
"\".png\"",
")",
";",
"}"
] |
Gets the name of the image file with the screenshot.
@param method
the method name
@return the file that will cotain the screenshot
|
[
"Gets",
"the",
"name",
"of",
"the",
"image",
"file",
"with",
"the",
"screenshot",
"."
] |
f89d91c59f686114f94624bfc55712f278005bfa
|
https://github.com/ludovicianul/selenium-on-steroids/blob/f89d91c59f686114f94624bfc55712f278005bfa/src/main/java/com/insidecoding/sos/junit/TakeScreenshotOnFailureRule.java#L129-L134
|
154,847
|
ludovicianul/selenium-on-steroids
|
src/main/java/com/insidecoding/sos/junit/TakeScreenshotOnFailureRule.java
|
TakeScreenshotOnFailureRule.silentlySaveScreenshotTo
|
private void silentlySaveScreenshotTo(final File file) {
try {
saveScreenshotTo(file);
LOG.info("Screenshot saved: " + file.getAbsolutePath());
} catch (Exception e) {
LOG.warn("Error while taking screenshot " + file.getName() + ": "
+ e);
}
}
|
java
|
private void silentlySaveScreenshotTo(final File file) {
try {
saveScreenshotTo(file);
LOG.info("Screenshot saved: " + file.getAbsolutePath());
} catch (Exception e) {
LOG.warn("Error while taking screenshot " + file.getName() + ": "
+ e);
}
}
|
[
"private",
"void",
"silentlySaveScreenshotTo",
"(",
"final",
"File",
"file",
")",
"{",
"try",
"{",
"saveScreenshotTo",
"(",
"file",
")",
";",
"LOG",
".",
"info",
"(",
"\"Screenshot saved: \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Error while taking screenshot \"",
"+",
"file",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"e",
")",
";",
"}",
"}"
] |
Saves the actual screenshot without interrupting the running of the
tests. It will log an error if unable to store take the screenshot.
@param file
the file that will store the screenshot
|
[
"Saves",
"the",
"actual",
"screenshot",
"without",
"interrupting",
"the",
"running",
"of",
"the",
"tests",
".",
"It",
"will",
"log",
"an",
"error",
"if",
"unable",
"to",
"store",
"take",
"the",
"screenshot",
"."
] |
f89d91c59f686114f94624bfc55712f278005bfa
|
https://github.com/ludovicianul/selenium-on-steroids/blob/f89d91c59f686114f94624bfc55712f278005bfa/src/main/java/com/insidecoding/sos/junit/TakeScreenshotOnFailureRule.java#L143-L151
|
154,848
|
ludovicianul/selenium-on-steroids
|
src/main/java/com/insidecoding/sos/junit/TakeScreenshotOnFailureRule.java
|
TakeScreenshotOnFailureRule.saveScreenshotTo
|
private void saveScreenshotTo(final File file) throws IOException {
byte[] bytes = null;
try {
bytes = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.BYTES);
} catch (ClassCastException e) {
WebDriver augmentedDriver = new Augmenter().augment(driver);
bytes = ((TakesScreenshot) augmentedDriver)
.getScreenshotAs(OutputType.BYTES);
}
Files.write(bytes, file);
}
|
java
|
private void saveScreenshotTo(final File file) throws IOException {
byte[] bytes = null;
try {
bytes = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.BYTES);
} catch (ClassCastException e) {
WebDriver augmentedDriver = new Augmenter().augment(driver);
bytes = ((TakesScreenshot) augmentedDriver)
.getScreenshotAs(OutputType.BYTES);
}
Files.write(bytes, file);
}
|
[
"private",
"void",
"saveScreenshotTo",
"(",
"final",
"File",
"file",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"null",
";",
"try",
"{",
"bytes",
"=",
"(",
"(",
"TakesScreenshot",
")",
"driver",
")",
".",
"getScreenshotAs",
"(",
"OutputType",
".",
"BYTES",
")",
";",
"}",
"catch",
"(",
"ClassCastException",
"e",
")",
"{",
"WebDriver",
"augmentedDriver",
"=",
"new",
"Augmenter",
"(",
")",
".",
"augment",
"(",
"driver",
")",
";",
"bytes",
"=",
"(",
"(",
"TakesScreenshot",
")",
"augmentedDriver",
")",
".",
"getScreenshotAs",
"(",
"OutputType",
".",
"BYTES",
")",
";",
"}",
"Files",
".",
"write",
"(",
"bytes",
",",
"file",
")",
";",
"}"
] |
Saves the screenshot to the file.
@param file
the file where to save the screenshot
@throws IOException
if something goes wrong while saving
|
[
"Saves",
"the",
"screenshot",
"to",
"the",
"file",
"."
] |
f89d91c59f686114f94624bfc55712f278005bfa
|
https://github.com/ludovicianul/selenium-on-steroids/blob/f89d91c59f686114f94624bfc55712f278005bfa/src/main/java/com/insidecoding/sos/junit/TakeScreenshotOnFailureRule.java#L161-L173
|
154,849
|
zandero/http
|
src/main/java/com/zandero/http/logging/LoggingUtils.java
|
LoggingUtils.prepareForLogging
|
public static void prepareForLogging(HttpServletRequest request) {
// Add the fishtag for Log4j2 MDC
MDC.put("timestamp", System.currentTimeMillis() + "");
MDC.put("request_id", UUID.randomUUID().toString()); // generate random request id
MDC.put("request", request.getRequestURI());
MDC.put("ip", RequestUtils.getClientIpAddress(request));
MDC.put("user_agent", RequestUtils.getUserAgent(request));
MDC.put("method", request.getMethod());
MDC.put("host", request.getServerName());
MDC.put("scheme", RequestUtils.getScheme(request));
MDC.put("domain", UrlUtils.resolveDomain(request.getServerName()));
MDC.put("port", request.getServerPort() + "");
MDC.put("path", request.getContextPath() + request.getPathInfo());
if (request.getUserPrincipal() != null) {
MDC.put("user", request.getUserPrincipal() != null ? request.getUserPrincipal().getName() : null);
}
if (!StringUtils.isNullOrEmptyTrimmed(request.getQueryString())) {
MDC.put("query", request.getQueryString());
}
}
|
java
|
public static void prepareForLogging(HttpServletRequest request) {
// Add the fishtag for Log4j2 MDC
MDC.put("timestamp", System.currentTimeMillis() + "");
MDC.put("request_id", UUID.randomUUID().toString()); // generate random request id
MDC.put("request", request.getRequestURI());
MDC.put("ip", RequestUtils.getClientIpAddress(request));
MDC.put("user_agent", RequestUtils.getUserAgent(request));
MDC.put("method", request.getMethod());
MDC.put("host", request.getServerName());
MDC.put("scheme", RequestUtils.getScheme(request));
MDC.put("domain", UrlUtils.resolveDomain(request.getServerName()));
MDC.put("port", request.getServerPort() + "");
MDC.put("path", request.getContextPath() + request.getPathInfo());
if (request.getUserPrincipal() != null) {
MDC.put("user", request.getUserPrincipal() != null ? request.getUserPrincipal().getName() : null);
}
if (!StringUtils.isNullOrEmptyTrimmed(request.getQueryString())) {
MDC.put("query", request.getQueryString());
}
}
|
[
"public",
"static",
"void",
"prepareForLogging",
"(",
"HttpServletRequest",
"request",
")",
"{",
"// Add the fishtag for Log4j2 MDC",
"MDC",
".",
"put",
"(",
"\"timestamp\"",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"\"\"",
")",
";",
"MDC",
".",
"put",
"(",
"\"request_id\"",
",",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"// generate random request id",
"MDC",
".",
"put",
"(",
"\"request\"",
",",
"request",
".",
"getRequestURI",
"(",
")",
")",
";",
"MDC",
".",
"put",
"(",
"\"ip\"",
",",
"RequestUtils",
".",
"getClientIpAddress",
"(",
"request",
")",
")",
";",
"MDC",
".",
"put",
"(",
"\"user_agent\"",
",",
"RequestUtils",
".",
"getUserAgent",
"(",
"request",
")",
")",
";",
"MDC",
".",
"put",
"(",
"\"method\"",
",",
"request",
".",
"getMethod",
"(",
")",
")",
";",
"MDC",
".",
"put",
"(",
"\"host\"",
",",
"request",
".",
"getServerName",
"(",
")",
")",
";",
"MDC",
".",
"put",
"(",
"\"scheme\"",
",",
"RequestUtils",
".",
"getScheme",
"(",
"request",
")",
")",
";",
"MDC",
".",
"put",
"(",
"\"domain\"",
",",
"UrlUtils",
".",
"resolveDomain",
"(",
"request",
".",
"getServerName",
"(",
")",
")",
")",
";",
"MDC",
".",
"put",
"(",
"\"port\"",
",",
"request",
".",
"getServerPort",
"(",
")",
"+",
"\"\"",
")",
";",
"MDC",
".",
"put",
"(",
"\"path\"",
",",
"request",
".",
"getContextPath",
"(",
")",
"+",
"request",
".",
"getPathInfo",
"(",
")",
")",
";",
"if",
"(",
"request",
".",
"getUserPrincipal",
"(",
")",
"!=",
"null",
")",
"{",
"MDC",
".",
"put",
"(",
"\"user\"",
",",
"request",
".",
"getUserPrincipal",
"(",
")",
"!=",
"null",
"?",
"request",
".",
"getUserPrincipal",
"(",
")",
".",
"getName",
"(",
")",
":",
"null",
")",
";",
"}",
"if",
"(",
"!",
"StringUtils",
".",
"isNullOrEmptyTrimmed",
"(",
"request",
".",
"getQueryString",
"(",
")",
")",
")",
"{",
"MDC",
".",
"put",
"(",
"\"query\"",
",",
"request",
".",
"getQueryString",
"(",
")",
")",
";",
"}",
"}"
] |
Fills up MDC with request info
@param request to be logged
|
[
"Fills",
"up",
"MDC",
"with",
"request",
"info"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/logging/LoggingUtils.java#L29-L53
|
154,850
|
zandero/http
|
src/main/java/com/zandero/http/logging/LoggingUtils.java
|
LoggingUtils.prepareForLogging
|
public static void prepareForLogging(String path, String query) {
MDC.put("request_id", UUID.randomUUID().toString()); // generate unique request id ...
try {
URI uri = new URI(path);
MDC.put("host", uri.getHost());
MDC.put("scheme", uri.getScheme());
MDC.put("domain", UrlUtils.resolveDomain(uri.getPath()));
MDC.put("port", uri.getPort() + "");
MDC.put("path", uri.getPath());
}
catch (URISyntaxException e) {
// fall back
MDC.put("path", path);
}
MDC.put("timestamp", System.currentTimeMillis() + "");
if (!StringUtils.isNullOrEmptyTrimmed(query)) {
MDC.put("query", query);
}
}
|
java
|
public static void prepareForLogging(String path, String query) {
MDC.put("request_id", UUID.randomUUID().toString()); // generate unique request id ...
try {
URI uri = new URI(path);
MDC.put("host", uri.getHost());
MDC.put("scheme", uri.getScheme());
MDC.put("domain", UrlUtils.resolveDomain(uri.getPath()));
MDC.put("port", uri.getPort() + "");
MDC.put("path", uri.getPath());
}
catch (URISyntaxException e) {
// fall back
MDC.put("path", path);
}
MDC.put("timestamp", System.currentTimeMillis() + "");
if (!StringUtils.isNullOrEmptyTrimmed(query)) {
MDC.put("query", query);
}
}
|
[
"public",
"static",
"void",
"prepareForLogging",
"(",
"String",
"path",
",",
"String",
"query",
")",
"{",
"MDC",
".",
"put",
"(",
"\"request_id\"",
",",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"// generate unique request id ...",
"try",
"{",
"URI",
"uri",
"=",
"new",
"URI",
"(",
"path",
")",
";",
"MDC",
".",
"put",
"(",
"\"host\"",
",",
"uri",
".",
"getHost",
"(",
")",
")",
";",
"MDC",
".",
"put",
"(",
"\"scheme\"",
",",
"uri",
".",
"getScheme",
"(",
")",
")",
";",
"MDC",
".",
"put",
"(",
"\"domain\"",
",",
"UrlUtils",
".",
"resolveDomain",
"(",
"uri",
".",
"getPath",
"(",
")",
")",
")",
";",
"MDC",
".",
"put",
"(",
"\"port\"",
",",
"uri",
".",
"getPort",
"(",
")",
"+",
"\"\"",
")",
";",
"MDC",
".",
"put",
"(",
"\"path\"",
",",
"uri",
".",
"getPath",
"(",
")",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"// fall back",
"MDC",
".",
"put",
"(",
"\"path\"",
",",
"path",
")",
";",
"}",
"MDC",
".",
"put",
"(",
"\"timestamp\"",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"\"\"",
")",
";",
"if",
"(",
"!",
"StringUtils",
".",
"isNullOrEmptyTrimmed",
"(",
"query",
")",
")",
"{",
"MDC",
".",
"put",
"(",
"\"query\"",
",",
"query",
")",
";",
"}",
"}"
] |
Common purpose logging
@param path of request
@param query optional query of request
|
[
"Common",
"purpose",
"logging"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/logging/LoggingUtils.java#L60-L83
|
154,851
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.getThreadQueue
|
public static BlockingQueue<Runnable> getThreadQueue(
ExecutorService executorService) {
if (executorService instanceof ThreadPoolExecutor)
return ((ThreadPoolExecutor) executorService).getQueue();
throw JMExceptionManager.handleExceptionAndReturnRuntimeEx(log,
new IllegalArgumentException(
"Unsupported ExecutorService - Use ThrJMThread.newThreadPool Or newSingleThreadPool To Get ExecutorService !!!"),
"getThreadQueue", executorService);
}
|
java
|
public static BlockingQueue<Runnable> getThreadQueue(
ExecutorService executorService) {
if (executorService instanceof ThreadPoolExecutor)
return ((ThreadPoolExecutor) executorService).getQueue();
throw JMExceptionManager.handleExceptionAndReturnRuntimeEx(log,
new IllegalArgumentException(
"Unsupported ExecutorService - Use ThrJMThread.newThreadPool Or newSingleThreadPool To Get ExecutorService !!!"),
"getThreadQueue", executorService);
}
|
[
"public",
"static",
"BlockingQueue",
"<",
"Runnable",
">",
"getThreadQueue",
"(",
"ExecutorService",
"executorService",
")",
"{",
"if",
"(",
"executorService",
"instanceof",
"ThreadPoolExecutor",
")",
"return",
"(",
"(",
"ThreadPoolExecutor",
")",
"executorService",
")",
".",
"getQueue",
"(",
")",
";",
"throw",
"JMExceptionManager",
".",
"handleExceptionAndReturnRuntimeEx",
"(",
"log",
",",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported ExecutorService - Use ThrJMThread.newThreadPool Or newSingleThreadPool To Get ExecutorService !!!\"",
")",
",",
"\"getThreadQueue\"",
",",
"executorService",
")",
";",
"}"
] |
Gets thread queue.
@param executorService the executor service
@return the thread queue
|
[
"Gets",
"thread",
"queue",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L37-L45
|
154,852
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.awaitTermination
|
public static void awaitTermination(ExecutorService executorService,
long timeoutMillis) {
if (executorService.isTerminated())
return;
log.info("Start Terminating !!! - {}, timeoutMillis - {}",
executorService, timeoutMillis);
long startTimeMillis = System.currentTimeMillis();
try {
executorService
.awaitTermination(timeoutMillis, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
log.warn("Timeout Occur !!! - {}, timeoutMillis - {}",
executorService, timeoutMillis);
}
log.info("Terminated !!! - {} took {} ms", executorService,
startTimeMillis - System.currentTimeMillis());
}
|
java
|
public static void awaitTermination(ExecutorService executorService,
long timeoutMillis) {
if (executorService.isTerminated())
return;
log.info("Start Terminating !!! - {}, timeoutMillis - {}",
executorService, timeoutMillis);
long startTimeMillis = System.currentTimeMillis();
try {
executorService
.awaitTermination(timeoutMillis, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
log.warn("Timeout Occur !!! - {}, timeoutMillis - {}",
executorService, timeoutMillis);
}
log.info("Terminated !!! - {} took {} ms", executorService,
startTimeMillis - System.currentTimeMillis());
}
|
[
"public",
"static",
"void",
"awaitTermination",
"(",
"ExecutorService",
"executorService",
",",
"long",
"timeoutMillis",
")",
"{",
"if",
"(",
"executorService",
".",
"isTerminated",
"(",
")",
")",
"return",
";",
"log",
".",
"info",
"(",
"\"Start Terminating !!! - {}, timeoutMillis - {}\"",
",",
"executorService",
",",
"timeoutMillis",
")",
";",
"long",
"startTimeMillis",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"try",
"{",
"executorService",
".",
"awaitTermination",
"(",
"timeoutMillis",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"Timeout Occur !!! - {}, timeoutMillis - {}\"",
",",
"executorService",
",",
"timeoutMillis",
")",
";",
"}",
"log",
".",
"info",
"(",
"\"Terminated !!! - {} took {} ms\"",
",",
"executorService",
",",
"startTimeMillis",
"-",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"}"
] |
Await termination.
@param executorService the executor service
@param timeoutMillis the timeout millis
|
[
"Await",
"termination",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L92-L108
|
154,853
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.suspendWhenNull
|
public static <R> R suspendWhenNull(long intervalAsMillis,
Supplier<R> objectSupplier) {
R object = objectSupplier.get();
if (object == null) {
log.warn("Start Suspending !!!");
long startTimeMillis = System.currentTimeMillis();
while ((object = objectSupplier.get()) == null)
sleep(intervalAsMillis);
log.warn("Stop Suspending Over {} ms",
System.currentTimeMillis() - startTimeMillis);
}
return object;
}
|
java
|
public static <R> R suspendWhenNull(long intervalAsMillis,
Supplier<R> objectSupplier) {
R object = objectSupplier.get();
if (object == null) {
log.warn("Start Suspending !!!");
long startTimeMillis = System.currentTimeMillis();
while ((object = objectSupplier.get()) == null)
sleep(intervalAsMillis);
log.warn("Stop Suspending Over {} ms",
System.currentTimeMillis() - startTimeMillis);
}
return object;
}
|
[
"public",
"static",
"<",
"R",
">",
"R",
"suspendWhenNull",
"(",
"long",
"intervalAsMillis",
",",
"Supplier",
"<",
"R",
">",
"objectSupplier",
")",
"{",
"R",
"object",
"=",
"objectSupplier",
".",
"get",
"(",
")",
";",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"log",
".",
"warn",
"(",
"\"Start Suspending !!!\"",
")",
";",
"long",
"startTimeMillis",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"while",
"(",
"(",
"object",
"=",
"objectSupplier",
".",
"get",
"(",
")",
")",
"==",
"null",
")",
"sleep",
"(",
"intervalAsMillis",
")",
";",
"log",
".",
"warn",
"(",
"\"Stop Suspending Over {} ms\"",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startTimeMillis",
")",
";",
"}",
"return",
"object",
";",
"}"
] |
Suspend when null r.
@param <R> the type parameter
@param intervalAsMillis the interval as millis
@param objectSupplier the object supplier
@return the r
|
[
"Suspend",
"when",
"null",
"r",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L198-L210
|
154,854
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.run
|
public static <T> Future<T> run(Callable<T> callableWork,
long timeoutInSec) {
final ExecutorService threadPool = Executors.newFixedThreadPool(2);
Future<T> future = threadPool.submit(callableWork);
afterTimeout(timeoutInSec, threadPool, future);
return future;
}
|
java
|
public static <T> Future<T> run(Callable<T> callableWork,
long timeoutInSec) {
final ExecutorService threadPool = Executors.newFixedThreadPool(2);
Future<T> future = threadPool.submit(callableWork);
afterTimeout(timeoutInSec, threadPool, future);
return future;
}
|
[
"public",
"static",
"<",
"T",
">",
"Future",
"<",
"T",
">",
"run",
"(",
"Callable",
"<",
"T",
">",
"callableWork",
",",
"long",
"timeoutInSec",
")",
"{",
"final",
"ExecutorService",
"threadPool",
"=",
"Executors",
".",
"newFixedThreadPool",
"(",
"2",
")",
";",
"Future",
"<",
"T",
">",
"future",
"=",
"threadPool",
".",
"submit",
"(",
"callableWork",
")",
";",
"afterTimeout",
"(",
"timeoutInSec",
",",
"threadPool",
",",
"future",
")",
";",
"return",
"future",
";",
"}"
] |
Run future.
@param <T> the type parameter
@param callableWork the callable work
@param timeoutInSec the timeout in sec
@return the future
|
[
"Run",
"future",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L247-L253
|
154,855
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.newSingleScheduledThreadPool
|
public static ScheduledExecutorService newSingleScheduledThreadPool() {
ScheduledExecutorService scheduledExecutorService =
Executors.newScheduledThreadPool(1);
OS.addShutdownHook(scheduledExecutorService::shutdown);
return scheduledExecutorService;
}
|
java
|
public static ScheduledExecutorService newSingleScheduledThreadPool() {
ScheduledExecutorService scheduledExecutorService =
Executors.newScheduledThreadPool(1);
OS.addShutdownHook(scheduledExecutorService::shutdown);
return scheduledExecutorService;
}
|
[
"public",
"static",
"ScheduledExecutorService",
"newSingleScheduledThreadPool",
"(",
")",
"{",
"ScheduledExecutorService",
"scheduledExecutorService",
"=",
"Executors",
".",
"newScheduledThreadPool",
"(",
"1",
")",
";",
"OS",
".",
"addShutdownHook",
"(",
"scheduledExecutorService",
"::",
"shutdown",
")",
";",
"return",
"scheduledExecutorService",
";",
"}"
] |
New single scheduled thread pool scheduled executor service.
@return the scheduled executor service
|
[
"New",
"single",
"scheduled",
"thread",
"pool",
"scheduled",
"executor",
"service",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L284-L289
|
154,856
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.buildCallableWithLogging
|
public static <V> Callable<V> buildCallableWithLogging(String name,
Callable<V> callable, Object... params) {
return () -> supplyAsync(() -> {
try {
JMLog.debug(log, name, System.currentTimeMillis(), params);
return callable.call();
} catch (Exception e) {
return JMExceptionManager.handleExceptionAndReturnNull(log, e,
name, params);
}
}).get();
}
|
java
|
public static <V> Callable<V> buildCallableWithLogging(String name,
Callable<V> callable, Object... params) {
return () -> supplyAsync(() -> {
try {
JMLog.debug(log, name, System.currentTimeMillis(), params);
return callable.call();
} catch (Exception e) {
return JMExceptionManager.handleExceptionAndReturnNull(log, e,
name, params);
}
}).get();
}
|
[
"public",
"static",
"<",
"V",
">",
"Callable",
"<",
"V",
">",
"buildCallableWithLogging",
"(",
"String",
"name",
",",
"Callable",
"<",
"V",
">",
"callable",
",",
"Object",
"...",
"params",
")",
"{",
"return",
"(",
")",
"->",
"supplyAsync",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"JMLog",
".",
"debug",
"(",
"log",
",",
"name",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
",",
"params",
")",
";",
"return",
"callable",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"JMExceptionManager",
".",
"handleExceptionAndReturnNull",
"(",
"log",
",",
"e",
",",
"name",
",",
"params",
")",
";",
"}",
"}",
")",
".",
"get",
"(",
")",
";",
"}"
] |
Build callable with logging callable.
@param <V> the type parameter
@param name the name
@param callable the callable
@param params the params
@return the callable
|
[
"Build",
"callable",
"with",
"logging",
"callable",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L300-L311
|
154,857
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.buildRunnableWithLogging
|
public static Runnable buildRunnableWithLogging(String runnableName,
Runnable runnable, Object... params) {
return () -> {
JMLog.debug(log, runnableName, System.currentTimeMillis(), params);
runnable.run();
};
}
|
java
|
public static Runnable buildRunnableWithLogging(String runnableName,
Runnable runnable, Object... params) {
return () -> {
JMLog.debug(log, runnableName, System.currentTimeMillis(), params);
runnable.run();
};
}
|
[
"public",
"static",
"Runnable",
"buildRunnableWithLogging",
"(",
"String",
"runnableName",
",",
"Runnable",
"runnable",
",",
"Object",
"...",
"params",
")",
"{",
"return",
"(",
")",
"->",
"{",
"JMLog",
".",
"debug",
"(",
"log",
",",
"runnableName",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
",",
"params",
")",
";",
"runnable",
".",
"run",
"(",
")",
";",
"}",
";",
"}"
] |
Build runnable with logging runnable.
@param runnableName the runnable name
@param runnable the runnable
@param params the params
@return the runnable
|
[
"Build",
"runnable",
"with",
"logging",
"runnable",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L321-L327
|
154,858
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.runWithScheduleAtFixedRate
|
public static ScheduledFuture<?> runWithScheduleAtFixedRate(
long initialDelayMillis, long periodMillis, Runnable runnable) {
return runWithScheduleAtFixedRate(initialDelayMillis, periodMillis,
"runWithScheduleAtFixedRate", runnable);
}
|
java
|
public static ScheduledFuture<?> runWithScheduleAtFixedRate(
long initialDelayMillis, long periodMillis, Runnable runnable) {
return runWithScheduleAtFixedRate(initialDelayMillis, periodMillis,
"runWithScheduleAtFixedRate", runnable);
}
|
[
"public",
"static",
"ScheduledFuture",
"<",
"?",
">",
"runWithScheduleAtFixedRate",
"(",
"long",
"initialDelayMillis",
",",
"long",
"periodMillis",
",",
"Runnable",
"runnable",
")",
"{",
"return",
"runWithScheduleAtFixedRate",
"(",
"initialDelayMillis",
",",
"periodMillis",
",",
"\"runWithScheduleAtFixedRate\"",
",",
"runnable",
")",
";",
"}"
] |
Run with schedule at fixed rate scheduled future.
@param initialDelayMillis the initial delay millis
@param periodMillis the period millis
@param runnable the runnable
@return the scheduled future
|
[
"Run",
"with",
"schedule",
"at",
"fixed",
"rate",
"scheduled",
"future",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L363-L367
|
154,859
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.runWithScheduleAtFixedRateOnStartTime
|
public static ScheduledFuture<?> runWithScheduleAtFixedRateOnStartTime(
ZonedDateTime startDateTime, long periodMillis, Runnable runnable) {
return runWithScheduleAtFixedRate(calInitialDelayMillis(startDateTime),
periodMillis, "runWithScheduleAtFixedRateOnStartTime",
runnable);
}
|
java
|
public static ScheduledFuture<?> runWithScheduleAtFixedRateOnStartTime(
ZonedDateTime startDateTime, long periodMillis, Runnable runnable) {
return runWithScheduleAtFixedRate(calInitialDelayMillis(startDateTime),
periodMillis, "runWithScheduleAtFixedRateOnStartTime",
runnable);
}
|
[
"public",
"static",
"ScheduledFuture",
"<",
"?",
">",
"runWithScheduleAtFixedRateOnStartTime",
"(",
"ZonedDateTime",
"startDateTime",
",",
"long",
"periodMillis",
",",
"Runnable",
"runnable",
")",
"{",
"return",
"runWithScheduleAtFixedRate",
"(",
"calInitialDelayMillis",
"(",
"startDateTime",
")",
",",
"periodMillis",
",",
"\"runWithScheduleAtFixedRateOnStartTime\"",
",",
"runnable",
")",
";",
"}"
] |
Run with schedule at fixed rate on start time scheduled future.
@param startDateTime the start date time
@param periodMillis the period millis
@param runnable the runnable
@return the scheduled future
|
[
"Run",
"with",
"schedule",
"at",
"fixed",
"rate",
"on",
"start",
"time",
"scheduled",
"future",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L377-L382
|
154,860
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.runWithScheduleWithFixedDelay
|
public static ScheduledFuture<?> runWithScheduleWithFixedDelay(
long initialDelayMillis, long delayMillis, Runnable runnable) {
return runWithScheduleWithFixedDelay(initialDelayMillis, delayMillis,
"runWithScheduleWithFixedDelay", runnable);
}
|
java
|
public static ScheduledFuture<?> runWithScheduleWithFixedDelay(
long initialDelayMillis, long delayMillis, Runnable runnable) {
return runWithScheduleWithFixedDelay(initialDelayMillis, delayMillis,
"runWithScheduleWithFixedDelay", runnable);
}
|
[
"public",
"static",
"ScheduledFuture",
"<",
"?",
">",
"runWithScheduleWithFixedDelay",
"(",
"long",
"initialDelayMillis",
",",
"long",
"delayMillis",
",",
"Runnable",
"runnable",
")",
"{",
"return",
"runWithScheduleWithFixedDelay",
"(",
"initialDelayMillis",
",",
"delayMillis",
",",
"\"runWithScheduleWithFixedDelay\"",
",",
"runnable",
")",
";",
"}"
] |
Run with schedule with fixed delay scheduled future.
@param initialDelayMillis the initial delay millis
@param delayMillis the delay millis
@param runnable the runnable
@return the scheduled future
|
[
"Run",
"with",
"schedule",
"with",
"fixed",
"delay",
"scheduled",
"future",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L401-L405
|
154,861
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.runWithScheduleWithFixedDelayOnStartTime
|
public static ScheduledFuture<?> runWithScheduleWithFixedDelayOnStartTime(
ZonedDateTime startDateTime, long delayMillis, Runnable runnable) {
return runWithScheduleWithFixedDelay(
calInitialDelayMillis(startDateTime), delayMillis,
"runWithScheduleWithFixedDelayOnStartTime", runnable);
}
|
java
|
public static ScheduledFuture<?> runWithScheduleWithFixedDelayOnStartTime(
ZonedDateTime startDateTime, long delayMillis, Runnable runnable) {
return runWithScheduleWithFixedDelay(
calInitialDelayMillis(startDateTime), delayMillis,
"runWithScheduleWithFixedDelayOnStartTime", runnable);
}
|
[
"public",
"static",
"ScheduledFuture",
"<",
"?",
">",
"runWithScheduleWithFixedDelayOnStartTime",
"(",
"ZonedDateTime",
"startDateTime",
",",
"long",
"delayMillis",
",",
"Runnable",
"runnable",
")",
"{",
"return",
"runWithScheduleWithFixedDelay",
"(",
"calInitialDelayMillis",
"(",
"startDateTime",
")",
",",
"delayMillis",
",",
"\"runWithScheduleWithFixedDelayOnStartTime\"",
",",
"runnable",
")",
";",
"}"
] |
Run with schedule with fixed delay on start time scheduled future.
@param startDateTime the start date time
@param delayMillis the delay millis
@param runnable the runnable
@return the scheduled future
|
[
"Run",
"with",
"schedule",
"with",
"fixed",
"delay",
"on",
"start",
"time",
"scheduled",
"future",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L420-L425
|
154,862
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.startWithSingleExecutorService
|
public static ExecutorService startWithSingleExecutorService(String message,
Runnable runnable) {
return startWithExecutorService(newSingleThreadPool(), message,
runnable);
}
|
java
|
public static ExecutorService startWithSingleExecutorService(String message,
Runnable runnable) {
return startWithExecutorService(newSingleThreadPool(), message,
runnable);
}
|
[
"public",
"static",
"ExecutorService",
"startWithSingleExecutorService",
"(",
"String",
"message",
",",
"Runnable",
"runnable",
")",
"{",
"return",
"startWithExecutorService",
"(",
"newSingleThreadPool",
"(",
")",
",",
"message",
",",
"runnable",
")",
";",
"}"
] |
Start with single executor service executor service.
@param message the message
@param runnable the runnable
@return the executor service
|
[
"Start",
"with",
"single",
"executor",
"service",
"executor",
"service",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L554-L558
|
154,863
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.getLimitedBlockingQueue
|
public static <E> BlockingQueue<E> getLimitedBlockingQueue(int maxQueue) {
return new LinkedBlockingQueue<E>(maxQueue) {
@Override
public boolean offer(E e) {
return putInsteadOfOffer(this, e);
}
};
}
|
java
|
public static <E> BlockingQueue<E> getLimitedBlockingQueue(int maxQueue) {
return new LinkedBlockingQueue<E>(maxQueue) {
@Override
public boolean offer(E e) {
return putInsteadOfOffer(this, e);
}
};
}
|
[
"public",
"static",
"<",
"E",
">",
"BlockingQueue",
"<",
"E",
">",
"getLimitedBlockingQueue",
"(",
"int",
"maxQueue",
")",
"{",
"return",
"new",
"LinkedBlockingQueue",
"<",
"E",
">",
"(",
"maxQueue",
")",
"{",
"@",
"Override",
"public",
"boolean",
"offer",
"(",
"E",
"e",
")",
"{",
"return",
"putInsteadOfOffer",
"(",
"this",
",",
"e",
")",
";",
"}",
"}",
";",
"}"
] |
Gets limited blocking queue.
@param <E> the type parameter
@param maxQueue the max queue
@return the limited blocking queue
|
[
"Gets",
"limited",
"blocking",
"queue",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L598-L605
|
154,864
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.getWaitingLimitedBlockingQueue
|
public static <E> BlockingQueue<E> getWaitingLimitedBlockingQueue(
long waitingMillis, int maxQueue) {
return new LinkedBlockingQueue<E>(maxQueue) {
@Override
public boolean offer(E e) {
if (size() >= maxQueue) {
sleep(waitingMillis);
log.warn("Wait For {} ms And Blocking !!! - maxQueue = {}",
waitingMillis, maxQueue);
}
return putInsteadOfOffer(this, e);
}
};
}
|
java
|
public static <E> BlockingQueue<E> getWaitingLimitedBlockingQueue(
long waitingMillis, int maxQueue) {
return new LinkedBlockingQueue<E>(maxQueue) {
@Override
public boolean offer(E e) {
if (size() >= maxQueue) {
sleep(waitingMillis);
log.warn("Wait For {} ms And Blocking !!! - maxQueue = {}",
waitingMillis, maxQueue);
}
return putInsteadOfOffer(this, e);
}
};
}
|
[
"public",
"static",
"<",
"E",
">",
"BlockingQueue",
"<",
"E",
">",
"getWaitingLimitedBlockingQueue",
"(",
"long",
"waitingMillis",
",",
"int",
"maxQueue",
")",
"{",
"return",
"new",
"LinkedBlockingQueue",
"<",
"E",
">",
"(",
"maxQueue",
")",
"{",
"@",
"Override",
"public",
"boolean",
"offer",
"(",
"E",
"e",
")",
"{",
"if",
"(",
"size",
"(",
")",
">=",
"maxQueue",
")",
"{",
"sleep",
"(",
"waitingMillis",
")",
";",
"log",
".",
"warn",
"(",
"\"Wait For {} ms And Blocking !!! - maxQueue = {}\"",
",",
"waitingMillis",
",",
"maxQueue",
")",
";",
"}",
"return",
"putInsteadOfOffer",
"(",
"this",
",",
"e",
")",
";",
"}",
"}",
";",
"}"
] |
Gets waiting limited blocking queue.
@param <E> the type parameter
@param waitingMillis the waiting millis
@param maxQueue the max queue
@return the waiting limited blocking queue
|
[
"Gets",
"waiting",
"limited",
"blocking",
"queue",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L615-L628
|
154,865
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMThread.java
|
JMThread.newMaxQueueThreadPool
|
public static ExecutorService newMaxQueueThreadPool(int numWorkerThreads,
long waitingMillis, int maxQueue) {
return new ThreadPoolExecutor(numWorkerThreads, numWorkerThreads,
0L, TimeUnit.MILLISECONDS,
waitingMillis > 0 ? getWaitingLimitedBlockingQueue(
waitingMillis, maxQueue) : getLimitedBlockingQueue(
maxQueue));
}
|
java
|
public static ExecutorService newMaxQueueThreadPool(int numWorkerThreads,
long waitingMillis, int maxQueue) {
return new ThreadPoolExecutor(numWorkerThreads, numWorkerThreads,
0L, TimeUnit.MILLISECONDS,
waitingMillis > 0 ? getWaitingLimitedBlockingQueue(
waitingMillis, maxQueue) : getLimitedBlockingQueue(
maxQueue));
}
|
[
"public",
"static",
"ExecutorService",
"newMaxQueueThreadPool",
"(",
"int",
"numWorkerThreads",
",",
"long",
"waitingMillis",
",",
"int",
"maxQueue",
")",
"{",
"return",
"new",
"ThreadPoolExecutor",
"(",
"numWorkerThreads",
",",
"numWorkerThreads",
",",
"0L",
",",
"TimeUnit",
".",
"MILLISECONDS",
",",
"waitingMillis",
">",
"0",
"?",
"getWaitingLimitedBlockingQueue",
"(",
"waitingMillis",
",",
"maxQueue",
")",
":",
"getLimitedBlockingQueue",
"(",
"maxQueue",
")",
")",
";",
"}"
] |
New max queue thread pool executor service.
@param numWorkerThreads the num worker threads
@param waitingMillis the waiting millis
@param maxQueue the max queue
@return the executor service
|
[
"New",
"max",
"queue",
"thread",
"pool",
"executor",
"service",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMThread.java#L648-L655
|
154,866
|
app55/app55-java
|
src/support/java/com/googlecode/openbeans/Statement.java
|
Statement.findMethod
|
static Method findMethod(Class<?> clazz, String methodName, Object[] args, boolean isStatic) throws NoSuchMethodException
{
Class<?>[] argTypes = getTypes(args);
Method[] methods = null;
if (classMethodsCache.containsKey(clazz))
{
methods = classMethodsCache.get(clazz);
}
else
{
methods = clazz.getMethods();
classMethodsCache.put(clazz, methods);
}
ArrayList<Method> fitMethods = new ArrayList<Method>();
for (Method method : methods)
{
if (methodName.equals(method.getName()))
{
if (!isStatic || Modifier.isStatic(method.getModifiers()))
{
if (match(argTypes, method.getParameterTypes()))
{
fitMethods.add(method);
}
}
}
}
int fitSize = fitMethods.size();
if (fitSize == 0)
{
throw new NoSuchMethodException(Messages.getString("beans.41", methodName)); //$NON-NLS-1$
}
if (fitSize == 1)
{
return fitMethods.get(0);
}
// find the most relevant one
MethodComparator comparator = new MethodComparator(methodName, argTypes);
Method[] fitMethodArray = fitMethods.toArray(new Method[fitSize]);
Method onlyMethod = fitMethodArray[0];
Class<?> onlyReturnType, fitReturnType;
int difference;
for (int i = 1; i < fitMethodArray.length; i++)
{
// if 2 methods have same relevance, check their return type
if ((difference = comparator.compare(onlyMethod, fitMethodArray[i])) == 0)
{
// if 2 methods have the same signature, check their return type
onlyReturnType = onlyMethod.getReturnType();
fitReturnType = fitMethodArray[i].getReturnType();
if (onlyReturnType == fitReturnType)
{
// if 2 methods have the same relevance and return type
throw new NoSuchMethodException(Messages.getString("beans.62", methodName)); //$NON-NLS-1$
}
if (onlyReturnType.isAssignableFrom(fitReturnType))
{
// if onlyReturnType is super class or interface of
// fitReturnType, set onlyMethod to fitMethodArray[i]
onlyMethod = fitMethodArray[i];
}
}
if (difference > 0)
{
onlyMethod = fitMethodArray[i];
}
}
return onlyMethod;
}
|
java
|
static Method findMethod(Class<?> clazz, String methodName, Object[] args, boolean isStatic) throws NoSuchMethodException
{
Class<?>[] argTypes = getTypes(args);
Method[] methods = null;
if (classMethodsCache.containsKey(clazz))
{
methods = classMethodsCache.get(clazz);
}
else
{
methods = clazz.getMethods();
classMethodsCache.put(clazz, methods);
}
ArrayList<Method> fitMethods = new ArrayList<Method>();
for (Method method : methods)
{
if (methodName.equals(method.getName()))
{
if (!isStatic || Modifier.isStatic(method.getModifiers()))
{
if (match(argTypes, method.getParameterTypes()))
{
fitMethods.add(method);
}
}
}
}
int fitSize = fitMethods.size();
if (fitSize == 0)
{
throw new NoSuchMethodException(Messages.getString("beans.41", methodName)); //$NON-NLS-1$
}
if (fitSize == 1)
{
return fitMethods.get(0);
}
// find the most relevant one
MethodComparator comparator = new MethodComparator(methodName, argTypes);
Method[] fitMethodArray = fitMethods.toArray(new Method[fitSize]);
Method onlyMethod = fitMethodArray[0];
Class<?> onlyReturnType, fitReturnType;
int difference;
for (int i = 1; i < fitMethodArray.length; i++)
{
// if 2 methods have same relevance, check their return type
if ((difference = comparator.compare(onlyMethod, fitMethodArray[i])) == 0)
{
// if 2 methods have the same signature, check their return type
onlyReturnType = onlyMethod.getReturnType();
fitReturnType = fitMethodArray[i].getReturnType();
if (onlyReturnType == fitReturnType)
{
// if 2 methods have the same relevance and return type
throw new NoSuchMethodException(Messages.getString("beans.62", methodName)); //$NON-NLS-1$
}
if (onlyReturnType.isAssignableFrom(fitReturnType))
{
// if onlyReturnType is super class or interface of
// fitReturnType, set onlyMethod to fitMethodArray[i]
onlyMethod = fitMethodArray[i];
}
}
if (difference > 0)
{
onlyMethod = fitMethodArray[i];
}
}
return onlyMethod;
}
|
[
"static",
"Method",
"findMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"methodName",
",",
"Object",
"[",
"]",
"args",
",",
"boolean",
"isStatic",
")",
"throws",
"NoSuchMethodException",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"argTypes",
"=",
"getTypes",
"(",
"args",
")",
";",
"Method",
"[",
"]",
"methods",
"=",
"null",
";",
"if",
"(",
"classMethodsCache",
".",
"containsKey",
"(",
"clazz",
")",
")",
"{",
"methods",
"=",
"classMethodsCache",
".",
"get",
"(",
"clazz",
")",
";",
"}",
"else",
"{",
"methods",
"=",
"clazz",
".",
"getMethods",
"(",
")",
";",
"classMethodsCache",
".",
"put",
"(",
"clazz",
",",
"methods",
")",
";",
"}",
"ArrayList",
"<",
"Method",
">",
"fitMethods",
"=",
"new",
"ArrayList",
"<",
"Method",
">",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"methods",
")",
"{",
"if",
"(",
"methodName",
".",
"equals",
"(",
"method",
".",
"getName",
"(",
")",
")",
")",
"{",
"if",
"(",
"!",
"isStatic",
"||",
"Modifier",
".",
"isStatic",
"(",
"method",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"if",
"(",
"match",
"(",
"argTypes",
",",
"method",
".",
"getParameterTypes",
"(",
")",
")",
")",
"{",
"fitMethods",
".",
"add",
"(",
"method",
")",
";",
"}",
"}",
"}",
"}",
"int",
"fitSize",
"=",
"fitMethods",
".",
"size",
"(",
")",
";",
"if",
"(",
"fitSize",
"==",
"0",
")",
"{",
"throw",
"new",
"NoSuchMethodException",
"(",
"Messages",
".",
"getString",
"(",
"\"beans.41\"",
",",
"methodName",
")",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"fitSize",
"==",
"1",
")",
"{",
"return",
"fitMethods",
".",
"get",
"(",
"0",
")",
";",
"}",
"// find the most relevant one",
"MethodComparator",
"comparator",
"=",
"new",
"MethodComparator",
"(",
"methodName",
",",
"argTypes",
")",
";",
"Method",
"[",
"]",
"fitMethodArray",
"=",
"fitMethods",
".",
"toArray",
"(",
"new",
"Method",
"[",
"fitSize",
"]",
")",
";",
"Method",
"onlyMethod",
"=",
"fitMethodArray",
"[",
"0",
"]",
";",
"Class",
"<",
"?",
">",
"onlyReturnType",
",",
"fitReturnType",
";",
"int",
"difference",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"fitMethodArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"// if 2 methods have same relevance, check their return type",
"if",
"(",
"(",
"difference",
"=",
"comparator",
".",
"compare",
"(",
"onlyMethod",
",",
"fitMethodArray",
"[",
"i",
"]",
")",
")",
"==",
"0",
")",
"{",
"// if 2 methods have the same signature, check their return type",
"onlyReturnType",
"=",
"onlyMethod",
".",
"getReturnType",
"(",
")",
";",
"fitReturnType",
"=",
"fitMethodArray",
"[",
"i",
"]",
".",
"getReturnType",
"(",
")",
";",
"if",
"(",
"onlyReturnType",
"==",
"fitReturnType",
")",
"{",
"// if 2 methods have the same relevance and return type",
"throw",
"new",
"NoSuchMethodException",
"(",
"Messages",
".",
"getString",
"(",
"\"beans.62\"",
",",
"methodName",
")",
")",
";",
"//$NON-NLS-1$",
"}",
"if",
"(",
"onlyReturnType",
".",
"isAssignableFrom",
"(",
"fitReturnType",
")",
")",
"{",
"// if onlyReturnType is super class or interface of",
"// fitReturnType, set onlyMethod to fitMethodArray[i]",
"onlyMethod",
"=",
"fitMethodArray",
"[",
"i",
"]",
";",
"}",
"}",
"if",
"(",
"difference",
">",
"0",
")",
"{",
"onlyMethod",
"=",
"fitMethodArray",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"onlyMethod",
";",
"}"
] |
Searches for best matching method for given name and argument types.
|
[
"Searches",
"for",
"best",
"matching",
"method",
"for",
"given",
"name",
"and",
"argument",
"types",
"."
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/Statement.java#L401-L472
|
154,867
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.removeAllIfByKey
|
public static <K, V> List<V> removeAllIfByKey(Map<K, V> map,
Predicate<? super K> filter) {
return map.keySet().stream().filter(filter).collect(toList())
.stream().map(map::remove).collect(toList());
}
|
java
|
public static <K, V> List<V> removeAllIfByKey(Map<K, V> map,
Predicate<? super K> filter) {
return map.keySet().stream().filter(filter).collect(toList())
.stream().map(map::remove).collect(toList());
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"List",
"<",
"V",
">",
"removeAllIfByKey",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Predicate",
"<",
"?",
"super",
"K",
">",
"filter",
")",
"{",
"return",
"map",
".",
"keySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"filter",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"map",
"::",
"remove",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"}"
] |
Remove all if by key list.
@param <K> the type parameter
@param <V> the type parameter
@param map the map
@param filter the filter
@return the list
|
[
"Remove",
"all",
"if",
"by",
"key",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L32-L36
|
154,868
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.removeAllIfByEntry
|
public static <K, V> List<V> removeAllIfByEntry(Map<K, V> map,
Predicate<? super Entry<K, V>> filter) {
return getEntryStreamWithFilter(map, filter).map(Entry::getKey)
.collect(toList()).stream().map(map::remove)
.collect(toList());
}
|
java
|
public static <K, V> List<V> removeAllIfByEntry(Map<K, V> map,
Predicate<? super Entry<K, V>> filter) {
return getEntryStreamWithFilter(map, filter).map(Entry::getKey)
.collect(toList()).stream().map(map::remove)
.collect(toList());
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"List",
"<",
"V",
">",
"removeAllIfByEntry",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Predicate",
"<",
"?",
"super",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"filter",
")",
"{",
"return",
"getEntryStreamWithFilter",
"(",
"map",
",",
"filter",
")",
".",
"map",
"(",
"Entry",
"::",
"getKey",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"map",
"::",
"remove",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"}"
] |
Remove all if by entry list.
@param <K> the type parameter
@param <V> the type parameter
@param map the map
@param filter the filter
@return the list
|
[
"Remove",
"all",
"if",
"by",
"entry",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L47-L52
|
154,869
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.getEntryStreamWithFilter
|
public static <K, V> Stream<Entry<K, V>> getEntryStreamWithFilter(
Map<K, V> map, Predicate<? super Entry<K, V>> predicate) {
return buildEntryStream(map).filter(predicate);
}
|
java
|
public static <K, V> Stream<Entry<K, V>> getEntryStreamWithFilter(
Map<K, V> map, Predicate<? super Entry<K, V>> predicate) {
return buildEntryStream(map).filter(predicate);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"Stream",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"getEntryStreamWithFilter",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Predicate",
"<",
"?",
"super",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"predicate",
")",
"{",
"return",
"buildEntryStream",
"(",
"map",
")",
".",
"filter",
"(",
"predicate",
")",
";",
"}"
] |
Gets entry stream with filter.
@param <K> the type parameter
@param <V> the type parameter
@param map the map
@param predicate the predicate
@return the entry stream with filter
|
[
"Gets",
"entry",
"stream",
"with",
"filter",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L63-L66
|
154,870
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.getOrElse
|
public static <K, V> V getOrElse(Map<K, V> map, K key,
Supplier<V> valueSupplier) {
return JMOptional.getOptional(map, key).orElseGet(valueSupplier);
}
|
java
|
public static <K, V> V getOrElse(Map<K, V> map, K key,
Supplier<V> valueSupplier) {
return JMOptional.getOptional(map, key).orElseGet(valueSupplier);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"V",
"getOrElse",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"K",
"key",
",",
"Supplier",
"<",
"V",
">",
"valueSupplier",
")",
"{",
"return",
"JMOptional",
".",
"getOptional",
"(",
"map",
",",
"key",
")",
".",
"orElseGet",
"(",
"valueSupplier",
")",
";",
"}"
] |
Gets or else.
@param <K> the type parameter
@param <V> the type parameter
@param map the map
@param key the key
@param valueSupplier the value supplier
@return the or else
|
[
"Gets",
"or",
"else",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L90-L93
|
154,871
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.putGetNew
|
public static <V, K> V putGetNew(Map<K, V> map, K key, V newValue) {
synchronized (map) {
map.put(key, newValue);
return newValue;
}
}
|
java
|
public static <V, K> V putGetNew(Map<K, V> map, K key, V newValue) {
synchronized (map) {
map.put(key, newValue);
return newValue;
}
}
|
[
"public",
"static",
"<",
"V",
",",
"K",
">",
"V",
"putGetNew",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"K",
"key",
",",
"V",
"newValue",
")",
"{",
"synchronized",
"(",
"map",
")",
"{",
"map",
".",
"put",
"(",
"key",
",",
"newValue",
")",
";",
"return",
"newValue",
";",
"}",
"}"
] |
Put get new v.
@param <V> the type parameter
@param <K> the type parameter
@param map the map
@param key the key
@param newValue the new value
@return the v
|
[
"Put",
"get",
"new",
"v",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L122-L127
|
154,872
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newChangedKeyMap
|
public static <K, V, NK> Map<NK, V> newChangedKeyMap(Map<K, V> map,
Function<K, NK> changingKeyFunction) {
return buildEntryStream(map)
.collect(toMap(
entry -> changingKeyFunction.apply(entry.getKey()),
Entry::getValue));
}
|
java
|
public static <K, V, NK> Map<NK, V> newChangedKeyMap(Map<K, V> map,
Function<K, NK> changingKeyFunction) {
return buildEntryStream(map)
.collect(toMap(
entry -> changingKeyFunction.apply(entry.getKey()),
Entry::getValue));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"NK",
">",
"Map",
"<",
"NK",
",",
"V",
">",
"newChangedKeyMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Function",
"<",
"K",
",",
"NK",
">",
"changingKeyFunction",
")",
"{",
"return",
"buildEntryStream",
"(",
"map",
")",
".",
"collect",
"(",
"toMap",
"(",
"entry",
"->",
"changingKeyFunction",
".",
"apply",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
",",
"Entry",
"::",
"getValue",
")",
")",
";",
"}"
] |
New changed key map map.
@param <K> the type parameter
@param <V> the type parameter
@param <NK> the type parameter
@param map the map
@param changingKeyFunction the changing key function
@return the map
|
[
"New",
"changed",
"key",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L159-L165
|
154,873
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newChangedKeyWithEntryMap
|
public static <K, V, NK> Map<NK, V> newChangedKeyWithEntryMap(
Map<K, V> map,
Function<Entry<K, V>, NK> changingKeyFunction) {
return buildEntryStream(map).collect(
toMap(changingKeyFunction, Entry::getValue));
}
|
java
|
public static <K, V, NK> Map<NK, V> newChangedKeyWithEntryMap(
Map<K, V> map,
Function<Entry<K, V>, NK> changingKeyFunction) {
return buildEntryStream(map).collect(
toMap(changingKeyFunction, Entry::getValue));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"NK",
">",
"Map",
"<",
"NK",
",",
"V",
">",
"newChangedKeyWithEntryMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Function",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
",",
"NK",
">",
"changingKeyFunction",
")",
"{",
"return",
"buildEntryStream",
"(",
"map",
")",
".",
"collect",
"(",
"toMap",
"(",
"changingKeyFunction",
",",
"Entry",
"::",
"getValue",
")",
")",
";",
"}"
] |
New changed key with entry map map.
@param <K> the type parameter
@param <V> the type parameter
@param <NK> the type parameter
@param map the map
@param changingKeyFunction the changing key function
@return the map
|
[
"New",
"changed",
"key",
"with",
"entry",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L177-L182
|
154,874
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newFilteredChangedKeyWithEntryMap
|
public static <K, V, NK> Map<NK, V> newFilteredChangedKeyWithEntryMap(
Map<K, V> map, Predicate<? super Entry<K, V>> filter,
Function<Entry<K, V>, NK> changingKeyFunction) {
return getEntryStreamWithFilter(map, filter).collect(
toMap(changingKeyFunction, Entry::getValue));
}
|
java
|
public static <K, V, NK> Map<NK, V> newFilteredChangedKeyWithEntryMap(
Map<K, V> map, Predicate<? super Entry<K, V>> filter,
Function<Entry<K, V>, NK> changingKeyFunction) {
return getEntryStreamWithFilter(map, filter).collect(
toMap(changingKeyFunction, Entry::getValue));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"NK",
">",
"Map",
"<",
"NK",
",",
"V",
">",
"newFilteredChangedKeyWithEntryMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Predicate",
"<",
"?",
"super",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"filter",
",",
"Function",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
",",
"NK",
">",
"changingKeyFunction",
")",
"{",
"return",
"getEntryStreamWithFilter",
"(",
"map",
",",
"filter",
")",
".",
"collect",
"(",
"toMap",
"(",
"changingKeyFunction",
",",
"Entry",
"::",
"getValue",
")",
")",
";",
"}"
] |
New filtered changed key with entry map map.
@param <K> the type parameter
@param <V> the type parameter
@param <NK> the type parameter
@param map the map
@param filter the filter
@param changingKeyFunction the changing key function
@return the map
|
[
"New",
"filtered",
"changed",
"key",
"with",
"entry",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L214-L219
|
154,875
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newChangedValueMap
|
public static <K, V, NV> Map<K, NV> newChangedValueMap(Map<K, V> map,
Function<V, NV> changingValueFunction) {
synchronized (map) {
return buildEntryStream(map).collect(toMap(Entry::getKey,
entry -> changingValueFunction.apply(entry.getValue())));
}
}
|
java
|
public static <K, V, NV> Map<K, NV> newChangedValueMap(Map<K, V> map,
Function<V, NV> changingValueFunction) {
synchronized (map) {
return buildEntryStream(map).collect(toMap(Entry::getKey,
entry -> changingValueFunction.apply(entry.getValue())));
}
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"NV",
">",
"Map",
"<",
"K",
",",
"NV",
">",
"newChangedValueMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Function",
"<",
"V",
",",
"NV",
">",
"changingValueFunction",
")",
"{",
"synchronized",
"(",
"map",
")",
"{",
"return",
"buildEntryStream",
"(",
"map",
")",
".",
"collect",
"(",
"toMap",
"(",
"Entry",
"::",
"getKey",
",",
"entry",
"->",
"changingValueFunction",
".",
"apply",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
")",
";",
"}",
"}"
] |
New changed value map map.
@param <K> the type parameter
@param <V> the type parameter
@param <NV> the type parameter
@param map the map
@param changingValueFunction the changing value function
@return the map
|
[
"New",
"changed",
"value",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L231-L237
|
154,876
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newChangedValueWithEntryMap
|
public static <K, V, NV> Map<K, NV> newChangedValueWithEntryMap(
Map<K, V> map,
Function<Entry<K, V>, NV> changingValueFunction) {
return buildEntryStream(map).collect(
toMap(Entry::getKey, changingValueFunction));
}
|
java
|
public static <K, V, NV> Map<K, NV> newChangedValueWithEntryMap(
Map<K, V> map,
Function<Entry<K, V>, NV> changingValueFunction) {
return buildEntryStream(map).collect(
toMap(Entry::getKey, changingValueFunction));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"NV",
">",
"Map",
"<",
"K",
",",
"NV",
">",
"newChangedValueWithEntryMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Function",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
",",
"NV",
">",
"changingValueFunction",
")",
"{",
"return",
"buildEntryStream",
"(",
"map",
")",
".",
"collect",
"(",
"toMap",
"(",
"Entry",
"::",
"getKey",
",",
"changingValueFunction",
")",
")",
";",
"}"
] |
New changed value with entry map map.
@param <K> the type parameter
@param <V> the type parameter
@param <NV> the type parameter
@param map the map
@param changingValueFunction the changing value function
@return the map
|
[
"New",
"changed",
"value",
"with",
"entry",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L249-L254
|
154,877
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newFilteredChangedValueWithEntryMap
|
public static <K, V, NV> Map<K, NV> newFilteredChangedValueWithEntryMap(
Map<K, V> map, Predicate<Entry<K, V>> filter,
Function<Entry<K, V>, NV> changingValueFunction) {
return getEntryStreamWithFilter(map, filter).collect(
toMap(Entry::getKey, changingValueFunction::apply));
}
|
java
|
public static <K, V, NV> Map<K, NV> newFilteredChangedValueWithEntryMap(
Map<K, V> map, Predicate<Entry<K, V>> filter,
Function<Entry<K, V>, NV> changingValueFunction) {
return getEntryStreamWithFilter(map, filter).collect(
toMap(Entry::getKey, changingValueFunction::apply));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"NV",
">",
"Map",
"<",
"K",
",",
"NV",
">",
"newFilteredChangedValueWithEntryMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Predicate",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"filter",
",",
"Function",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
",",
"NV",
">",
"changingValueFunction",
")",
"{",
"return",
"getEntryStreamWithFilter",
"(",
"map",
",",
"filter",
")",
".",
"collect",
"(",
"toMap",
"(",
"Entry",
"::",
"getKey",
",",
"changingValueFunction",
"::",
"apply",
")",
")",
";",
"}"
] |
New filtered changed value with entry map map.
@param <K> the type parameter
@param <V> the type parameter
@param <NV> the type parameter
@param map the map
@param filter the filter
@param changingValueFunction the changing value function
@return the map
|
[
"New",
"filtered",
"changed",
"value",
"with",
"entry",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L286-L291
|
154,878
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newChangedKeyValueMap
|
public static <K, V, NK, NV> Map<NK, NV> newChangedKeyValueMap(
Map<K, V> map, Function<K, NK> changingKeyFunction,
Function<V, NV> changingValueFunction) {
return buildEntryStream(map).collect(toMap(
entry -> changingKeyFunction.apply(entry.getKey()),
entry -> changingValueFunction.apply(entry.getValue())));
}
|
java
|
public static <K, V, NK, NV> Map<NK, NV> newChangedKeyValueMap(
Map<K, V> map, Function<K, NK> changingKeyFunction,
Function<V, NV> changingValueFunction) {
return buildEntryStream(map).collect(toMap(
entry -> changingKeyFunction.apply(entry.getKey()),
entry -> changingValueFunction.apply(entry.getValue())));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"NK",
",",
"NV",
">",
"Map",
"<",
"NK",
",",
"NV",
">",
"newChangedKeyValueMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Function",
"<",
"K",
",",
"NK",
">",
"changingKeyFunction",
",",
"Function",
"<",
"V",
",",
"NV",
">",
"changingValueFunction",
")",
"{",
"return",
"buildEntryStream",
"(",
"map",
")",
".",
"collect",
"(",
"toMap",
"(",
"entry",
"->",
"changingKeyFunction",
".",
"apply",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
",",
"entry",
"->",
"changingValueFunction",
".",
"apply",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
")",
";",
"}"
] |
New changed key value map map.
@param <K> the type parameter
@param <V> the type parameter
@param <NK> the type parameter
@param <NV> the type parameter
@param map the map
@param changingKeyFunction the changing key function
@param changingValueFunction the changing value function
@return the map
|
[
"New",
"changed",
"key",
"value",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L305-L311
|
154,879
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newFilteredChangedKeyValueMap
|
public static <K, V, NK, NV> Map<NK, NV> newFilteredChangedKeyValueMap(
Map<K, V> map, Predicate<? super Entry<K, V>> filter,
Function<K, NK> changingKeyFunction,
Function<V, NV> changingValueFunction) {
return getEntryStreamWithFilter(map, filter).collect(toMap(
entry -> changingKeyFunction.apply(entry.getKey()),
entry -> changingValueFunction.apply(entry.getValue())));
}
|
java
|
public static <K, V, NK, NV> Map<NK, NV> newFilteredChangedKeyValueMap(
Map<K, V> map, Predicate<? super Entry<K, V>> filter,
Function<K, NK> changingKeyFunction,
Function<V, NV> changingValueFunction) {
return getEntryStreamWithFilter(map, filter).collect(toMap(
entry -> changingKeyFunction.apply(entry.getKey()),
entry -> changingValueFunction.apply(entry.getValue())));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"NK",
",",
"NV",
">",
"Map",
"<",
"NK",
",",
"NV",
">",
"newFilteredChangedKeyValueMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Predicate",
"<",
"?",
"super",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"filter",
",",
"Function",
"<",
"K",
",",
"NK",
">",
"changingKeyFunction",
",",
"Function",
"<",
"V",
",",
"NV",
">",
"changingValueFunction",
")",
"{",
"return",
"getEntryStreamWithFilter",
"(",
"map",
",",
"filter",
")",
".",
"collect",
"(",
"toMap",
"(",
"entry",
"->",
"changingKeyFunction",
".",
"apply",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
",",
"entry",
"->",
"changingValueFunction",
".",
"apply",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
")",
")",
";",
"}"
] |
New filtered changed key value map map.
@param <K> the type parameter
@param <V> the type parameter
@param <NK> the type parameter
@param <NV> the type parameter
@param map the map
@param filter the filter
@param changingKeyFunction the changing key function
@param changingValueFunction the changing value function
@return the map
|
[
"New",
"filtered",
"changed",
"key",
"value",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L326-L333
|
154,880
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newChangedKeyValueWithEntryMap
|
public static <K, V, NK, NV> Map<NK, NV> newChangedKeyValueWithEntryMap(
Map<K, V> map, Function<Entry<K, V>, NK> changingKeyFunction,
Function<Entry<K, V>, NV> changingValueFunction) {
return buildEntryStream(map).collect(toMap(
changingKeyFunction, changingValueFunction));
}
|
java
|
public static <K, V, NK, NV> Map<NK, NV> newChangedKeyValueWithEntryMap(
Map<K, V> map, Function<Entry<K, V>, NK> changingKeyFunction,
Function<Entry<K, V>, NV> changingValueFunction) {
return buildEntryStream(map).collect(toMap(
changingKeyFunction, changingValueFunction));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"NK",
",",
"NV",
">",
"Map",
"<",
"NK",
",",
"NV",
">",
"newChangedKeyValueWithEntryMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Function",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
",",
"NK",
">",
"changingKeyFunction",
",",
"Function",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
",",
"NV",
">",
"changingValueFunction",
")",
"{",
"return",
"buildEntryStream",
"(",
"map",
")",
".",
"collect",
"(",
"toMap",
"(",
"changingKeyFunction",
",",
"changingValueFunction",
")",
")",
";",
"}"
] |
New changed key value with entry map map.
@param <K> the type parameter
@param <V> the type parameter
@param <NK> the type parameter
@param <NV> the type parameter
@param map the map
@param changingKeyFunction the changing key function
@param changingValueFunction the changing value function
@return the map
|
[
"New",
"changed",
"key",
"value",
"with",
"entry",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L347-L352
|
154,881
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newFilteredChangedKeyValueWithEntryMap
|
public static <K, V, NK, NV> Map<NK, NV>
newFilteredChangedKeyValueWithEntryMap(Map<K, V> map,
Predicate<? super Entry<K, V>> filter,
Function<Entry<K, V>, NK> changingKeyFunction,
Function<Entry<K, V>, NV> changingValueFunction) {
return getEntryStreamWithFilter(map, filter).collect(toMap(
changingKeyFunction, changingValueFunction));
}
|
java
|
public static <K, V, NK, NV> Map<NK, NV>
newFilteredChangedKeyValueWithEntryMap(Map<K, V> map,
Predicate<? super Entry<K, V>> filter,
Function<Entry<K, V>, NK> changingKeyFunction,
Function<Entry<K, V>, NV> changingValueFunction) {
return getEntryStreamWithFilter(map, filter).collect(toMap(
changingKeyFunction, changingValueFunction));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"NK",
",",
"NV",
">",
"Map",
"<",
"NK",
",",
"NV",
">",
"newFilteredChangedKeyValueWithEntryMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Predicate",
"<",
"?",
"super",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"filter",
",",
"Function",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
",",
"NK",
">",
"changingKeyFunction",
",",
"Function",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
",",
"NV",
">",
"changingValueFunction",
")",
"{",
"return",
"getEntryStreamWithFilter",
"(",
"map",
",",
"filter",
")",
".",
"collect",
"(",
"toMap",
"(",
"changingKeyFunction",
",",
"changingValueFunction",
")",
")",
";",
"}"
] |
New filtered changed key value with entry map map.
@param <K> the type parameter
@param <V> the type parameter
@param <NK> the type parameter
@param <NV> the type parameter
@param map the map
@param filter the filter
@param changingKeyFunction the changing key function
@param changingValueFunction the changing value function
@return the map
|
[
"New",
"filtered",
"changed",
"key",
"value",
"with",
"entry",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L367-L374
|
154,882
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newFilteredMap
|
public static <K, V> Map<K, V> newFilteredMap(Map<K, V> map,
Predicate<? super Entry<K, V>> filter) {
return getEntryStreamWithFilter(map, filter)
.collect(toMap(Entry::getKey, Entry::getValue));
}
|
java
|
public static <K, V> Map<K, V> newFilteredMap(Map<K, V> map,
Predicate<? super Entry<K, V>> filter) {
return getEntryStreamWithFilter(map, filter)
.collect(toMap(Entry::getKey, Entry::getValue));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"newFilteredMap",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"Predicate",
"<",
"?",
"super",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"filter",
")",
"{",
"return",
"getEntryStreamWithFilter",
"(",
"map",
",",
"filter",
")",
".",
"collect",
"(",
"toMap",
"(",
"Entry",
"::",
"getKey",
",",
"Entry",
"::",
"getValue",
")",
")",
";",
"}"
] |
New filtered map map.
@param <K> the type parameter
@param <V> the type parameter
@param map the map
@param filter the filter
@return the map
|
[
"New",
"filtered",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L385-L389
|
154,883
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.sortByValue
|
public static <K, V extends Comparable<V>> Map<K, V>
sortByValue(Map<K, V> map) {
return sort(map, comparing(map::get));
}
|
java
|
public static <K, V extends Comparable<V>> Map<K, V>
sortByValue(Map<K, V> map) {
return sort(map, comparing(map::get));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
"extends",
"Comparable",
"<",
"V",
">",
">",
"Map",
"<",
"K",
",",
"V",
">",
"sortByValue",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
")",
"{",
"return",
"sort",
"(",
"map",
",",
"comparing",
"(",
"map",
"::",
"get",
")",
")",
";",
"}"
] |
Sort by value map.
@param <K> the type parameter
@param <V> the type parameter
@param map the map
@return the map
|
[
"Sort",
"by",
"value",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L456-L459
|
154,884
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.sortedStreamByValue
|
public static <K, V extends Comparable<V>> Stream<Entry<K, V>>
sortedStreamByValue(Map<K, V> map) {
return buildEntryStream(map).sorted(comparing(Entry::getValue));
}
|
java
|
public static <K, V extends Comparable<V>> Stream<Entry<K, V>>
sortedStreamByValue(Map<K, V> map) {
return buildEntryStream(map).sorted(comparing(Entry::getValue));
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
"extends",
"Comparable",
"<",
"V",
">",
">",
"Stream",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"sortedStreamByValue",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
")",
"{",
"return",
"buildEntryStream",
"(",
"map",
")",
".",
"sorted",
"(",
"comparing",
"(",
"Entry",
"::",
"getValue",
")",
")",
";",
"}"
] |
Sorted stream by value stream.
@param <K> the type parameter
@param <V> the type parameter
@param map the map
@return the stream
|
[
"Sorted",
"stream",
"by",
"value",
"stream",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L469-L472
|
154,885
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newCombinedMap
|
public static <K, V> Map<K, V> newCombinedMap(K[] keys,
V[] values) {
HashMap<K, V> map = new HashMap<>();
for (int i = 0; i < keys.length; i++)
map.put(keys[i], getValueOfIndex(values, i));
return map;
}
|
java
|
public static <K, V> Map<K, V> newCombinedMap(K[] keys,
V[] values) {
HashMap<K, V> map = new HashMap<>();
for (int i = 0; i < keys.length; i++)
map.put(keys[i], getValueOfIndex(values, i));
return map;
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
">",
"Map",
"<",
"K",
",",
"V",
">",
"newCombinedMap",
"(",
"K",
"[",
"]",
"keys",
",",
"V",
"[",
"]",
"values",
")",
"{",
"HashMap",
"<",
"K",
",",
"V",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"map",
".",
"put",
"(",
"keys",
"[",
"i",
"]",
",",
"getValueOfIndex",
"(",
"values",
",",
"i",
")",
")",
";",
"return",
"map",
";",
"}"
] |
New combined map map.
@param <K> the type parameter
@param <V> the type parameter
@param keys the keys
@param values the values
@return the map
|
[
"New",
"combined",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L503-L509
|
154,886
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMMap.java
|
JMMap.newFlatKeyMap
|
public static Map<String, Object> newFlatKeyMap(Map<String, ?> map) {
return newFlatKeyMap(new HashMap<>(), map);
}
|
java
|
public static Map<String, Object> newFlatKeyMap(Map<String, ?> map) {
return newFlatKeyMap(new HashMap<>(), map);
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"newFlatKeyMap",
"(",
"Map",
"<",
"String",
",",
"?",
">",
"map",
")",
"{",
"return",
"newFlatKeyMap",
"(",
"new",
"HashMap",
"<>",
"(",
")",
",",
"map",
")",
";",
"}"
] |
New flat key map map.
@param map the map
@return the map
|
[
"New",
"flat",
"key",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMMap.java#L525-L527
|
154,887
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.partitionBy
|
public static <T> Map<Boolean, List<T>>
partitionBy(Collection<T> collection, Predicate<T> predicate) {
return collection.stream().collect(partitioningBy(predicate));
}
|
java
|
public static <T> Map<Boolean, List<T>>
partitionBy(Collection<T> collection, Predicate<T> predicate) {
return collection.stream().collect(partitioningBy(predicate));
}
|
[
"public",
"static",
"<",
"T",
">",
"Map",
"<",
"Boolean",
",",
"List",
"<",
"T",
">",
">",
"partitionBy",
"(",
"Collection",
"<",
"T",
">",
"collection",
",",
"Predicate",
"<",
"T",
">",
"predicate",
")",
"{",
"return",
"collection",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"partitioningBy",
"(",
"predicate",
")",
")",
";",
"}"
] |
Partition by map.
@param <T> the type parameter
@param collection the collection
@param predicate the predicate
@return the map
|
[
"Partition",
"by",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L24-L27
|
154,888
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.merge
|
public static <T, R> Map<R, T> merge(Stream<Map<R, T>> stream) {
return stream.collect(HashMap::new, Map::putAll, Map::putAll);
}
|
java
|
public static <T, R> Map<R, T> merge(Stream<Map<R, T>> stream) {
return stream.collect(HashMap::new, Map::putAll, Map::putAll);
}
|
[
"public",
"static",
"<",
"T",
",",
"R",
">",
"Map",
"<",
"R",
",",
"T",
">",
"merge",
"(",
"Stream",
"<",
"Map",
"<",
"R",
",",
"T",
">",
">",
"stream",
")",
"{",
"return",
"stream",
".",
"collect",
"(",
"HashMap",
"::",
"new",
",",
"Map",
"::",
"putAll",
",",
"Map",
"::",
"putAll",
")",
";",
"}"
] |
Merge map.
@param <T> the type parameter
@param <R> the type parameter
@param stream the stream
@return the map
|
[
"Merge",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L116-L118
|
154,889
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.groupByTwoKey
|
public static <T, R1, R2> Map<R1, Map<R2, T>> groupByTwoKey(
Collection<T> collection, Function<T, R1> classifier1,
Function<T, R2> classifier2) {
return collection.stream()
.collect(groupingBy(classifier1, toMap(classifier2, t -> t)));
}
|
java
|
public static <T, R1, R2> Map<R1, Map<R2, T>> groupByTwoKey(
Collection<T> collection, Function<T, R1> classifier1,
Function<T, R2> classifier2) {
return collection.stream()
.collect(groupingBy(classifier1, toMap(classifier2, t -> t)));
}
|
[
"public",
"static",
"<",
"T",
",",
"R1",
",",
"R2",
">",
"Map",
"<",
"R1",
",",
"Map",
"<",
"R2",
",",
"T",
">",
">",
"groupByTwoKey",
"(",
"Collection",
"<",
"T",
">",
"collection",
",",
"Function",
"<",
"T",
",",
"R1",
">",
"classifier1",
",",
"Function",
"<",
"T",
",",
"R2",
">",
"classifier2",
")",
"{",
"return",
"collection",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"groupingBy",
"(",
"classifier1",
",",
"toMap",
"(",
"classifier2",
",",
"t",
"->",
"t",
")",
")",
")",
";",
"}"
] |
Group by two key map.
@param <T> the type parameter
@param <R1> the type parameter
@param <R2> the type parameter
@param collection the collection
@param classifier1 the classifier 1
@param classifier2 the classifier 2
@return the map
|
[
"Group",
"by",
"two",
"key",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L131-L136
|
154,890
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.consumeByPredicate
|
public static <T> void consumeByPredicate(Collection<T> collection,
Predicate<T> predicate, Consumer<T> trueConsumer,
Consumer<T> falseConsumer) {
collection.forEach(target -> JMLambda.consumeByBoolean(
predicate.test(target), target, trueConsumer, falseConsumer));
}
|
java
|
public static <T> void consumeByPredicate(Collection<T> collection,
Predicate<T> predicate, Consumer<T> trueConsumer,
Consumer<T> falseConsumer) {
collection.forEach(target -> JMLambda.consumeByBoolean(
predicate.test(target), target, trueConsumer, falseConsumer));
}
|
[
"public",
"static",
"<",
"T",
">",
"void",
"consumeByPredicate",
"(",
"Collection",
"<",
"T",
">",
"collection",
",",
"Predicate",
"<",
"T",
">",
"predicate",
",",
"Consumer",
"<",
"T",
">",
"trueConsumer",
",",
"Consumer",
"<",
"T",
">",
"falseConsumer",
")",
"{",
"collection",
".",
"forEach",
"(",
"target",
"->",
"JMLambda",
".",
"consumeByBoolean",
"(",
"predicate",
".",
"test",
"(",
"target",
")",
",",
"target",
",",
"trueConsumer",
",",
"falseConsumer",
")",
")",
";",
"}"
] |
Consume by predicate.
@param <T> the type parameter
@param collection the collection
@param predicate the predicate
@param trueConsumer the true consumer
@param falseConsumer the false consumer
|
[
"Consume",
"by",
"predicate",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L147-L152
|
154,891
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.consumeByBoolean
|
public static <T> void consumeByBoolean(boolean bool, T target,
Consumer<T> trueConsumer, Consumer<T> falseConsumer) {
if (bool)
trueConsumer.accept(target);
else
falseConsumer.accept(target);
}
|
java
|
public static <T> void consumeByBoolean(boolean bool, T target,
Consumer<T> trueConsumer, Consumer<T> falseConsumer) {
if (bool)
trueConsumer.accept(target);
else
falseConsumer.accept(target);
}
|
[
"public",
"static",
"<",
"T",
">",
"void",
"consumeByBoolean",
"(",
"boolean",
"bool",
",",
"T",
"target",
",",
"Consumer",
"<",
"T",
">",
"trueConsumer",
",",
"Consumer",
"<",
"T",
">",
"falseConsumer",
")",
"{",
"if",
"(",
"bool",
")",
"trueConsumer",
".",
"accept",
"(",
"target",
")",
";",
"else",
"falseConsumer",
".",
"accept",
"(",
"target",
")",
";",
"}"
] |
Consume by boolean.
@param <T> the type parameter
@param bool the bool
@param target the target
@param trueConsumer the true consumer
@param falseConsumer the false consumer
|
[
"Consume",
"by",
"boolean",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L181-L187
|
154,892
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.consumeIfNotNull
|
public static <T> void consumeIfNotNull(T target, Consumer<T> consumer) {
Optional.ofNullable(target).ifPresent(consumer);
}
|
java
|
public static <T> void consumeIfNotNull(T target, Consumer<T> consumer) {
Optional.ofNullable(target).ifPresent(consumer);
}
|
[
"public",
"static",
"<",
"T",
">",
"void",
"consumeIfNotNull",
"(",
"T",
"target",
",",
"Consumer",
"<",
"T",
">",
"consumer",
")",
"{",
"Optional",
".",
"ofNullable",
"(",
"target",
")",
".",
"ifPresent",
"(",
"consumer",
")",
";",
"}"
] |
Consume if not null.
@param <T> the type parameter
@param target the target
@param consumer the consumer
|
[
"Consume",
"if",
"not",
"null",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L196-L198
|
154,893
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.functionIfTrue
|
public static <T, R> Optional<R> functionIfTrue(boolean bool, T target,
Function<T, R> function) {
return supplierIfTrue(bool, () -> function.apply(target));
}
|
java
|
public static <T, R> Optional<R> functionIfTrue(boolean bool, T target,
Function<T, R> function) {
return supplierIfTrue(bool, () -> function.apply(target));
}
|
[
"public",
"static",
"<",
"T",
",",
"R",
">",
"Optional",
"<",
"R",
">",
"functionIfTrue",
"(",
"boolean",
"bool",
",",
"T",
"target",
",",
"Function",
"<",
"T",
",",
"R",
">",
"function",
")",
"{",
"return",
"supplierIfTrue",
"(",
"bool",
",",
"(",
")",
"->",
"function",
".",
"apply",
"(",
"target",
")",
")",
";",
"}"
] |
Function if true optional.
@param <T> the type parameter
@param <R> the type parameter
@param bool the bool
@param target the target
@param function the function
@return the optional
|
[
"Function",
"if",
"true",
"optional",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L269-L272
|
154,894
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.biFunctionIfTrue
|
public static <T, U, R> Optional<R> biFunctionIfTrue(boolean bool,
T target1, U target2, BiFunction<T, U, R> biFunction) {
return supplierIfTrue(bool, () -> biFunction.apply(target1, target2));
}
|
java
|
public static <T, U, R> Optional<R> biFunctionIfTrue(boolean bool,
T target1, U target2, BiFunction<T, U, R> biFunction) {
return supplierIfTrue(bool, () -> biFunction.apply(target1, target2));
}
|
[
"public",
"static",
"<",
"T",
",",
"U",
",",
"R",
">",
"Optional",
"<",
"R",
">",
"biFunctionIfTrue",
"(",
"boolean",
"bool",
",",
"T",
"target1",
",",
"U",
"target2",
",",
"BiFunction",
"<",
"T",
",",
"U",
",",
"R",
">",
"biFunction",
")",
"{",
"return",
"supplierIfTrue",
"(",
"bool",
",",
"(",
")",
"->",
"biFunction",
".",
"apply",
"(",
"target1",
",",
"target2",
")",
")",
";",
"}"
] |
Bi function if true optional.
@param <T> the type parameter
@param <U> the type parameter
@param <R> the type parameter
@param bool the bool
@param target1 the target 1
@param target2 the target 2
@param biFunction the bi function
@return the optional
|
[
"Bi",
"function",
"if",
"true",
"optional",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L286-L289
|
154,895
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.supplierIfTrue
|
public static <R> Optional<R> supplierIfTrue(boolean bool,
Supplier<R> supplier) {
return bool ? Optional.ofNullable(supplier.get()) : Optional.empty();
}
|
java
|
public static <R> Optional<R> supplierIfTrue(boolean bool,
Supplier<R> supplier) {
return bool ? Optional.ofNullable(supplier.get()) : Optional.empty();
}
|
[
"public",
"static",
"<",
"R",
">",
"Optional",
"<",
"R",
">",
"supplierIfTrue",
"(",
"boolean",
"bool",
",",
"Supplier",
"<",
"R",
">",
"supplier",
")",
"{",
"return",
"bool",
"?",
"Optional",
".",
"ofNullable",
"(",
"supplier",
".",
"get",
"(",
")",
")",
":",
"Optional",
".",
"empty",
"(",
")",
";",
"}"
] |
Supplier if true optional.
@param <R> the type parameter
@param bool the bool
@param supplier the supplier
@return the optional
|
[
"Supplier",
"if",
"true",
"optional",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L299-L302
|
154,896
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.functionByBoolean
|
public static <T, R> R functionByBoolean(boolean bool, T target,
Function<T, R> trueFunction, Function<T, R> falseFunction) {
return bool ? trueFunction.apply(target) : falseFunction.apply(target);
}
|
java
|
public static <T, R> R functionByBoolean(boolean bool, T target,
Function<T, R> trueFunction, Function<T, R> falseFunction) {
return bool ? trueFunction.apply(target) : falseFunction.apply(target);
}
|
[
"public",
"static",
"<",
"T",
",",
"R",
">",
"R",
"functionByBoolean",
"(",
"boolean",
"bool",
",",
"T",
"target",
",",
"Function",
"<",
"T",
",",
"R",
">",
"trueFunction",
",",
"Function",
"<",
"T",
",",
"R",
">",
"falseFunction",
")",
"{",
"return",
"bool",
"?",
"trueFunction",
".",
"apply",
"(",
"target",
")",
":",
"falseFunction",
".",
"apply",
"(",
"target",
")",
";",
"}"
] |
Function by boolean r.
@param <T> the type parameter
@param <R> the type parameter
@param bool the bool
@param target the target
@param trueFunction the true function
@param falseFunction the false function
@return the r
|
[
"Function",
"by",
"boolean",
"r",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L315-L318
|
154,897
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.supplierByBoolean
|
public static <R> R supplierByBoolean(boolean bool,
Supplier<R> trueSupplier, Supplier<R> falseSupplier) {
return bool ? trueSupplier.get() : falseSupplier.get();
}
|
java
|
public static <R> R supplierByBoolean(boolean bool,
Supplier<R> trueSupplier, Supplier<R> falseSupplier) {
return bool ? trueSupplier.get() : falseSupplier.get();
}
|
[
"public",
"static",
"<",
"R",
">",
"R",
"supplierByBoolean",
"(",
"boolean",
"bool",
",",
"Supplier",
"<",
"R",
">",
"trueSupplier",
",",
"Supplier",
"<",
"R",
">",
"falseSupplier",
")",
"{",
"return",
"bool",
"?",
"trueSupplier",
".",
"get",
"(",
")",
":",
"falseSupplier",
".",
"get",
"(",
")",
";",
"}"
] |
Supplier by boolean r.
@param <R> the type parameter
@param bool the bool
@param trueSupplier the true supplier
@param falseSupplier the false supplier
@return the r
|
[
"Supplier",
"by",
"boolean",
"r",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L329-L332
|
154,898
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.changeInto
|
public static <T, R> Function<T, R> changeInto(R input) {
return t -> input;
}
|
java
|
public static <T, R> Function<T, R> changeInto(R input) {
return t -> input;
}
|
[
"public",
"static",
"<",
"T",
",",
"R",
">",
"Function",
"<",
"T",
",",
"R",
">",
"changeInto",
"(",
"R",
"input",
")",
"{",
"return",
"t",
"->",
"input",
";",
"}"
] |
Change into function.
@param <T> the type parameter
@param <R> the type parameter
@param input the input
@return the function
|
[
"Change",
"into",
"function",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L342-L344
|
154,899
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMLambda.java
|
JMLambda.supplierIfNull
|
public static <R> R supplierIfNull(R target, Supplier<R> supplier) {
return Optional.ofNullable(target).orElseGet(supplier);
}
|
java
|
public static <R> R supplierIfNull(R target, Supplier<R> supplier) {
return Optional.ofNullable(target).orElseGet(supplier);
}
|
[
"public",
"static",
"<",
"R",
">",
"R",
"supplierIfNull",
"(",
"R",
"target",
",",
"Supplier",
"<",
"R",
">",
"supplier",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"target",
")",
".",
"orElseGet",
"(",
"supplier",
")",
";",
"}"
] |
Supplier if null r.
@param <R> the type parameter
@param target the target
@param supplier the supplier
@return the r
|
[
"Supplier",
"if",
"null",
"r",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMLambda.java#L354-L356
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.