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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
155,600
|
app55/app55-java
|
src/support/java/com/googlecode/openbeans/EventSetDescriptor.java
|
EventSetDescriptor.checkNotNull
|
@SuppressWarnings("nls")
private void checkNotNull(Object sourceClass, Object eventSetName, Object alistenerType, Object listenerMethodName)
{
if (sourceClass == null)
{
throw new NullPointerException(Messages.getString("beans.0C"));
}
if (eventSetName == null)
{
throw new NullPointerException(Messages.getString("beans.53"));
}
if (alistenerType == null)
{
throw new NullPointerException(Messages.getString("beans.54"));
}
if (listenerMethodName == null)
{
throw new NullPointerException(Messages.getString("beans.52"));
}
}
|
java
|
@SuppressWarnings("nls")
private void checkNotNull(Object sourceClass, Object eventSetName, Object alistenerType, Object listenerMethodName)
{
if (sourceClass == null)
{
throw new NullPointerException(Messages.getString("beans.0C"));
}
if (eventSetName == null)
{
throw new NullPointerException(Messages.getString("beans.53"));
}
if (alistenerType == null)
{
throw new NullPointerException(Messages.getString("beans.54"));
}
if (listenerMethodName == null)
{
throw new NullPointerException(Messages.getString("beans.52"));
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"nls\"",
")",
"private",
"void",
"checkNotNull",
"(",
"Object",
"sourceClass",
",",
"Object",
"eventSetName",
",",
"Object",
"alistenerType",
",",
"Object",
"listenerMethodName",
")",
"{",
"if",
"(",
"sourceClass",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"Messages",
".",
"getString",
"(",
"\"beans.0C\"",
")",
")",
";",
"}",
"if",
"(",
"eventSetName",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"Messages",
".",
"getString",
"(",
"\"beans.53\"",
")",
")",
";",
"}",
"if",
"(",
"alistenerType",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"Messages",
".",
"getString",
"(",
"\"beans.54\"",
")",
")",
";",
"}",
"if",
"(",
"listenerMethodName",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"Messages",
".",
"getString",
"(",
"\"beans.52\"",
")",
")",
";",
"}",
"}"
] |
ensures that there is no nulls
|
[
"ensures",
"that",
"there",
"is",
"no",
"nulls"
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/EventSetDescriptor.java#L183-L202
|
155,601
|
BellaDati/belladati-sdk-java
|
src/main/java/com/belladati/sdk/impl/BellaDatiServiceImpl.java
|
BellaDatiServiceImpl.appendFilter
|
public URIBuilder appendFilter(URIBuilder builder, Collection<Filter<?>> filters) {
if (filters.size() > 0) {
ObjectNode filterNode = new ObjectMapper().createObjectNode();
for (Filter<?> filter : filters) {
filterNode.setAll(filter.toJson());
}
ObjectNode drilldownNode = new ObjectMapper().createObjectNode();
drilldownNode.put("drilldown", filterNode);
builder.addParameter("filter", drilldownNode.toString());
}
return builder;
}
|
java
|
public URIBuilder appendFilter(URIBuilder builder, Collection<Filter<?>> filters) {
if (filters.size() > 0) {
ObjectNode filterNode = new ObjectMapper().createObjectNode();
for (Filter<?> filter : filters) {
filterNode.setAll(filter.toJson());
}
ObjectNode drilldownNode = new ObjectMapper().createObjectNode();
drilldownNode.put("drilldown", filterNode);
builder.addParameter("filter", drilldownNode.toString());
}
return builder;
}
|
[
"public",
"URIBuilder",
"appendFilter",
"(",
"URIBuilder",
"builder",
",",
"Collection",
"<",
"Filter",
"<",
"?",
">",
">",
"filters",
")",
"{",
"if",
"(",
"filters",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"ObjectNode",
"filterNode",
"=",
"new",
"ObjectMapper",
"(",
")",
".",
"createObjectNode",
"(",
")",
";",
"for",
"(",
"Filter",
"<",
"?",
">",
"filter",
":",
"filters",
")",
"{",
"filterNode",
".",
"setAll",
"(",
"filter",
".",
"toJson",
"(",
")",
")",
";",
"}",
"ObjectNode",
"drilldownNode",
"=",
"new",
"ObjectMapper",
"(",
")",
".",
"createObjectNode",
"(",
")",
";",
"drilldownNode",
".",
"put",
"(",
"\"drilldown\"",
",",
"filterNode",
")",
";",
"builder",
".",
"addParameter",
"(",
"\"filter\"",
",",
"drilldownNode",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"builder",
";",
"}"
] |
Appends a filter parameter from the given filters to the URI builder.
Won't do anything if the filter collection is empty.
@param builder the builder to append to
@param filters filters to append
@return the same builder, for chaining
|
[
"Appends",
"a",
"filter",
"parameter",
"from",
"the",
"given",
"filters",
"to",
"the",
"URI",
"builder",
".",
"Won",
"t",
"do",
"anything",
"if",
"the",
"filter",
"collection",
"is",
"empty",
"."
] |
1a732a57ebc825ddf47ce405723cc958adb1a43f
|
https://github.com/BellaDati/belladati-sdk-java/blob/1a732a57ebc825ddf47ce405723cc958adb1a43f/src/main/java/com/belladati/sdk/impl/BellaDatiServiceImpl.java#L384-L395
|
155,602
|
BellaDati/belladati-sdk-java
|
src/main/java/com/belladati/sdk/impl/BellaDatiServiceImpl.java
|
BellaDatiServiceImpl.readObject
|
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
try {
Field domainList = getClass().getDeclaredField("domainList");
domainList.setAccessible(true);
domainList.set(this, new DomainList());
Field dashboardList = getClass().getDeclaredField("dashboardList");
dashboardList.setAccessible(true);
dashboardList.set(this, new DashboardList());
Field reportList = getClass().getDeclaredField("reportList");
reportList.setAccessible(true);
reportList.set(this, new ReportList());
Field dataSetList = getClass().getDeclaredField("dataSetList");
dataSetList.setAccessible(true);
dataSetList.set(this, new DataSetList());
Field commentLists = getClass().getDeclaredField("commentLists");
commentLists.setAccessible(true);
commentLists.set(this, Collections.synchronizedMap(new HashMap<String, PaginatedList<Comment>>()));
Field reportAttributeValues = getClass().getDeclaredField("dataSetAttributeValues");
reportAttributeValues.setAccessible(true);
reportAttributeValues.set(this, new HashMap<String, Map<String, CachedListImpl<AttributeValue>>>());
Field dataSourceList = getClass().getDeclaredField("dataSourceList");
dataSourceList.setAccessible(true);
dataSourceList.set(this, new HashMap<String, CachedListImpl<DataSource>>());
Field importFormList = getClass().getDeclaredField("importFormList");
importFormList.setAccessible(true);
importFormList.set(this, new ImportFormList());
Field dataSourceImportList = getClass().getDeclaredField("dataSourceImportList");
dataSourceImportList.setAccessible(true);
dataSourceImportList.set(this, new HashMap<String, CachedListImpl<DataSourceImport>>());
} catch (NoSuchFieldException e) {
throw new InternalConfigurationException("Failed to set service fields", e);
} catch (IllegalAccessException e) {
throw new InternalConfigurationException("Failed to set service fields", e);
} catch (SecurityException e) {
throw new InternalConfigurationException("Failed to set service fields", e);
} catch (IllegalArgumentException e) {
throw new InternalConfigurationException("Failed to set service fields", e);
}
}
|
java
|
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
try {
Field domainList = getClass().getDeclaredField("domainList");
domainList.setAccessible(true);
domainList.set(this, new DomainList());
Field dashboardList = getClass().getDeclaredField("dashboardList");
dashboardList.setAccessible(true);
dashboardList.set(this, new DashboardList());
Field reportList = getClass().getDeclaredField("reportList");
reportList.setAccessible(true);
reportList.set(this, new ReportList());
Field dataSetList = getClass().getDeclaredField("dataSetList");
dataSetList.setAccessible(true);
dataSetList.set(this, new DataSetList());
Field commentLists = getClass().getDeclaredField("commentLists");
commentLists.setAccessible(true);
commentLists.set(this, Collections.synchronizedMap(new HashMap<String, PaginatedList<Comment>>()));
Field reportAttributeValues = getClass().getDeclaredField("dataSetAttributeValues");
reportAttributeValues.setAccessible(true);
reportAttributeValues.set(this, new HashMap<String, Map<String, CachedListImpl<AttributeValue>>>());
Field dataSourceList = getClass().getDeclaredField("dataSourceList");
dataSourceList.setAccessible(true);
dataSourceList.set(this, new HashMap<String, CachedListImpl<DataSource>>());
Field importFormList = getClass().getDeclaredField("importFormList");
importFormList.setAccessible(true);
importFormList.set(this, new ImportFormList());
Field dataSourceImportList = getClass().getDeclaredField("dataSourceImportList");
dataSourceImportList.setAccessible(true);
dataSourceImportList.set(this, new HashMap<String, CachedListImpl<DataSourceImport>>());
} catch (NoSuchFieldException e) {
throw new InternalConfigurationException("Failed to set service fields", e);
} catch (IllegalAccessException e) {
throw new InternalConfigurationException("Failed to set service fields", e);
} catch (SecurityException e) {
throw new InternalConfigurationException("Failed to set service fields", e);
} catch (IllegalArgumentException e) {
throw new InternalConfigurationException("Failed to set service fields", e);
}
}
|
[
"private",
"void",
"readObject",
"(",
"ObjectInputStream",
"in",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"in",
".",
"defaultReadObject",
"(",
")",
";",
"try",
"{",
"Field",
"domainList",
"=",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"domainList\"",
")",
";",
"domainList",
".",
"setAccessible",
"(",
"true",
")",
";",
"domainList",
".",
"set",
"(",
"this",
",",
"new",
"DomainList",
"(",
")",
")",
";",
"Field",
"dashboardList",
"=",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"dashboardList\"",
")",
";",
"dashboardList",
".",
"setAccessible",
"(",
"true",
")",
";",
"dashboardList",
".",
"set",
"(",
"this",
",",
"new",
"DashboardList",
"(",
")",
")",
";",
"Field",
"reportList",
"=",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"reportList\"",
")",
";",
"reportList",
".",
"setAccessible",
"(",
"true",
")",
";",
"reportList",
".",
"set",
"(",
"this",
",",
"new",
"ReportList",
"(",
")",
")",
";",
"Field",
"dataSetList",
"=",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"dataSetList\"",
")",
";",
"dataSetList",
".",
"setAccessible",
"(",
"true",
")",
";",
"dataSetList",
".",
"set",
"(",
"this",
",",
"new",
"DataSetList",
"(",
")",
")",
";",
"Field",
"commentLists",
"=",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"commentLists\"",
")",
";",
"commentLists",
".",
"setAccessible",
"(",
"true",
")",
";",
"commentLists",
".",
"set",
"(",
"this",
",",
"Collections",
".",
"synchronizedMap",
"(",
"new",
"HashMap",
"<",
"String",
",",
"PaginatedList",
"<",
"Comment",
">",
">",
"(",
")",
")",
")",
";",
"Field",
"reportAttributeValues",
"=",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"dataSetAttributeValues\"",
")",
";",
"reportAttributeValues",
".",
"setAccessible",
"(",
"true",
")",
";",
"reportAttributeValues",
".",
"set",
"(",
"this",
",",
"new",
"HashMap",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"CachedListImpl",
"<",
"AttributeValue",
">",
">",
">",
"(",
")",
")",
";",
"Field",
"dataSourceList",
"=",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"dataSourceList\"",
")",
";",
"dataSourceList",
".",
"setAccessible",
"(",
"true",
")",
";",
"dataSourceList",
".",
"set",
"(",
"this",
",",
"new",
"HashMap",
"<",
"String",
",",
"CachedListImpl",
"<",
"DataSource",
">",
">",
"(",
")",
")",
";",
"Field",
"importFormList",
"=",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"importFormList\"",
")",
";",
"importFormList",
".",
"setAccessible",
"(",
"true",
")",
";",
"importFormList",
".",
"set",
"(",
"this",
",",
"new",
"ImportFormList",
"(",
")",
")",
";",
"Field",
"dataSourceImportList",
"=",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"dataSourceImportList\"",
")",
";",
"dataSourceImportList",
".",
"setAccessible",
"(",
"true",
")",
";",
"dataSourceImportList",
".",
"set",
"(",
"this",
",",
"new",
"HashMap",
"<",
"String",
",",
"CachedListImpl",
"<",
"DataSourceImport",
">",
">",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"throw",
"new",
"InternalConfigurationException",
"(",
"\"Failed to set service fields\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"InternalConfigurationException",
"(",
"\"Failed to set service fields\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"SecurityException",
"e",
")",
"{",
"throw",
"new",
"InternalConfigurationException",
"(",
"\"Failed to set service fields\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"InternalConfigurationException",
"(",
"\"Failed to set service fields\"",
",",
"e",
")",
";",
"}",
"}"
] |
Deserialization. Sets up the element lists and maps as empty objects.
@param in Input stream of object to be de-serialized
@throws IOException Thrown if IO error occurs during class reading
@throws ClassNotFoundException Thrown if desired class does not exist
|
[
"Deserialization",
".",
"Sets",
"up",
"the",
"element",
"lists",
"and",
"maps",
"as",
"empty",
"objects",
"."
] |
1a732a57ebc825ddf47ce405723cc958adb1a43f
|
https://github.com/BellaDati/belladati-sdk-java/blob/1a732a57ebc825ddf47ce405723cc958adb1a43f/src/main/java/com/belladati/sdk/impl/BellaDatiServiceImpl.java#L556-L603
|
155,603
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/JMThreadServiceForLimitedQueueSize.java
|
JMThreadServiceForLimitedQueueSize.submit
|
public <T> Future<T> submit(Callable<T> callable) {
checkThreadQueue();
return threadPool.submit(callable);
}
|
java
|
public <T> Future<T> submit(Callable<T> callable) {
checkThreadQueue();
return threadPool.submit(callable);
}
|
[
"public",
"<",
"T",
">",
"Future",
"<",
"T",
">",
"submit",
"(",
"Callable",
"<",
"T",
">",
"callable",
")",
"{",
"checkThreadQueue",
"(",
")",
";",
"return",
"threadPool",
".",
"submit",
"(",
"callable",
")",
";",
"}"
] |
Submit future.
@param <T> the type parameter
@param callable the callable
@return the future
|
[
"Submit",
"future",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMThreadServiceForLimitedQueueSize.java#L89-L92
|
155,604
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/text/PasswordUtility.java
|
PasswordUtility.maskInUrl
|
public static MaskedText maskInUrl(String url){
MaskedText result = new MaskedText();
result.setClearText(url);
result.setText(url);
result.setMasked(null);
if (url != null){
Matcher urlMatcher = URL_PATTERN.matcher(url);
if (urlMatcher.find()) {
Matcher pwdMatcher = PASSWORD_IN_URL_PATTERN.matcher(url);
if (pwdMatcher.find()){
result.setText(pwdMatcher.replaceFirst(PASSWORD_IN_URL_MASK));
String s = pwdMatcher.group(); // with leading ":" and trailing "@"
result.setMasked(s.substring(1, s.length()-1));
}
}
}
return result;
}
|
java
|
public static MaskedText maskInUrl(String url){
MaskedText result = new MaskedText();
result.setClearText(url);
result.setText(url);
result.setMasked(null);
if (url != null){
Matcher urlMatcher = URL_PATTERN.matcher(url);
if (urlMatcher.find()) {
Matcher pwdMatcher = PASSWORD_IN_URL_PATTERN.matcher(url);
if (pwdMatcher.find()){
result.setText(pwdMatcher.replaceFirst(PASSWORD_IN_URL_MASK));
String s = pwdMatcher.group(); // with leading ":" and trailing "@"
result.setMasked(s.substring(1, s.length()-1));
}
}
}
return result;
}
|
[
"public",
"static",
"MaskedText",
"maskInUrl",
"(",
"String",
"url",
")",
"{",
"MaskedText",
"result",
"=",
"new",
"MaskedText",
"(",
")",
";",
"result",
".",
"setClearText",
"(",
"url",
")",
";",
"result",
".",
"setText",
"(",
"url",
")",
";",
"result",
".",
"setMasked",
"(",
"null",
")",
";",
"if",
"(",
"url",
"!=",
"null",
")",
"{",
"Matcher",
"urlMatcher",
"=",
"URL_PATTERN",
".",
"matcher",
"(",
"url",
")",
";",
"if",
"(",
"urlMatcher",
".",
"find",
"(",
")",
")",
"{",
"Matcher",
"pwdMatcher",
"=",
"PASSWORD_IN_URL_PATTERN",
".",
"matcher",
"(",
"url",
")",
";",
"if",
"(",
"pwdMatcher",
".",
"find",
"(",
")",
")",
"{",
"result",
".",
"setText",
"(",
"pwdMatcher",
".",
"replaceFirst",
"(",
"PASSWORD_IN_URL_MASK",
")",
")",
";",
"String",
"s",
"=",
"pwdMatcher",
".",
"group",
"(",
")",
";",
"// with leading \":\" and trailing \"@\"\r",
"result",
".",
"setMasked",
"(",
"s",
".",
"substring",
"(",
"1",
",",
"s",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Mask password in URL.
@param url The original URL string.
@return The result containing original URL, masked URL and the password which had been masked.
If there is no password filed found in the URL, in the result, original and masked URL
will be the same, and password will be null.
|
[
"Mask",
"password",
"in",
"URL",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/text/PasswordUtility.java#L41-L59
|
155,605
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/text/PasswordUtility.java
|
PasswordUtility.unmaskInUrl
|
public static String unmaskInUrl(String url, String password){
String result = null;
if (url != null){
Matcher urlMatcher = URL_PATTERN.matcher(url);
if (urlMatcher.find()) {
int s = url.indexOf(PASSWORD_IN_URL_MASK);
if (s >= 0){
StringBuilder sb = new StringBuilder();
sb.append(url.substring(0, s));
if (password != null){
sb.append(':').append(password);
}
sb.append('@');
sb.append(url.substring(s+PASSWORD_IN_URL_MASK.length(), url.length()));
result = sb.toString();
}
}
}
return result == null ? url : result;
}
|
java
|
public static String unmaskInUrl(String url, String password){
String result = null;
if (url != null){
Matcher urlMatcher = URL_PATTERN.matcher(url);
if (urlMatcher.find()) {
int s = url.indexOf(PASSWORD_IN_URL_MASK);
if (s >= 0){
StringBuilder sb = new StringBuilder();
sb.append(url.substring(0, s));
if (password != null){
sb.append(':').append(password);
}
sb.append('@');
sb.append(url.substring(s+PASSWORD_IN_URL_MASK.length(), url.length()));
result = sb.toString();
}
}
}
return result == null ? url : result;
}
|
[
"public",
"static",
"String",
"unmaskInUrl",
"(",
"String",
"url",
",",
"String",
"password",
")",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"url",
"!=",
"null",
")",
"{",
"Matcher",
"urlMatcher",
"=",
"URL_PATTERN",
".",
"matcher",
"(",
"url",
")",
";",
"if",
"(",
"urlMatcher",
".",
"find",
"(",
")",
")",
"{",
"int",
"s",
"=",
"url",
".",
"indexOf",
"(",
"PASSWORD_IN_URL_MASK",
")",
";",
"if",
"(",
"s",
">=",
"0",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"url",
".",
"substring",
"(",
"0",
",",
"s",
")",
")",
";",
"if",
"(",
"password",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"password",
")",
";",
"}",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"sb",
".",
"append",
"(",
"url",
".",
"substring",
"(",
"s",
"+",
"PASSWORD_IN_URL_MASK",
".",
"length",
"(",
")",
",",
"url",
".",
"length",
"(",
")",
")",
")",
";",
"result",
"=",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"}",
"}",
"return",
"result",
"==",
"null",
"?",
"url",
":",
"result",
";",
"}"
] |
Unmask password in URL.
@param url The URL in which the password part had been masked.
@param password The clear password
@return The URL with clear password.
|
[
"Unmask",
"password",
"in",
"URL",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/text/PasswordUtility.java#L67-L86
|
155,606
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/accumulator/TimeSeriesCountBytesSizeAccumulator.java
|
TimeSeriesCountBytesSizeAccumulator.getNumber
|
public double getNumber(long timestamp,
Function<CountBytesSizeAccumulator, Long> valueFunction) {
return JMOptional.getOptional(this, timestamp).map(valueFunction)
.map((Long::doubleValue)).orElse(0d);
}
|
java
|
public double getNumber(long timestamp,
Function<CountBytesSizeAccumulator, Long> valueFunction) {
return JMOptional.getOptional(this, timestamp).map(valueFunction)
.map((Long::doubleValue)).orElse(0d);
}
|
[
"public",
"double",
"getNumber",
"(",
"long",
"timestamp",
",",
"Function",
"<",
"CountBytesSizeAccumulator",
",",
"Long",
">",
"valueFunction",
")",
"{",
"return",
"JMOptional",
".",
"getOptional",
"(",
"this",
",",
"timestamp",
")",
".",
"map",
"(",
"valueFunction",
")",
".",
"map",
"(",
"(",
"Long",
"::",
"doubleValue",
")",
")",
".",
"orElse",
"(",
"0d",
")",
";",
"}"
] |
Gets number.
@param timestamp the timestamp
@param valueFunction the value function
@return the number
|
[
"Gets",
"number",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/accumulator/TimeSeriesCountBytesSizeAccumulator.java#L40-L44
|
155,607
|
dmfs/http-client-interfaces
|
src/org/dmfs/httpclientinterfaces/ContentType.java
|
ContentType.param
|
public Parameter param(String key)
{
if (mParams == null)
{
return null;
}
Parameter value = mParams.get(key);
return value != null ? value : mParams.get(key.toLowerCase(Locale.ENGLISH));
}
|
java
|
public Parameter param(String key)
{
if (mParams == null)
{
return null;
}
Parameter value = mParams.get(key);
return value != null ? value : mParams.get(key.toLowerCase(Locale.ENGLISH));
}
|
[
"public",
"Parameter",
"param",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"mParams",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Parameter",
"value",
"=",
"mParams",
".",
"get",
"(",
"key",
")",
";",
"return",
"value",
"!=",
"null",
"?",
"value",
":",
"mParams",
".",
"get",
"(",
"key",
".",
"toLowerCase",
"(",
"Locale",
".",
"ENGLISH",
")",
")",
";",
"}"
] |
Return the parameter value for a specific key.
@param key
The key of the parameter.
@return The value {@link String}.
|
[
"Return",
"the",
"parameter",
"value",
"for",
"a",
"specific",
"key",
"."
] |
10896c71270ccaf32ac4ed5d706dfa0001fd3862
|
https://github.com/dmfs/http-client-interfaces/blob/10896c71270ccaf32ac4ed5d706dfa0001fd3862/src/org/dmfs/httpclientinterfaces/ContentType.java#L190-L200
|
155,608
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/MapConverter.java
|
MapConverter.toNullableMap
|
@SuppressWarnings("unchecked")
public static Map<String, Object> toNullableMap(Object value) {
if (value == null)
return null;
Class<?> valueClass = value.getClass();
if (valueClass.isPrimitive())
return null;
if (value instanceof Map<?, ?>)
return mapToMap((Map<Object, Object>) value);
if (valueClass.isArray())
return arrayToMap((Object[]) value);
if (value instanceof Collection<?>)
return listToMap((Collection<Object>) value);
try {
return mapper.convertValue(value, typeRef);
} catch (Exception ex) {
return null;
}
}
|
java
|
@SuppressWarnings("unchecked")
public static Map<String, Object> toNullableMap(Object value) {
if (value == null)
return null;
Class<?> valueClass = value.getClass();
if (valueClass.isPrimitive())
return null;
if (value instanceof Map<?, ?>)
return mapToMap((Map<Object, Object>) value);
if (valueClass.isArray())
return arrayToMap((Object[]) value);
if (value instanceof Collection<?>)
return listToMap((Collection<Object>) value);
try {
return mapper.convertValue(value, typeRef);
} catch (Exception ex) {
return null;
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"toNullableMap",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"null",
";",
"Class",
"<",
"?",
">",
"valueClass",
"=",
"value",
".",
"getClass",
"(",
")",
";",
"if",
"(",
"valueClass",
".",
"isPrimitive",
"(",
")",
")",
"return",
"null",
";",
"if",
"(",
"value",
"instanceof",
"Map",
"<",
"?",
",",
"?",
">",
")",
"return",
"mapToMap",
"(",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
")",
"value",
")",
";",
"if",
"(",
"valueClass",
".",
"isArray",
"(",
")",
")",
"return",
"arrayToMap",
"(",
"(",
"Object",
"[",
"]",
")",
"value",
")",
";",
"if",
"(",
"value",
"instanceof",
"Collection",
"<",
"?",
">",
")",
"return",
"listToMap",
"(",
"(",
"Collection",
"<",
"Object",
">",
")",
"value",
")",
";",
"try",
"{",
"return",
"mapper",
".",
"convertValue",
"(",
"value",
",",
"typeRef",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
Converts value into map object or returns null when conversion is not
possible.
@param value the value to convert.
@return map object or null when conversion is not supported.
|
[
"Converts",
"value",
"into",
"map",
"object",
"or",
"returns",
"null",
"when",
"conversion",
"is",
"not",
"possible",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/MapConverter.java#L65-L88
|
155,609
|
rainu/dbc
|
src/main/java/de/raysha/lib/dbc/ConvertHelper.java
|
ConvertHelper.convertObjectToByteArray
|
public static byte[] convertObjectToByteArray(Object o) throws IOException{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(o);
return bos.toByteArray();
}
|
java
|
public static byte[] convertObjectToByteArray(Object o) throws IOException{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(o);
return bos.toByteArray();
}
|
[
"public",
"static",
"byte",
"[",
"]",
"convertObjectToByteArray",
"(",
"Object",
"o",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"bos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"oos",
"=",
"new",
"ObjectOutputStream",
"(",
"bos",
")",
";",
"oos",
".",
"writeObject",
"(",
"o",
")",
";",
"return",
"bos",
".",
"toByteArray",
"(",
")",
";",
"}"
] |
Konvertiert ein beliebiges Objekt in ein byte-Array.
@param o Objekt welches konvertiert werden soll.
@return byte-Array-Representation des Objektes
@throws IOException
|
[
"Konvertiert",
"ein",
"beliebiges",
"Objekt",
"in",
"ein",
"byte",
"-",
"Array",
"."
] |
bdf1d1945ccaa8db8ed0b91bd08d5ef9802777f7
|
https://github.com/rainu/dbc/blob/bdf1d1945ccaa8db8ed0b91bd08d5ef9802777f7/src/main/java/de/raysha/lib/dbc/ConvertHelper.java#L23-L29
|
155,610
|
rainu/dbc
|
src/main/java/de/raysha/lib/dbc/ConvertHelper.java
|
ConvertHelper.convertObjectToInputStream
|
public static InputStream convertObjectToInputStream(Object o) throws IOException{
byte[] bObject = convertObjectToByteArray(o);
return new ByteArrayInputStream(bObject);
}
|
java
|
public static InputStream convertObjectToInputStream(Object o) throws IOException{
byte[] bObject = convertObjectToByteArray(o);
return new ByteArrayInputStream(bObject);
}
|
[
"public",
"static",
"InputStream",
"convertObjectToInputStream",
"(",
"Object",
"o",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"bObject",
"=",
"convertObjectToByteArray",
"(",
"o",
")",
";",
"return",
"new",
"ByteArrayInputStream",
"(",
"bObject",
")",
";",
"}"
] |
Konvertiert ein beliebiges Objekt in ein byte-Array und schleust dieses durch ein InputStream.
@param o
@return
@throws IOException
|
[
"Konvertiert",
"ein",
"beliebiges",
"Objekt",
"in",
"ein",
"byte",
"-",
"Array",
"und",
"schleust",
"dieses",
"durch",
"ein",
"InputStream",
"."
] |
bdf1d1945ccaa8db8ed0b91bd08d5ef9802777f7
|
https://github.com/rainu/dbc/blob/bdf1d1945ccaa8db8ed0b91bd08d5ef9802777f7/src/main/java/de/raysha/lib/dbc/ConvertHelper.java#L37-L40
|
155,611
|
rainu/dbc
|
src/main/java/de/raysha/lib/dbc/ConvertHelper.java
|
ConvertHelper.convertInputStreamToObject
|
public static Object convertInputStreamToObject(InputStream is) throws IOException, ClassNotFoundException{
ObjectInputStream ois = new ObjectInputStream(is);
return ois.readObject();
}
|
java
|
public static Object convertInputStreamToObject(InputStream is) throws IOException, ClassNotFoundException{
ObjectInputStream ois = new ObjectInputStream(is);
return ois.readObject();
}
|
[
"public",
"static",
"Object",
"convertInputStreamToObject",
"(",
"InputStream",
"is",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"ObjectInputStream",
"ois",
"=",
"new",
"ObjectInputStream",
"(",
"is",
")",
";",
"return",
"ois",
".",
"readObject",
"(",
")",
";",
"}"
] |
Liest aus einen Inputstream ein Object aus.
@param is
@return
@throws IOException
@throws ClassNotFoundException
|
[
"Liest",
"aus",
"einen",
"Inputstream",
"ein",
"Object",
"aus",
"."
] |
bdf1d1945ccaa8db8ed0b91bd08d5ef9802777f7
|
https://github.com/rainu/dbc/blob/bdf1d1945ccaa8db8ed0b91bd08d5ef9802777f7/src/main/java/de/raysha/lib/dbc/ConvertHelper.java#L50-L53
|
155,612
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/web/HttpServletRequestUtility.java
|
HttpServletRequestUtility.getBasicAuthUsername
|
static public String getBasicAuthUsername(HttpServletRequest request){
String[] userAndPassword = getBasicAuthUsernameAndPassword(request);
return userAndPassword == null || userAndPassword.length == 0 ? null : userAndPassword[0];
}
|
java
|
static public String getBasicAuthUsername(HttpServletRequest request){
String[] userAndPassword = getBasicAuthUsernameAndPassword(request);
return userAndPassword == null || userAndPassword.length == 0 ? null : userAndPassword[0];
}
|
[
"static",
"public",
"String",
"getBasicAuthUsername",
"(",
"HttpServletRequest",
"request",
")",
"{",
"String",
"[",
"]",
"userAndPassword",
"=",
"getBasicAuthUsernameAndPassword",
"(",
"request",
")",
";",
"return",
"userAndPassword",
"==",
"null",
"||",
"userAndPassword",
".",
"length",
"==",
"0",
"?",
"null",
":",
"userAndPassword",
"[",
"0",
"]",
";",
"}"
] |
Get the user name in the basic authentication header
@param request the http servlet request
@return the user name, or null if not found
|
[
"Get",
"the",
"user",
"name",
"in",
"the",
"basic",
"authentication",
"header"
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/web/HttpServletRequestUtility.java#L22-L25
|
155,613
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/web/HttpServletRequestUtility.java
|
HttpServletRequestUtility.getBasicAuthUsernameAndPassword
|
static public String[] getBasicAuthUsernameAndPassword(HttpServletRequest request){
String authorization = request.getHeader("Authorization");
if (authorization != null && authorization.startsWith("Basic")) {
try{
// Authorization: Basic base64credentials
String base64Credentials = authorization.substring("Basic".length()).trim();
String credentials = new String(Base64.decode(base64Credentials), "UTF-8");
// credentials = username:password
String[] values = StringUtils.split(credentials, ':');
return values;
}catch(Exception e){
// ignore
}
}
return null;
}
|
java
|
static public String[] getBasicAuthUsernameAndPassword(HttpServletRequest request){
String authorization = request.getHeader("Authorization");
if (authorization != null && authorization.startsWith("Basic")) {
try{
// Authorization: Basic base64credentials
String base64Credentials = authorization.substring("Basic".length()).trim();
String credentials = new String(Base64.decode(base64Credentials), "UTF-8");
// credentials = username:password
String[] values = StringUtils.split(credentials, ':');
return values;
}catch(Exception e){
// ignore
}
}
return null;
}
|
[
"static",
"public",
"String",
"[",
"]",
"getBasicAuthUsernameAndPassword",
"(",
"HttpServletRequest",
"request",
")",
"{",
"String",
"authorization",
"=",
"request",
".",
"getHeader",
"(",
"\"Authorization\"",
")",
";",
"if",
"(",
"authorization",
"!=",
"null",
"&&",
"authorization",
".",
"startsWith",
"(",
"\"Basic\"",
")",
")",
"{",
"try",
"{",
"// Authorization: Basic base64credentials",
"String",
"base64Credentials",
"=",
"authorization",
".",
"substring",
"(",
"\"Basic\"",
".",
"length",
"(",
")",
")",
".",
"trim",
"(",
")",
";",
"String",
"credentials",
"=",
"new",
"String",
"(",
"Base64",
".",
"decode",
"(",
"base64Credentials",
")",
",",
"\"UTF-8\"",
")",
";",
"// credentials = username:password",
"String",
"[",
"]",
"values",
"=",
"StringUtils",
".",
"split",
"(",
"credentials",
",",
"'",
"'",
")",
";",
"return",
"values",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// ignore",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get the user name and password passed in the basic authentication header.
@param request the http servlet request
@return user name and password, or null if not found. If there is no password,
the result may contain only one element, or two elements and the second element is null or empty.
|
[
"Get",
"the",
"user",
"name",
"and",
"password",
"passed",
"in",
"the",
"basic",
"authentication",
"header",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/web/HttpServletRequestUtility.java#L33-L48
|
155,614
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/web/HttpServletRequestUtility.java
|
HttpServletRequestUtility.isFromLocalhost
|
static public boolean isFromLocalhost(HttpServletRequest request){
String addr = request.getRemoteAddr();
return "0:0:0:0:0:0:0:1".equals(addr) || "::1".equals(addr)
|| (addr != null && addr.startsWith("127."));
}
|
java
|
static public boolean isFromLocalhost(HttpServletRequest request){
String addr = request.getRemoteAddr();
return "0:0:0:0:0:0:0:1".equals(addr) || "::1".equals(addr)
|| (addr != null && addr.startsWith("127."));
}
|
[
"static",
"public",
"boolean",
"isFromLocalhost",
"(",
"HttpServletRequest",
"request",
")",
"{",
"String",
"addr",
"=",
"request",
".",
"getRemoteAddr",
"(",
")",
";",
"return",
"\"0:0:0:0:0:0:0:1\"",
".",
"equals",
"(",
"addr",
")",
"||",
"\"::1\"",
".",
"equals",
"(",
"addr",
")",
"||",
"(",
"addr",
"!=",
"null",
"&&",
"addr",
".",
"startsWith",
"(",
"\"127.\"",
")",
")",
";",
"}"
] |
Check to see if the request is from localhost
@param request the http request
@return true if it is from localhost, false if not.
|
[
"Check",
"to",
"see",
"if",
"the",
"request",
"is",
"from",
"localhost"
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/web/HttpServletRequestUtility.java#L55-L59
|
155,615
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/PermissionUtil.java
|
PermissionUtil.id2Permissions
|
public static List<Permission> id2Permissions(int id){
List<Permission> list = new ArrayList<Permission>();
if(id <= 0 || id > 31){
list.add(Permission.NONE);
}else{
if((id & Permission.READ.getId())!=0){
list.add(Permission.READ);
}
if((id & Permission.WRITE.getId())!=0){
list.add(Permission.WRITE);
}
if((id & Permission.CREATE.getId())!=0){
list.add(Permission.CREATE);
}
if((id & Permission.DELETE.getId())!=0){
list.add(Permission.DELETE);
}
if((id & Permission.ADMIN.getId())!=0){
list.add(Permission.ADMIN);
}
}
return list;
}
|
java
|
public static List<Permission> id2Permissions(int id){
List<Permission> list = new ArrayList<Permission>();
if(id <= 0 || id > 31){
list.add(Permission.NONE);
}else{
if((id & Permission.READ.getId())!=0){
list.add(Permission.READ);
}
if((id & Permission.WRITE.getId())!=0){
list.add(Permission.WRITE);
}
if((id & Permission.CREATE.getId())!=0){
list.add(Permission.CREATE);
}
if((id & Permission.DELETE.getId())!=0){
list.add(Permission.DELETE);
}
if((id & Permission.ADMIN.getId())!=0){
list.add(Permission.ADMIN);
}
}
return list;
}
|
[
"public",
"static",
"List",
"<",
"Permission",
">",
"id2Permissions",
"(",
"int",
"id",
")",
"{",
"List",
"<",
"Permission",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"Permission",
">",
"(",
")",
";",
"if",
"(",
"id",
"<=",
"0",
"||",
"id",
">",
"31",
")",
"{",
"list",
".",
"add",
"(",
"Permission",
".",
"NONE",
")",
";",
"}",
"else",
"{",
"if",
"(",
"(",
"id",
"&",
"Permission",
".",
"READ",
".",
"getId",
"(",
")",
")",
"!=",
"0",
")",
"{",
"list",
".",
"add",
"(",
"Permission",
".",
"READ",
")",
";",
"}",
"if",
"(",
"(",
"id",
"&",
"Permission",
".",
"WRITE",
".",
"getId",
"(",
")",
")",
"!=",
"0",
")",
"{",
"list",
".",
"add",
"(",
"Permission",
".",
"WRITE",
")",
";",
"}",
"if",
"(",
"(",
"id",
"&",
"Permission",
".",
"CREATE",
".",
"getId",
"(",
")",
")",
"!=",
"0",
")",
"{",
"list",
".",
"add",
"(",
"Permission",
".",
"CREATE",
")",
";",
"}",
"if",
"(",
"(",
"id",
"&",
"Permission",
".",
"DELETE",
".",
"getId",
"(",
")",
")",
"!=",
"0",
")",
"{",
"list",
".",
"add",
"(",
"Permission",
".",
"DELETE",
")",
";",
"}",
"if",
"(",
"(",
"id",
"&",
"Permission",
".",
"ADMIN",
".",
"getId",
"(",
")",
")",
"!=",
"0",
")",
"{",
"list",
".",
"add",
"(",
"Permission",
".",
"ADMIN",
")",
";",
"}",
"}",
"return",
"list",
";",
"}"
] |
Transfer the permission id to Permission list.
@param id
the permission id.
@return
the Permission list.
|
[
"Transfer",
"the",
"permission",
"id",
"to",
"Permission",
"list",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/PermissionUtil.java#L38-L60
|
155,616
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/PermissionUtil.java
|
PermissionUtil.permissionList2Id
|
public static int permissionList2Id(List<Permission> permissions){
int id = 0;
if(permissions != null && ! permissions.isEmpty()){
for (Permission p : permissions) {
id += p.getId();
}
}
return id;
}
|
java
|
public static int permissionList2Id(List<Permission> permissions){
int id = 0;
if(permissions != null && ! permissions.isEmpty()){
for (Permission p : permissions) {
id += p.getId();
}
}
return id;
}
|
[
"public",
"static",
"int",
"permissionList2Id",
"(",
"List",
"<",
"Permission",
">",
"permissions",
")",
"{",
"int",
"id",
"=",
"0",
";",
"if",
"(",
"permissions",
"!=",
"null",
"&&",
"!",
"permissions",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"Permission",
"p",
":",
"permissions",
")",
"{",
"id",
"+=",
"p",
".",
"getId",
"(",
")",
";",
"}",
"}",
"return",
"id",
";",
"}"
] |
Transfer the Permission List to id.
@param permissions
the Permission list.
@return
the permission id.
|
[
"Transfer",
"the",
"Permission",
"List",
"to",
"id",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/PermissionUtil.java#L70-L78
|
155,617
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/PermissionUtil.java
|
PermissionUtil.permissionArray2Id
|
public static int permissionArray2Id(Permission[] permissions){
int id = 0;
if(permissions != null && permissions.length != 0){
for (Permission p : permissions) {
id += p.getId();
}
}
return id;
}
|
java
|
public static int permissionArray2Id(Permission[] permissions){
int id = 0;
if(permissions != null && permissions.length != 0){
for (Permission p : permissions) {
id += p.getId();
}
}
return id;
}
|
[
"public",
"static",
"int",
"permissionArray2Id",
"(",
"Permission",
"[",
"]",
"permissions",
")",
"{",
"int",
"id",
"=",
"0",
";",
"if",
"(",
"permissions",
"!=",
"null",
"&&",
"permissions",
".",
"length",
"!=",
"0",
")",
"{",
"for",
"(",
"Permission",
"p",
":",
"permissions",
")",
"{",
"id",
"+=",
"p",
".",
"getId",
"(",
")",
";",
"}",
"}",
"return",
"id",
";",
"}"
] |
Transfer the Permission Array to id.
@param permissions
the Permission Array.
@return
the permission id.
|
[
"Transfer",
"the",
"Permission",
"Array",
"to",
"id",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/PermissionUtil.java#L88-L96
|
155,618
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/StringConverter.java
|
StringConverter.toNullableString
|
public static String toNullableString(Object value) {
// Shortcuts
if (value == null)
return null;
if (value instanceof String)
return (String) value;
// Legacy and new dates
if (value instanceof Date)
value = ZonedDateTime.ofInstant(((Date) value).toInstant(), ZoneId.systemDefault());
if (value instanceof Calendar) {
value = ZonedDateTime.ofInstant(((Calendar) value).toInstant(),
((Calendar) value).getTimeZone().toZoneId());
}
if (value instanceof Duration)
value = ((Duration) value).toMillis();
if (value instanceof Instant)
value = ZonedDateTime.ofInstant((Instant) value, ZoneId.systemDefault());
if (value instanceof LocalDateTime)
value = ZonedDateTime.of((LocalDateTime) value, ZoneId.systemDefault());
if (value instanceof LocalDate)
value = ZonedDateTime.of((LocalDate) value, LocalTime.of(0, 0), ZoneId.systemDefault());
if (value instanceof ZonedDateTime)
return ((ZonedDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
// Convert list
if (value instanceof List<?>) {
StringBuilder builder = new StringBuilder();
for (Object element : (List<?>)value) {
if (builder.length() > 0)
builder.append(",");
builder.append(element);
}
return builder.toString();
}
// Convert array
if (value.getClass().isArray()) {
StringBuilder builder = new StringBuilder();
int length = Array.getLength(value);
for (int index = 0; index < length; index++) {
if (builder.length() > 0)
builder.append(",");
builder.append(Array.get(value, index));
}
return builder.toString();
}
// Everything else
return value.toString();
}
|
java
|
public static String toNullableString(Object value) {
// Shortcuts
if (value == null)
return null;
if (value instanceof String)
return (String) value;
// Legacy and new dates
if (value instanceof Date)
value = ZonedDateTime.ofInstant(((Date) value).toInstant(), ZoneId.systemDefault());
if (value instanceof Calendar) {
value = ZonedDateTime.ofInstant(((Calendar) value).toInstant(),
((Calendar) value).getTimeZone().toZoneId());
}
if (value instanceof Duration)
value = ((Duration) value).toMillis();
if (value instanceof Instant)
value = ZonedDateTime.ofInstant((Instant) value, ZoneId.systemDefault());
if (value instanceof LocalDateTime)
value = ZonedDateTime.of((LocalDateTime) value, ZoneId.systemDefault());
if (value instanceof LocalDate)
value = ZonedDateTime.of((LocalDate) value, LocalTime.of(0, 0), ZoneId.systemDefault());
if (value instanceof ZonedDateTime)
return ((ZonedDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
// Convert list
if (value instanceof List<?>) {
StringBuilder builder = new StringBuilder();
for (Object element : (List<?>)value) {
if (builder.length() > 0)
builder.append(",");
builder.append(element);
}
return builder.toString();
}
// Convert array
if (value.getClass().isArray()) {
StringBuilder builder = new StringBuilder();
int length = Array.getLength(value);
for (int index = 0; index < length; index++) {
if (builder.length() > 0)
builder.append(",");
builder.append(Array.get(value, index));
}
return builder.toString();
}
// Everything else
return value.toString();
}
|
[
"public",
"static",
"String",
"toNullableString",
"(",
"Object",
"value",
")",
"{",
"// Shortcuts",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"value",
"instanceof",
"String",
")",
"return",
"(",
"String",
")",
"value",
";",
"// Legacy and new dates",
"if",
"(",
"value",
"instanceof",
"Date",
")",
"value",
"=",
"ZonedDateTime",
".",
"ofInstant",
"(",
"(",
"(",
"Date",
")",
"value",
")",
".",
"toInstant",
"(",
")",
",",
"ZoneId",
".",
"systemDefault",
"(",
")",
")",
";",
"if",
"(",
"value",
"instanceof",
"Calendar",
")",
"{",
"value",
"=",
"ZonedDateTime",
".",
"ofInstant",
"(",
"(",
"(",
"Calendar",
")",
"value",
")",
".",
"toInstant",
"(",
")",
",",
"(",
"(",
"Calendar",
")",
"value",
")",
".",
"getTimeZone",
"(",
")",
".",
"toZoneId",
"(",
")",
")",
";",
"}",
"if",
"(",
"value",
"instanceof",
"Duration",
")",
"value",
"=",
"(",
"(",
"Duration",
")",
"value",
")",
".",
"toMillis",
"(",
")",
";",
"if",
"(",
"value",
"instanceof",
"Instant",
")",
"value",
"=",
"ZonedDateTime",
".",
"ofInstant",
"(",
"(",
"Instant",
")",
"value",
",",
"ZoneId",
".",
"systemDefault",
"(",
")",
")",
";",
"if",
"(",
"value",
"instanceof",
"LocalDateTime",
")",
"value",
"=",
"ZonedDateTime",
".",
"of",
"(",
"(",
"LocalDateTime",
")",
"value",
",",
"ZoneId",
".",
"systemDefault",
"(",
")",
")",
";",
"if",
"(",
"value",
"instanceof",
"LocalDate",
")",
"value",
"=",
"ZonedDateTime",
".",
"of",
"(",
"(",
"LocalDate",
")",
"value",
",",
"LocalTime",
".",
"of",
"(",
"0",
",",
"0",
")",
",",
"ZoneId",
".",
"systemDefault",
"(",
")",
")",
";",
"if",
"(",
"value",
"instanceof",
"ZonedDateTime",
")",
"return",
"(",
"(",
"ZonedDateTime",
")",
"value",
")",
".",
"format",
"(",
"DateTimeFormatter",
".",
"ISO_OFFSET_DATE_TIME",
")",
";",
"// Convert list",
"if",
"(",
"value",
"instanceof",
"List",
"<",
"?",
">",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Object",
"element",
":",
"(",
"List",
"<",
"?",
">",
")",
"value",
")",
"{",
"if",
"(",
"builder",
".",
"length",
"(",
")",
">",
"0",
")",
"builder",
".",
"append",
"(",
"\",\"",
")",
";",
"builder",
".",
"append",
"(",
"element",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}",
"// Convert array",
"if",
"(",
"value",
".",
"getClass",
"(",
")",
".",
"isArray",
"(",
")",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"length",
"=",
"Array",
".",
"getLength",
"(",
"value",
")",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"length",
";",
"index",
"++",
")",
"{",
"if",
"(",
"builder",
".",
"length",
"(",
")",
">",
"0",
")",
"builder",
".",
"append",
"(",
"\",\"",
")",
";",
"builder",
".",
"append",
"(",
"Array",
".",
"get",
"(",
"value",
",",
"index",
")",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}",
"// Everything else",
"return",
"value",
".",
"toString",
"(",
")",
";",
"}"
] |
Converts value into string or returns null when value is null.
@param value the value to convert.
@return string value or null when value is null.
|
[
"Converts",
"value",
"into",
"string",
"or",
"returns",
"null",
"when",
"value",
"is",
"null",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/StringConverter.java#L37-L88
|
155,619
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/StringConverter.java
|
StringConverter.toStringWithDefault
|
public static String toStringWithDefault(Object value, String defaultValue) {
String result = toNullableString(value);
return result != null ? result : defaultValue;
}
|
java
|
public static String toStringWithDefault(Object value, String defaultValue) {
String result = toNullableString(value);
return result != null ? result : defaultValue;
}
|
[
"public",
"static",
"String",
"toStringWithDefault",
"(",
"Object",
"value",
",",
"String",
"defaultValue",
")",
"{",
"String",
"result",
"=",
"toNullableString",
"(",
"value",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"result",
":",
"defaultValue",
";",
"}"
] |
Converts value into string or returns default when value is null.
@param value the value to convert.
@param defaultValue the default value.
@return string value or default when value is null.
@see StringConverter#toNullableString(Object)
|
[
"Converts",
"value",
"into",
"string",
"or",
"returns",
"default",
"when",
"value",
"is",
"null",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/StringConverter.java#L111-L114
|
155,620
|
zandero/http
|
src/main/java/com/zandero/http/HttpUtils.java
|
HttpUtils.get
|
public static HttpRequestBase get(String path,
Map<String, String> headers,
Integer timeOutInSeconds) {
HttpGet get = new HttpGet(path);
addHeaders(get, headers);
get.setConfig(getConfig(timeOutInSeconds));
return get;
}
|
java
|
public static HttpRequestBase get(String path,
Map<String, String> headers,
Integer timeOutInSeconds) {
HttpGet get = new HttpGet(path);
addHeaders(get, headers);
get.setConfig(getConfig(timeOutInSeconds));
return get;
}
|
[
"public",
"static",
"HttpRequestBase",
"get",
"(",
"String",
"path",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
",",
"Integer",
"timeOutInSeconds",
")",
"{",
"HttpGet",
"get",
"=",
"new",
"HttpGet",
"(",
"path",
")",
";",
"addHeaders",
"(",
"get",
",",
"headers",
")",
";",
"get",
".",
"setConfig",
"(",
"getConfig",
"(",
"timeOutInSeconds",
")",
")",
";",
"return",
"get",
";",
"}"
] |
Step 1. prepare GET request
@param path target url
@param headers request headers
@param timeOutInSeconds time out in seconds or null for default time out
@return get request
|
[
"Step",
"1",
".",
"prepare",
"GET",
"request"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/HttpUtils.java#L68-L77
|
155,621
|
zandero/http
|
src/main/java/com/zandero/http/HttpUtils.java
|
HttpUtils.post
|
public static HttpRequestBase post(String path,
Map<String, String> headers,
Map<String, String> parameters,
HttpEntity entity,
Integer timeOutInSeconds) {
HttpPost post = new HttpPost(path);
addHeaders(post, headers);
addParameters(post, parameters);
post.setConfig(getConfig(timeOutInSeconds));
if (entity != null) {
post.setEntity(entity);
}
return post;
}
|
java
|
public static HttpRequestBase post(String path,
Map<String, String> headers,
Map<String, String> parameters,
HttpEntity entity,
Integer timeOutInSeconds) {
HttpPost post = new HttpPost(path);
addHeaders(post, headers);
addParameters(post, parameters);
post.setConfig(getConfig(timeOutInSeconds));
if (entity != null) {
post.setEntity(entity);
}
return post;
}
|
[
"public",
"static",
"HttpRequestBase",
"post",
"(",
"String",
"path",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
",",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
",",
"HttpEntity",
"entity",
",",
"Integer",
"timeOutInSeconds",
")",
"{",
"HttpPost",
"post",
"=",
"new",
"HttpPost",
"(",
"path",
")",
";",
"addHeaders",
"(",
"post",
",",
"headers",
")",
";",
"addParameters",
"(",
"post",
",",
"parameters",
")",
";",
"post",
".",
"setConfig",
"(",
"getConfig",
"(",
"timeOutInSeconds",
")",
")",
";",
"if",
"(",
"entity",
"!=",
"null",
")",
"{",
"post",
".",
"setEntity",
"(",
"entity",
")",
";",
"}",
"return",
"post",
";",
"}"
] |
Step 1. prepare POST request
@param path target url
@param headers request headers
@param entity to POST
@param parameters to POST
@param timeOutInSeconds time out in seconds or null for default time out
@return post request
|
[
"Step",
"1",
".",
"prepare",
"POST",
"request"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/HttpUtils.java#L100-L117
|
155,622
|
zandero/http
|
src/main/java/com/zandero/http/HttpUtils.java
|
HttpUtils.patch
|
public static HttpRequestBase patch(String path,
Map<String, String> headers,
Map<String, String> parameters,
HttpEntity entity,
Integer timeOutInSeconds) {
HttpPatch patch = new HttpPatch(path);
addHeaders(patch, headers);
addParameters(patch, parameters);
patch.setConfig(getConfig(timeOutInSeconds));
if (entity != null) {
patch.setEntity(entity);
}
return patch;
}
|
java
|
public static HttpRequestBase patch(String path,
Map<String, String> headers,
Map<String, String> parameters,
HttpEntity entity,
Integer timeOutInSeconds) {
HttpPatch patch = new HttpPatch(path);
addHeaders(patch, headers);
addParameters(patch, parameters);
patch.setConfig(getConfig(timeOutInSeconds));
if (entity != null) {
patch.setEntity(entity);
}
return patch;
}
|
[
"public",
"static",
"HttpRequestBase",
"patch",
"(",
"String",
"path",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
",",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
",",
"HttpEntity",
"entity",
",",
"Integer",
"timeOutInSeconds",
")",
"{",
"HttpPatch",
"patch",
"=",
"new",
"HttpPatch",
"(",
"path",
")",
";",
"addHeaders",
"(",
"patch",
",",
"headers",
")",
";",
"addParameters",
"(",
"patch",
",",
"parameters",
")",
";",
"patch",
".",
"setConfig",
"(",
"getConfig",
"(",
"timeOutInSeconds",
")",
")",
";",
"if",
"(",
"entity",
"!=",
"null",
")",
"{",
"patch",
".",
"setEntity",
"(",
"entity",
")",
";",
"}",
"return",
"patch",
";",
"}"
] |
Step 1. prepare PATCH request
@param path target url
@param headers request headers
@param parameters to PATCH
@param entity send to patch
@param timeOutInSeconds time out in seconds or null for default time out
@return patch request
|
[
"Step",
"1",
".",
"prepare",
"PATCH",
"request"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/HttpUtils.java#L206-L222
|
155,623
|
zandero/http
|
src/main/java/com/zandero/http/HttpUtils.java
|
HttpUtils.delete
|
public static HttpRequestBase delete(String path,
Map<String, String> headers,
Integer timeOutInSeconds) {
HttpDelete delete = new HttpDelete(path);
addHeaders(delete, headers);
delete.setConfig(getConfig(timeOutInSeconds));
return delete;
}
|
java
|
public static HttpRequestBase delete(String path,
Map<String, String> headers,
Integer timeOutInSeconds) {
HttpDelete delete = new HttpDelete(path);
addHeaders(delete, headers);
delete.setConfig(getConfig(timeOutInSeconds));
return delete;
}
|
[
"public",
"static",
"HttpRequestBase",
"delete",
"(",
"String",
"path",
",",
"Map",
"<",
"String",
",",
"String",
">",
"headers",
",",
"Integer",
"timeOutInSeconds",
")",
"{",
"HttpDelete",
"delete",
"=",
"new",
"HttpDelete",
"(",
"path",
")",
";",
"addHeaders",
"(",
"delete",
",",
"headers",
")",
";",
"delete",
".",
"setConfig",
"(",
"getConfig",
"(",
"timeOutInSeconds",
")",
")",
";",
"return",
"delete",
";",
"}"
] |
Step 1. prepare DELETE request
@param path target url
@param headers request headers
@param timeOutInSeconds time out in seconds or null for default time out
@return delete request
|
[
"Step",
"1",
".",
"prepare",
"DELETE",
"request"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/HttpUtils.java#L272-L281
|
155,624
|
zandero/http
|
src/main/java/com/zandero/http/HttpUtils.java
|
HttpUtils.execute
|
public static HttpResponse execute(HttpRequestBase request) throws IOException {
Assert.notNull(request, "Missing request!");
HttpClient client = HttpClientBuilder.create().setRedirectStrategy(new DefaultRedirectStrategy()).build();
return client.execute(request);
}
|
java
|
public static HttpResponse execute(HttpRequestBase request) throws IOException {
Assert.notNull(request, "Missing request!");
HttpClient client = HttpClientBuilder.create().setRedirectStrategy(new DefaultRedirectStrategy()).build();
return client.execute(request);
}
|
[
"public",
"static",
"HttpResponse",
"execute",
"(",
"HttpRequestBase",
"request",
")",
"throws",
"IOException",
"{",
"Assert",
".",
"notNull",
"(",
"request",
",",
"\"Missing request!\"",
")",
";",
"HttpClient",
"client",
"=",
"HttpClientBuilder",
".",
"create",
"(",
")",
".",
"setRedirectStrategy",
"(",
"new",
"DefaultRedirectStrategy",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"client",
".",
"execute",
"(",
"request",
")",
";",
"}"
] |
Step 2. execute request
@param request to be executed
@return response
@throws IOException in case of network failure
|
[
"Step",
"2",
".",
"execute",
"request"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/HttpUtils.java#L290-L295
|
155,625
|
zandero/http
|
src/main/java/com/zandero/http/HttpUtils.java
|
HttpUtils.executeAsync
|
public static void executeAsync(Executor executor, HttpRequestBase request, FutureCallback<HttpResponse> callback) {
try {
executor.execute(new AsyncHttpCall(request, callback));
}
catch (Exception e) {
log.error("Failed to execute asynchronously: " + request.getMethod() + " " + request.getURI().toString());
}
}
|
java
|
public static void executeAsync(Executor executor, HttpRequestBase request, FutureCallback<HttpResponse> callback) {
try {
executor.execute(new AsyncHttpCall(request, callback));
}
catch (Exception e) {
log.error("Failed to execute asynchronously: " + request.getMethod() + " " + request.getURI().toString());
}
}
|
[
"public",
"static",
"void",
"executeAsync",
"(",
"Executor",
"executor",
",",
"HttpRequestBase",
"request",
",",
"FutureCallback",
"<",
"HttpResponse",
">",
"callback",
")",
"{",
"try",
"{",
"executor",
".",
"execute",
"(",
"new",
"AsyncHttpCall",
"(",
"request",
",",
"callback",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Failed to execute asynchronously: \"",
"+",
"request",
".",
"getMethod",
"(",
")",
"+",
"\" \"",
"+",
"request",
".",
"getURI",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] |
Step 2. execute request asynchronously
@param executor thread executor to be used
@param request to be executed
@param callback to be invoked when request is completed or failes
|
[
"Step",
"2",
".",
"execute",
"request",
"asynchronously"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/HttpUtils.java#L304-L312
|
155,626
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/reflect/TypeMatcher.java
|
TypeMatcher.matchValue
|
public static boolean matchValue(Object expectedType, Object actualValue) {
if (expectedType == null)
return true;
if (actualValue == null)
throw new NullPointerException("Actual value cannot be null");
return matchType(expectedType, actualValue.getClass());
}
|
java
|
public static boolean matchValue(Object expectedType, Object actualValue) {
if (expectedType == null)
return true;
if (actualValue == null)
throw new NullPointerException("Actual value cannot be null");
return matchType(expectedType, actualValue.getClass());
}
|
[
"public",
"static",
"boolean",
"matchValue",
"(",
"Object",
"expectedType",
",",
"Object",
"actualValue",
")",
"{",
"if",
"(",
"expectedType",
"==",
"null",
")",
"return",
"true",
";",
"if",
"(",
"actualValue",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Actual value cannot be null\"",
")",
";",
"return",
"matchType",
"(",
"expectedType",
",",
"actualValue",
".",
"getClass",
"(",
")",
")",
";",
"}"
] |
Matches expected type to a type of a value. The expected type can be
specified by a type, type name or TypeCode.
@param expectedType an expected type to match.
@param actualValue a value to match its type to the expected one.
@return true if types are matching and false if they don't.
@see #matchType(Object, Class)
@see #matchValueByName(String, Object) (for matching by types' string names)
|
[
"Matches",
"expected",
"type",
"to",
"a",
"type",
"of",
"a",
"value",
".",
"The",
"expected",
"type",
"can",
"be",
"specified",
"by",
"a",
"type",
"type",
"name",
"or",
"TypeCode",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/TypeMatcher.java#L30-L37
|
155,627
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/reflect/TypeMatcher.java
|
TypeMatcher.matchType
|
public static boolean matchType(Object expectedType, Class<?> actualType) {
if (expectedType == null)
return true;
if (actualType == null)
throw new NullPointerException("Actual type cannot be null");
if (expectedType instanceof Class<?>)
return ((Class<?>) expectedType).isAssignableFrom(actualType);
if (expectedType instanceof String)
return matchTypeByName((String) expectedType, actualType);
if (expectedType instanceof TypeCode)
return TypeConverter.toTypeCode(actualType).equals(expectedType);
return false;
}
|
java
|
public static boolean matchType(Object expectedType, Class<?> actualType) {
if (expectedType == null)
return true;
if (actualType == null)
throw new NullPointerException("Actual type cannot be null");
if (expectedType instanceof Class<?>)
return ((Class<?>) expectedType).isAssignableFrom(actualType);
if (expectedType instanceof String)
return matchTypeByName((String) expectedType, actualType);
if (expectedType instanceof TypeCode)
return TypeConverter.toTypeCode(actualType).equals(expectedType);
return false;
}
|
[
"public",
"static",
"boolean",
"matchType",
"(",
"Object",
"expectedType",
",",
"Class",
"<",
"?",
">",
"actualType",
")",
"{",
"if",
"(",
"expectedType",
"==",
"null",
")",
"return",
"true",
";",
"if",
"(",
"actualType",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Actual type cannot be null\"",
")",
";",
"if",
"(",
"expectedType",
"instanceof",
"Class",
"<",
"?",
">",
")",
"return",
"(",
"(",
"Class",
"<",
"?",
">",
")",
"expectedType",
")",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"if",
"(",
"expectedType",
"instanceof",
"String",
")",
"return",
"matchTypeByName",
"(",
"(",
"String",
")",
"expectedType",
",",
"actualType",
")",
";",
"if",
"(",
"expectedType",
"instanceof",
"TypeCode",
")",
"return",
"TypeConverter",
".",
"toTypeCode",
"(",
"actualType",
")",
".",
"equals",
"(",
"expectedType",
")",
";",
"return",
"false",
";",
"}"
] |
Matches expected type to an actual type. The types can be specified as types,
type names or TypeCode.
@param expectedType an expected type to match.
@param actualType an actual type to match.
@return true if types are matching and false if they don't.
@see #matchTypeByName(String, Class)
|
[
"Matches",
"expected",
"type",
"to",
"an",
"actual",
"type",
".",
"The",
"types",
"can",
"be",
"specified",
"as",
"types",
"type",
"names",
"or",
"TypeCode",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/TypeMatcher.java#L49-L65
|
155,628
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/reflect/TypeMatcher.java
|
TypeMatcher.matchValueByName
|
public static boolean matchValueByName(String expectedType, Object actualValue) {
if (expectedType == null)
return true;
if (actualValue == null)
throw new NullPointerException("Actual value cannot be null");
return matchTypeByName(expectedType, actualValue.getClass());
}
|
java
|
public static boolean matchValueByName(String expectedType, Object actualValue) {
if (expectedType == null)
return true;
if (actualValue == null)
throw new NullPointerException("Actual value cannot be null");
return matchTypeByName(expectedType, actualValue.getClass());
}
|
[
"public",
"static",
"boolean",
"matchValueByName",
"(",
"String",
"expectedType",
",",
"Object",
"actualValue",
")",
"{",
"if",
"(",
"expectedType",
"==",
"null",
")",
"return",
"true",
";",
"if",
"(",
"actualValue",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Actual value cannot be null\"",
")",
";",
"return",
"matchTypeByName",
"(",
"expectedType",
",",
"actualValue",
".",
"getClass",
"(",
")",
")",
";",
"}"
] |
Matches expected type to a type of a value.
@param expectedType an expected type name to match.
@param actualValue a value to match its type to the expected one.
@return true if types are matching and false if they don't.
|
[
"Matches",
"expected",
"type",
"to",
"a",
"type",
"of",
"a",
"value",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/TypeMatcher.java#L74-L81
|
155,629
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/reflect/TypeMatcher.java
|
TypeMatcher.matchTypeByName
|
public static boolean matchTypeByName(String expectedType, Class<?> actualType) {
if (expectedType == null)
return true;
if (actualType == null)
throw new NullPointerException("Actual type cannot be null");
expectedType = expectedType.toLowerCase();
if (actualType.getName().equalsIgnoreCase(expectedType))
return true;
else if (actualType.getSimpleName().equalsIgnoreCase(expectedType))
return true;
else if (expectedType.equals("object"))
return true;
else if (expectedType.equals("int") || expectedType.equals("integer")) {
return Integer.class.isAssignableFrom(actualType) || Long.class.isAssignableFrom(actualType);
} else if (expectedType.equals("long")) {
return Long.class.isAssignableFrom(actualType);
} else if (expectedType.equals("float")) {
return Float.class.isAssignableFrom(actualType) || Double.class.isAssignableFrom(actualType);
} else if (expectedType.equals("double")) {
return Double.class.isAssignableFrom(actualType);
} else if (expectedType.equals("string")) {
return String.class.isAssignableFrom(actualType);
} else if (expectedType.equals("bool") || expectedType.equals("boolean")) {
return Boolean.class.isAssignableFrom(actualType);
} else if (expectedType.equals("date") || expectedType.equals("datetime")) {
return Date.class.isAssignableFrom(actualType) || Calendar.class.isAssignableFrom(actualType)
|| ZonedDateTime.class.isAssignableFrom(actualType);
} else if (expectedType.equals("timespan") || expectedType.equals("duration")) {
return Integer.class.isAssignableFrom(actualType) || Long.class.isAssignableFrom(actualType)
|| Float.class.isAssignableFrom(actualType) || Double.class.isAssignableFrom(actualType);
} else if (expectedType.equals("enum")) {
return Enum.class.isAssignableFrom(actualType);
} else if (expectedType.equals("map") || expectedType.equals("dict") || expectedType.equals("dictionary")) {
return Map.class.isAssignableFrom(actualType);
} else if (expectedType.equals("array") || expectedType.equals("list")) {
return actualType.isArray() || List.class.isAssignableFrom(actualType);
} else if (expectedType.endsWith("[]")) {
// Todo: Check subtype
return actualType.isArray() || List.class.isAssignableFrom(actualType);
} else
return false;
}
|
java
|
public static boolean matchTypeByName(String expectedType, Class<?> actualType) {
if (expectedType == null)
return true;
if (actualType == null)
throw new NullPointerException("Actual type cannot be null");
expectedType = expectedType.toLowerCase();
if (actualType.getName().equalsIgnoreCase(expectedType))
return true;
else if (actualType.getSimpleName().equalsIgnoreCase(expectedType))
return true;
else if (expectedType.equals("object"))
return true;
else if (expectedType.equals("int") || expectedType.equals("integer")) {
return Integer.class.isAssignableFrom(actualType) || Long.class.isAssignableFrom(actualType);
} else if (expectedType.equals("long")) {
return Long.class.isAssignableFrom(actualType);
} else if (expectedType.equals("float")) {
return Float.class.isAssignableFrom(actualType) || Double.class.isAssignableFrom(actualType);
} else if (expectedType.equals("double")) {
return Double.class.isAssignableFrom(actualType);
} else if (expectedType.equals("string")) {
return String.class.isAssignableFrom(actualType);
} else if (expectedType.equals("bool") || expectedType.equals("boolean")) {
return Boolean.class.isAssignableFrom(actualType);
} else if (expectedType.equals("date") || expectedType.equals("datetime")) {
return Date.class.isAssignableFrom(actualType) || Calendar.class.isAssignableFrom(actualType)
|| ZonedDateTime.class.isAssignableFrom(actualType);
} else if (expectedType.equals("timespan") || expectedType.equals("duration")) {
return Integer.class.isAssignableFrom(actualType) || Long.class.isAssignableFrom(actualType)
|| Float.class.isAssignableFrom(actualType) || Double.class.isAssignableFrom(actualType);
} else if (expectedType.equals("enum")) {
return Enum.class.isAssignableFrom(actualType);
} else if (expectedType.equals("map") || expectedType.equals("dict") || expectedType.equals("dictionary")) {
return Map.class.isAssignableFrom(actualType);
} else if (expectedType.equals("array") || expectedType.equals("list")) {
return actualType.isArray() || List.class.isAssignableFrom(actualType);
} else if (expectedType.endsWith("[]")) {
// Todo: Check subtype
return actualType.isArray() || List.class.isAssignableFrom(actualType);
} else
return false;
}
|
[
"public",
"static",
"boolean",
"matchTypeByName",
"(",
"String",
"expectedType",
",",
"Class",
"<",
"?",
">",
"actualType",
")",
"{",
"if",
"(",
"expectedType",
"==",
"null",
")",
"return",
"true",
";",
"if",
"(",
"actualType",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Actual type cannot be null\"",
")",
";",
"expectedType",
"=",
"expectedType",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"actualType",
".",
"getName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"expectedType",
")",
")",
"return",
"true",
";",
"else",
"if",
"(",
"actualType",
".",
"getSimpleName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"expectedType",
")",
")",
"return",
"true",
";",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"object\"",
")",
")",
"return",
"true",
";",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"int\"",
")",
"||",
"expectedType",
".",
"equals",
"(",
"\"integer\"",
")",
")",
"{",
"return",
"Integer",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
"||",
"Long",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"long\"",
")",
")",
"{",
"return",
"Long",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"float\"",
")",
")",
"{",
"return",
"Float",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
"||",
"Double",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"double\"",
")",
")",
"{",
"return",
"Double",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"string\"",
")",
")",
"{",
"return",
"String",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"bool\"",
")",
"||",
"expectedType",
".",
"equals",
"(",
"\"boolean\"",
")",
")",
"{",
"return",
"Boolean",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"date\"",
")",
"||",
"expectedType",
".",
"equals",
"(",
"\"datetime\"",
")",
")",
"{",
"return",
"Date",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
"||",
"Calendar",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
"||",
"ZonedDateTime",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"timespan\"",
")",
"||",
"expectedType",
".",
"equals",
"(",
"\"duration\"",
")",
")",
"{",
"return",
"Integer",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
"||",
"Long",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
"||",
"Float",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
"||",
"Double",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"enum\"",
")",
")",
"{",
"return",
"Enum",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"map\"",
")",
"||",
"expectedType",
".",
"equals",
"(",
"\"dict\"",
")",
"||",
"expectedType",
".",
"equals",
"(",
"\"dictionary\"",
")",
")",
"{",
"return",
"Map",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"equals",
"(",
"\"array\"",
")",
"||",
"expectedType",
".",
"equals",
"(",
"\"list\"",
")",
")",
"{",
"return",
"actualType",
".",
"isArray",
"(",
")",
"||",
"List",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"if",
"(",
"expectedType",
".",
"endsWith",
"(",
"\"[]\"",
")",
")",
"{",
"// Todo: Check subtype",
"return",
"actualType",
".",
"isArray",
"(",
")",
"||",
"List",
".",
"class",
".",
"isAssignableFrom",
"(",
"actualType",
")",
";",
"}",
"else",
"return",
"false",
";",
"}"
] |
Matches expected type to an actual type.
@param expectedType an expected type name to match.
@param actualType an actual type to match defined by type code.
@return true if types are matching and false if they don't.
|
[
"Matches",
"expected",
"type",
"to",
"an",
"actual",
"type",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/TypeMatcher.java#L90-L133
|
155,630
|
Brightify/torch-old
|
torch-core/src/main/java/org/brightify/torch/TorchService.java
|
TorchService.with
|
public static TorchFactory with(DatabaseEngine engine) {
Validate.isNull(factoryInstance, "Call TorchService#forceUnload if you want to reload TorchFactory!");
factoryInstance = new TorchFactoryImpl(engine);
return factoryInstance;
}
|
java
|
public static TorchFactory with(DatabaseEngine engine) {
Validate.isNull(factoryInstance, "Call TorchService#forceUnload if you want to reload TorchFactory!");
factoryInstance = new TorchFactoryImpl(engine);
return factoryInstance;
}
|
[
"public",
"static",
"TorchFactory",
"with",
"(",
"DatabaseEngine",
"engine",
")",
"{",
"Validate",
".",
"isNull",
"(",
"factoryInstance",
",",
"\"Call TorchService#forceUnload if you want to reload TorchFactory!\"",
")",
";",
"factoryInstance",
"=",
"new",
"TorchFactoryImpl",
"(",
"engine",
")",
";",
"return",
"factoryInstance",
";",
"}"
] |
Loads the TorchFactory with passed context. In order to get all async callbacks delivered on UI Thread, you have
to call this on UI Thread
@param engine A database engine to be used in the factory.
@return EntityRegistrar for {@link org.brightify.torch.annotation.Entity} registration
|
[
"Loads",
"the",
"TorchFactory",
"with",
"passed",
"context",
".",
"In",
"order",
"to",
"get",
"all",
"async",
"callbacks",
"delivered",
"on",
"UI",
"Thread",
"you",
"have",
"to",
"call",
"this",
"on",
"UI",
"Thread"
] |
c7772f7e09726d0e172bff144d67f545884a2995
|
https://github.com/Brightify/torch-old/blob/c7772f7e09726d0e172bff144d67f545884a2995/torch-core/src/main/java/org/brightify/torch/TorchService.java#L56-L62
|
155,631
|
Brightify/torch-old
|
torch-core/src/main/java/org/brightify/torch/TorchService.java
|
TorchService.forceUnload
|
public static void forceUnload() {
if(factoryInstance != null) {
factoryInstance.unload();
}
STACK.get().clear();
factoryInstance = null;
}
|
java
|
public static void forceUnload() {
if(factoryInstance != null) {
factoryInstance.unload();
}
STACK.get().clear();
factoryInstance = null;
}
|
[
"public",
"static",
"void",
"forceUnload",
"(",
")",
"{",
"if",
"(",
"factoryInstance",
"!=",
"null",
")",
"{",
"factoryInstance",
".",
"unload",
"(",
")",
";",
"}",
"STACK",
".",
"get",
"(",
")",
".",
"clear",
"(",
")",
";",
"factoryInstance",
"=",
"null",
";",
"}"
] |
Use this to force unload Torch. Probably used in tests only.
This will NOT delete the database. It will only unload the factory and unregister all the Entities.
|
[
"Use",
"this",
"to",
"force",
"unload",
"Torch",
".",
"Probably",
"used",
"in",
"tests",
"only",
"."
] |
c7772f7e09726d0e172bff144d67f545884a2995
|
https://github.com/Brightify/torch-old/blob/c7772f7e09726d0e172bff144d67f545884a2995/torch-core/src/main/java/org/brightify/torch/TorchService.java#L69-L77
|
155,632
|
Brightify/torch-old
|
torch-core/src/main/java/org/brightify/torch/TorchService.java
|
TorchService.torch
|
public static Torch torch() {
if (!isLoaded()) {
throw new IllegalStateException("Factory is not loaded!");
}
LinkedList<Torch> stack = STACK.get();
if (stack.isEmpty()) {
stack.add(factoryInstance.begin());
}
return stack.getLast();
}
|
java
|
public static Torch torch() {
if (!isLoaded()) {
throw new IllegalStateException("Factory is not loaded!");
}
LinkedList<Torch> stack = STACK.get();
if (stack.isEmpty()) {
stack.add(factoryInstance.begin());
}
return stack.getLast();
}
|
[
"public",
"static",
"Torch",
"torch",
"(",
")",
"{",
"if",
"(",
"!",
"isLoaded",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Factory is not loaded!\"",
")",
";",
"}",
"LinkedList",
"<",
"Torch",
">",
"stack",
"=",
"STACK",
".",
"get",
"(",
")",
";",
"if",
"(",
"stack",
".",
"isEmpty",
"(",
")",
")",
"{",
"stack",
".",
"add",
"(",
"factoryInstance",
".",
"begin",
"(",
")",
")",
";",
"}",
"return",
"stack",
".",
"getLast",
"(",
")",
";",
"}"
] |
This is the main method that will initialize the Torch.
We recommend to static import this method, so that you can only call torch() to begin.
@return An instance of {@link Torch}.
|
[
"This",
"is",
"the",
"main",
"method",
"that",
"will",
"initialize",
"the",
"Torch",
"."
] |
c7772f7e09726d0e172bff144d67f545884a2995
|
https://github.com/Brightify/torch-old/blob/c7772f7e09726d0e172bff144d67f545884a2995/torch-core/src/main/java/org/brightify/torch/TorchService.java#L86-L97
|
155,633
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/BooleanConverter.java
|
BooleanConverter.toNullableBoolean
|
public static Boolean toNullableBoolean(Object value) {
if (value == null)
return null;
if (value instanceof Boolean)
return (boolean) value;
if (value instanceof Duration)
return ((Duration) value).toMillis() > 0;
String strValue = value.toString().toLowerCase();
if (strValue.equals("1") || strValue.equals("true") || strValue.equals("t") || strValue.equals("yes")
|| strValue.equals("y"))
return true;
if (strValue.equals("0") || strValue.equals("false") || strValue.equals("f") || strValue.equals("no")
|| strValue.equals("n"))
return false;
return null;
}
|
java
|
public static Boolean toNullableBoolean(Object value) {
if (value == null)
return null;
if (value instanceof Boolean)
return (boolean) value;
if (value instanceof Duration)
return ((Duration) value).toMillis() > 0;
String strValue = value.toString().toLowerCase();
if (strValue.equals("1") || strValue.equals("true") || strValue.equals("t") || strValue.equals("yes")
|| strValue.equals("y"))
return true;
if (strValue.equals("0") || strValue.equals("false") || strValue.equals("f") || strValue.equals("no")
|| strValue.equals("n"))
return false;
return null;
}
|
[
"public",
"static",
"Boolean",
"toNullableBoolean",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"value",
"instanceof",
"Boolean",
")",
"return",
"(",
"boolean",
")",
"value",
";",
"if",
"(",
"value",
"instanceof",
"Duration",
")",
"return",
"(",
"(",
"Duration",
")",
"value",
")",
".",
"toMillis",
"(",
")",
">",
"0",
";",
"String",
"strValue",
"=",
"value",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"strValue",
".",
"equals",
"(",
"\"1\"",
")",
"||",
"strValue",
".",
"equals",
"(",
"\"true\"",
")",
"||",
"strValue",
".",
"equals",
"(",
"\"t\"",
")",
"||",
"strValue",
".",
"equals",
"(",
"\"yes\"",
")",
"||",
"strValue",
".",
"equals",
"(",
"\"y\"",
")",
")",
"return",
"true",
";",
"if",
"(",
"strValue",
".",
"equals",
"(",
"\"0\"",
")",
"||",
"strValue",
".",
"equals",
"(",
"\"false\"",
")",
"||",
"strValue",
".",
"equals",
"(",
"\"f\"",
")",
"||",
"strValue",
".",
"equals",
"(",
"\"no\"",
")",
"||",
"strValue",
".",
"equals",
"(",
"\"n\"",
")",
")",
"return",
"false",
";",
"return",
"null",
";",
"}"
] |
Converts value into boolean or returns null when conversion is not possible.
@param value the value to convert.
@return boolean value or null when conversion is not supported.
|
[
"Converts",
"value",
"into",
"boolean",
"or",
"returns",
"null",
"when",
"conversion",
"is",
"not",
"possible",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/BooleanConverter.java#L32-L50
|
155,634
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/BooleanConverter.java
|
BooleanConverter.toBooleanWithDefault
|
public static boolean toBooleanWithDefault(Object value, boolean defaultValue) {
Boolean result = toNullableBoolean(value);
return result != null ? (boolean) result : defaultValue;
}
|
java
|
public static boolean toBooleanWithDefault(Object value, boolean defaultValue) {
Boolean result = toNullableBoolean(value);
return result != null ? (boolean) result : defaultValue;
}
|
[
"public",
"static",
"boolean",
"toBooleanWithDefault",
"(",
"Object",
"value",
",",
"boolean",
"defaultValue",
")",
"{",
"Boolean",
"result",
"=",
"toNullableBoolean",
"(",
"value",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"(",
"boolean",
")",
"result",
":",
"defaultValue",
";",
"}"
] |
Converts value into boolean or returns default value when conversion is not
possible
@param value the value to convert.
@param defaultValue the default value
@return boolean value or default when conversion is not supported.
@see BooleanConverter#toNullableBoolean(Object)
|
[
"Converts",
"value",
"into",
"boolean",
"or",
"returns",
"default",
"value",
"when",
"conversion",
"is",
"not",
"possible"
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/BooleanConverter.java#L74-L77
|
155,635
|
morimekta/utils
|
config-util/src/main/java/net/morimekta/config/impl/ImmutableConfig.java
|
ImmutableConfig.copyOf
|
public static ImmutableConfig copyOf(Config config) {
if (config instanceof ImmutableConfig) {
return (ImmutableConfig) config;
} else {
return new ImmutableConfig(config);
}
}
|
java
|
public static ImmutableConfig copyOf(Config config) {
if (config instanceof ImmutableConfig) {
return (ImmutableConfig) config;
} else {
return new ImmutableConfig(config);
}
}
|
[
"public",
"static",
"ImmutableConfig",
"copyOf",
"(",
"Config",
"config",
")",
"{",
"if",
"(",
"config",
"instanceof",
"ImmutableConfig",
")",
"{",
"return",
"(",
"ImmutableConfig",
")",
"config",
";",
"}",
"else",
"{",
"return",
"new",
"ImmutableConfig",
"(",
"config",
")",
";",
"}",
"}"
] |
Create an immutable config instance.
@param config The base config (or super-config).
@return The immutable config.
|
[
"Create",
"an",
"immutable",
"config",
"instance",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/impl/ImmutableConfig.java#L41-L47
|
155,636
|
foundation-runtime/service-directory
|
1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/registration/HeartbeatDirectoryRegistrationService.java
|
HeartbeatDirectoryRegistrationService.getCachedServiceInstance
|
private CachedProviderServiceInstance getCachedServiceInstance(
String serviceName, String providerAddress) {
ServiceInstanceId id = new ServiceInstanceId(serviceName, providerAddress);
return getCacheServiceInstances().get(id);
}
|
java
|
private CachedProviderServiceInstance getCachedServiceInstance(
String serviceName, String providerAddress) {
ServiceInstanceId id = new ServiceInstanceId(serviceName, providerAddress);
return getCacheServiceInstances().get(id);
}
|
[
"private",
"CachedProviderServiceInstance",
"getCachedServiceInstance",
"(",
"String",
"serviceName",
",",
"String",
"providerAddress",
")",
"{",
"ServiceInstanceId",
"id",
"=",
"new",
"ServiceInstanceId",
"(",
"serviceName",
",",
"providerAddress",
")",
";",
"return",
"getCacheServiceInstances",
"(",
")",
".",
"get",
"(",
"id",
")",
";",
"}"
] |
Get the Cached ProvidedServiceInstance by serviceName and providerAddress.
It is thread safe.
@param serviceName
the serviceName
@param providerAddress
the providerAddress
@return
the CachedProviderServiceInstance
|
[
"Get",
"the",
"Cached",
"ProvidedServiceInstance",
"by",
"serviceName",
"and",
"providerAddress",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/registration/HeartbeatDirectoryRegistrationService.java#L361-L367
|
155,637
|
foundation-runtime/service-directory
|
1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/registration/HeartbeatDirectoryRegistrationService.java
|
HeartbeatDirectoryRegistrationService.scheduleTasks
|
private void scheduleTasks() {
int rhDelay = getServiceDirectoryConfig().getInt(
SD_API_REGISTRY_HEALTH_CHECK_DELAY_PROPERTY,
SD_API_REGISTRY_HEALTH_CHECK_DELAY_DEFAULT);
int rhInterval = getServiceDirectoryConfig().getInt(
SD_API_REGISTRY_HEALTH_CHECK_INTERVAL_PROPERTY,
SD_API_REGISTRY_HEALTH_CHECK_INTERVAL_DEFAULT);
LOGGER.info(
"Start the SD API RegistryHealth Task scheduler, delay={}, interval={}.",
rhDelay, rhInterval);
healthCheckService.get().scheduleAtFixedRate(new HealthCheckTask(), rhDelay,
rhInterval, TimeUnit.SECONDS);
int hbDelay = getServiceDirectoryConfig().getInt(SD_API_HEARTBEAT_DELAY_PROPERTY,
SD_API_HEARTBEAT_DELAY_DEFAULT);
int hbInterval = getServiceDirectoryConfig().getInt(
SD_API_HEARTBEAT_INTERVAL_PROPERTY,
SD_API_HEARTBEAT_INTERVAL_DEFAULT);
LOGGER.info(
"Start the SD API Heartbeat Task scheduler, delay={}, interval={}.",
hbDelay, hbInterval);
heartbeatService.get().scheduleAtFixedRate(new HeartbeatTask(), hbDelay,
hbInterval, TimeUnit.SECONDS);
}
|
java
|
private void scheduleTasks() {
int rhDelay = getServiceDirectoryConfig().getInt(
SD_API_REGISTRY_HEALTH_CHECK_DELAY_PROPERTY,
SD_API_REGISTRY_HEALTH_CHECK_DELAY_DEFAULT);
int rhInterval = getServiceDirectoryConfig().getInt(
SD_API_REGISTRY_HEALTH_CHECK_INTERVAL_PROPERTY,
SD_API_REGISTRY_HEALTH_CHECK_INTERVAL_DEFAULT);
LOGGER.info(
"Start the SD API RegistryHealth Task scheduler, delay={}, interval={}.",
rhDelay, rhInterval);
healthCheckService.get().scheduleAtFixedRate(new HealthCheckTask(), rhDelay,
rhInterval, TimeUnit.SECONDS);
int hbDelay = getServiceDirectoryConfig().getInt(SD_API_HEARTBEAT_DELAY_PROPERTY,
SD_API_HEARTBEAT_DELAY_DEFAULT);
int hbInterval = getServiceDirectoryConfig().getInt(
SD_API_HEARTBEAT_INTERVAL_PROPERTY,
SD_API_HEARTBEAT_INTERVAL_DEFAULT);
LOGGER.info(
"Start the SD API Heartbeat Task scheduler, delay={}, interval={}.",
hbDelay, hbInterval);
heartbeatService.get().scheduleAtFixedRate(new HeartbeatTask(), hbDelay,
hbInterval, TimeUnit.SECONDS);
}
|
[
"private",
"void",
"scheduleTasks",
"(",
")",
"{",
"int",
"rhDelay",
"=",
"getServiceDirectoryConfig",
"(",
")",
".",
"getInt",
"(",
"SD_API_REGISTRY_HEALTH_CHECK_DELAY_PROPERTY",
",",
"SD_API_REGISTRY_HEALTH_CHECK_DELAY_DEFAULT",
")",
";",
"int",
"rhInterval",
"=",
"getServiceDirectoryConfig",
"(",
")",
".",
"getInt",
"(",
"SD_API_REGISTRY_HEALTH_CHECK_INTERVAL_PROPERTY",
",",
"SD_API_REGISTRY_HEALTH_CHECK_INTERVAL_DEFAULT",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"Start the SD API RegistryHealth Task scheduler, delay={}, interval={}.\"",
",",
"rhDelay",
",",
"rhInterval",
")",
";",
"healthCheckService",
".",
"get",
"(",
")",
".",
"scheduleAtFixedRate",
"(",
"new",
"HealthCheckTask",
"(",
")",
",",
"rhDelay",
",",
"rhInterval",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"int",
"hbDelay",
"=",
"getServiceDirectoryConfig",
"(",
")",
".",
"getInt",
"(",
"SD_API_HEARTBEAT_DELAY_PROPERTY",
",",
"SD_API_HEARTBEAT_DELAY_DEFAULT",
")",
";",
"int",
"hbInterval",
"=",
"getServiceDirectoryConfig",
"(",
")",
".",
"getInt",
"(",
"SD_API_HEARTBEAT_INTERVAL_PROPERTY",
",",
"SD_API_HEARTBEAT_INTERVAL_DEFAULT",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"Start the SD API Heartbeat Task scheduler, delay={}, interval={}.\"",
",",
"hbDelay",
",",
"hbInterval",
")",
";",
"heartbeatService",
".",
"get",
"(",
")",
".",
"scheduleAtFixedRate",
"(",
"new",
"HeartbeatTask",
"(",
")",
",",
"hbDelay",
",",
"hbInterval",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}"
] |
schedule the Heartbeat task and Health Check task.
|
[
"schedule",
"the",
"Heartbeat",
"task",
"and",
"Health",
"Check",
"task",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/registration/HeartbeatDirectoryRegistrationService.java#L408-L432
|
155,638
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/reflect/PropertyReflector.java
|
PropertyReflector.hasProperty
|
public static boolean hasProperty(Object obj, String name) {
if (obj == null)
throw new NullPointerException("Object cannot be null");
if (name == null)
throw new NullPointerException("Property name cannot be null");
Class<?> objClass = obj.getClass();
// Search in fields
for (Field field : objClass.getFields()) {
if (matchField(field, name))
return true;
}
// Search in properties
name = "get" + name;
for (Method method : objClass.getMethods()) {
if (matchPropertyGetter(method, name))
return true;
}
return false;
}
|
java
|
public static boolean hasProperty(Object obj, String name) {
if (obj == null)
throw new NullPointerException("Object cannot be null");
if (name == null)
throw new NullPointerException("Property name cannot be null");
Class<?> objClass = obj.getClass();
// Search in fields
for (Field field : objClass.getFields()) {
if (matchField(field, name))
return true;
}
// Search in properties
name = "get" + name;
for (Method method : objClass.getMethods()) {
if (matchPropertyGetter(method, name))
return true;
}
return false;
}
|
[
"public",
"static",
"boolean",
"hasProperty",
"(",
"Object",
"obj",
",",
"String",
"name",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Object cannot be null\"",
")",
";",
"if",
"(",
"name",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Property name cannot be null\"",
")",
";",
"Class",
"<",
"?",
">",
"objClass",
"=",
"obj",
".",
"getClass",
"(",
")",
";",
"// Search in fields",
"for",
"(",
"Field",
"field",
":",
"objClass",
".",
"getFields",
"(",
")",
")",
"{",
"if",
"(",
"matchField",
"(",
"field",
",",
"name",
")",
")",
"return",
"true",
";",
"}",
"// Search in properties",
"name",
"=",
"\"get\"",
"+",
"name",
";",
"for",
"(",
"Method",
"method",
":",
"objClass",
".",
"getMethods",
"(",
")",
")",
"{",
"if",
"(",
"matchPropertyGetter",
"(",
"method",
",",
"name",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if object has a property with specified name..
@param obj an object to introspect.
@param name a name of the property to check.
@return true if the object has the property and false if it doesn't.
|
[
"Checks",
"if",
"object",
"has",
"a",
"property",
"with",
"specified",
"name",
".."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/PropertyReflector.java#L58-L80
|
155,639
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/reflect/PropertyReflector.java
|
PropertyReflector.getProperty
|
public static Object getProperty(Object obj, String name) {
if (obj == null)
throw new NullPointerException("Object cannot be null");
if (name == null)
throw new NullPointerException("Property name cannot be null");
Class<?> objClass = obj.getClass();
// Search in fields
for (Field field : objClass.getFields()) {
try {
if (matchField(field, name))
return field.get(obj);
} catch (Throwable t) {
// Ignore exceptions
}
}
// Search in properties
name = "get" + name;
for (Method method : objClass.getMethods()) {
try {
if (matchPropertyGetter(method, name))
return method.invoke(obj);
} catch (Throwable t) {
// Ignore exceptions
}
}
return null;
}
|
java
|
public static Object getProperty(Object obj, String name) {
if (obj == null)
throw new NullPointerException("Object cannot be null");
if (name == null)
throw new NullPointerException("Property name cannot be null");
Class<?> objClass = obj.getClass();
// Search in fields
for (Field field : objClass.getFields()) {
try {
if (matchField(field, name))
return field.get(obj);
} catch (Throwable t) {
// Ignore exceptions
}
}
// Search in properties
name = "get" + name;
for (Method method : objClass.getMethods()) {
try {
if (matchPropertyGetter(method, name))
return method.invoke(obj);
} catch (Throwable t) {
// Ignore exceptions
}
}
return null;
}
|
[
"public",
"static",
"Object",
"getProperty",
"(",
"Object",
"obj",
",",
"String",
"name",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Object cannot be null\"",
")",
";",
"if",
"(",
"name",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Property name cannot be null\"",
")",
";",
"Class",
"<",
"?",
">",
"objClass",
"=",
"obj",
".",
"getClass",
"(",
")",
";",
"// Search in fields",
"for",
"(",
"Field",
"field",
":",
"objClass",
".",
"getFields",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"matchField",
"(",
"field",
",",
"name",
")",
")",
"return",
"field",
".",
"get",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// Ignore exceptions",
"}",
"}",
"// Search in properties",
"name",
"=",
"\"get\"",
"+",
"name",
";",
"for",
"(",
"Method",
"method",
":",
"objClass",
".",
"getMethods",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"matchPropertyGetter",
"(",
"method",
",",
"name",
")",
")",
"return",
"method",
".",
"invoke",
"(",
"obj",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// Ignore exceptions",
"}",
"}",
"return",
"null",
";",
"}"
] |
Gets value of object property specified by its name.
@param obj an object to read property from.
@param name a name of the property to get.
@return the property value or null if property doesn't exist or introspection
failed.
|
[
"Gets",
"value",
"of",
"object",
"property",
"specified",
"by",
"its",
"name",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/PropertyReflector.java#L90-L120
|
155,640
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/reflect/PropertyReflector.java
|
PropertyReflector.getProperties
|
public static Map<String, Object> getProperties(Object obj) {
Map<String, Object> map = new HashMap<String, Object>();
Class<?> objClass = obj.getClass();
// Get all fields
for (Field field : objClass.getFields()) {
try {
if (matchField(field, field.getName())) {
String name = field.getName();
Object value = field.get(obj);
map.put(name, value);
}
} catch (Throwable t) {
// Ignore exception
}
}
// Get all properties
for (Method method : objClass.getMethods()) {
try {
if (method.getName().startsWith("get") && matchPropertyGetter(method, method.getName())) {
String name = method.getName().substring(3);
name = name.substring(0, 1).toLowerCase() + name.substring(1);
Object value = method.invoke(obj);
map.put(name, value);
}
} catch (Throwable t) {
// Ignore exception
}
}
return map;
}
|
java
|
public static Map<String, Object> getProperties(Object obj) {
Map<String, Object> map = new HashMap<String, Object>();
Class<?> objClass = obj.getClass();
// Get all fields
for (Field field : objClass.getFields()) {
try {
if (matchField(field, field.getName())) {
String name = field.getName();
Object value = field.get(obj);
map.put(name, value);
}
} catch (Throwable t) {
// Ignore exception
}
}
// Get all properties
for (Method method : objClass.getMethods()) {
try {
if (method.getName().startsWith("get") && matchPropertyGetter(method, method.getName())) {
String name = method.getName().substring(3);
name = name.substring(0, 1).toLowerCase() + name.substring(1);
Object value = method.invoke(obj);
map.put(name, value);
}
} catch (Throwable t) {
// Ignore exception
}
}
return map;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"getProperties",
"(",
"Object",
"obj",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"Class",
"<",
"?",
">",
"objClass",
"=",
"obj",
".",
"getClass",
"(",
")",
";",
"// Get all fields",
"for",
"(",
"Field",
"field",
":",
"objClass",
".",
"getFields",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"matchField",
"(",
"field",
",",
"field",
".",
"getName",
"(",
")",
")",
")",
"{",
"String",
"name",
"=",
"field",
".",
"getName",
"(",
")",
";",
"Object",
"value",
"=",
"field",
".",
"get",
"(",
"obj",
")",
";",
"map",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// Ignore exception",
"}",
"}",
"// Get all properties",
"for",
"(",
"Method",
"method",
":",
"objClass",
".",
"getMethods",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"method",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"\"get\"",
")",
"&&",
"matchPropertyGetter",
"(",
"method",
",",
"method",
".",
"getName",
"(",
")",
")",
")",
"{",
"String",
"name",
"=",
"method",
".",
"getName",
"(",
")",
".",
"substring",
"(",
"3",
")",
";",
"name",
"=",
"name",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toLowerCase",
"(",
")",
"+",
"name",
".",
"substring",
"(",
"1",
")",
";",
"Object",
"value",
"=",
"method",
".",
"invoke",
"(",
"obj",
")",
";",
"map",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// Ignore exception",
"}",
"}",
"return",
"map",
";",
"}"
] |
Get values of all properties in specified object and returns them as a map.
@param obj an object to get properties from.
@return a map, containing the names of the object's properties and their
values.
|
[
"Get",
"values",
"of",
"all",
"properties",
"in",
"specified",
"object",
"and",
"returns",
"them",
"as",
"a",
"map",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/PropertyReflector.java#L158-L191
|
155,641
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMOptional.java
|
JMOptional.getOptionalIfTrue
|
public static <T> Optional<T> getOptionalIfTrue(boolean bool, T target) {
return bool ? Optional.ofNullable(target) : Optional.empty();
}
|
java
|
public static <T> Optional<T> getOptionalIfTrue(boolean bool, T target) {
return bool ? Optional.ofNullable(target) : Optional.empty();
}
|
[
"public",
"static",
"<",
"T",
">",
"Optional",
"<",
"T",
">",
"getOptionalIfTrue",
"(",
"boolean",
"bool",
",",
"T",
"target",
")",
"{",
"return",
"bool",
"?",
"Optional",
".",
"ofNullable",
"(",
"target",
")",
":",
"Optional",
".",
"empty",
"(",
")",
";",
"}"
] |
Gets optional if true.
@param <T> the type parameter
@param bool the bool
@param target the target
@return the optional if true
|
[
"Gets",
"optional",
"if",
"true",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L34-L36
|
155,642
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMOptional.java
|
JMOptional.getNullableAndFilteredOptional
|
public static <T> Optional<T> getNullableAndFilteredOptional(T target,
Predicate<T> predicate) {
return Optional.ofNullable(target).filter(predicate);
}
|
java
|
public static <T> Optional<T> getNullableAndFilteredOptional(T target,
Predicate<T> predicate) {
return Optional.ofNullable(target).filter(predicate);
}
|
[
"public",
"static",
"<",
"T",
">",
"Optional",
"<",
"T",
">",
"getNullableAndFilteredOptional",
"(",
"T",
"target",
",",
"Predicate",
"<",
"T",
">",
"predicate",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"target",
")",
".",
"filter",
"(",
"predicate",
")",
";",
"}"
] |
Gets nullable and filtered optional.
@param <T> the type parameter
@param target the target
@param predicate the predicate
@return the nullable and filtered optional
|
[
"Gets",
"nullable",
"and",
"filtered",
"optional",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L46-L49
|
155,643
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMOptional.java
|
JMOptional.getValueAsOptIfExist
|
public static <K, V, R> Optional<R> getValueAsOptIfExist(Map<K, V> map,
K key, Function<V, R> returnBuilderFunction) {
return getOptional(map, key).map(returnBuilderFunction::apply);
}
|
java
|
public static <K, V, R> Optional<R> getValueAsOptIfExist(Map<K, V> map,
K key, Function<V, R> returnBuilderFunction) {
return getOptional(map, key).map(returnBuilderFunction::apply);
}
|
[
"public",
"static",
"<",
"K",
",",
"V",
",",
"R",
">",
"Optional",
"<",
"R",
">",
"getValueAsOptIfExist",
"(",
"Map",
"<",
"K",
",",
"V",
">",
"map",
",",
"K",
"key",
",",
"Function",
"<",
"V",
",",
"R",
">",
"returnBuilderFunction",
")",
"{",
"return",
"getOptional",
"(",
"map",
",",
"key",
")",
".",
"map",
"(",
"returnBuilderFunction",
"::",
"apply",
")",
";",
"}"
] |
Gets value as opt if exist.
@param <K> the type parameter
@param <V> the type parameter
@param <R> the type parameter
@param map the map
@param key the key
@param returnBuilderFunction the return builder function
@return the value as opt if exist
|
[
"Gets",
"value",
"as",
"opt",
"if",
"exist",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L126-L129
|
155,644
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMOptional.java
|
JMOptional.ifNotNull
|
public static <T> void ifNotNull(T object, Consumer<T> consumer) {
Optional.ofNullable(object).ifPresent(consumer);
}
|
java
|
public static <T> void ifNotNull(T object, Consumer<T> consumer) {
Optional.ofNullable(object).ifPresent(consumer);
}
|
[
"public",
"static",
"<",
"T",
">",
"void",
"ifNotNull",
"(",
"T",
"object",
",",
"Consumer",
"<",
"T",
">",
"consumer",
")",
"{",
"Optional",
".",
"ofNullable",
"(",
"object",
")",
".",
"ifPresent",
"(",
"consumer",
")",
";",
"}"
] |
If not null.
@param <T> the type parameter
@param object the object
@param consumer the consumer
|
[
"If",
"not",
"null",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L217-L219
|
155,645
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMOptional.java
|
JMOptional.orElseGetIfNull
|
public static <T> T orElseGetIfNull(T target, Supplier<T> elseGetSupplier) {
return Optional.ofNullable(target).orElseGet(elseGetSupplier);
}
|
java
|
public static <T> T orElseGetIfNull(T target, Supplier<T> elseGetSupplier) {
return Optional.ofNullable(target).orElseGet(elseGetSupplier);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"orElseGetIfNull",
"(",
"T",
"target",
",",
"Supplier",
"<",
"T",
">",
"elseGetSupplier",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"target",
")",
".",
"orElseGet",
"(",
"elseGetSupplier",
")",
";",
"}"
] |
Or else get if null t.
@param <T> the type parameter
@param target the target
@param elseGetSupplier the else get supplier
@return the t
|
[
"Or",
"else",
"get",
"if",
"null",
"t",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L229-L231
|
155,646
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMOptional.java
|
JMOptional.orElseIfNull
|
public static <T> T orElseIfNull(T target, T elseTarget) {
return Optional.ofNullable(target).orElse(elseTarget);
}
|
java
|
public static <T> T orElseIfNull(T target, T elseTarget) {
return Optional.ofNullable(target).orElse(elseTarget);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"orElseIfNull",
"(",
"T",
"target",
",",
"T",
"elseTarget",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"target",
")",
".",
"orElse",
"(",
"elseTarget",
")",
";",
"}"
] |
Or else if null t.
@param <T> the type parameter
@param target the target
@param elseTarget the else target
@return the t
|
[
"Or",
"else",
"if",
"null",
"t",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L241-L243
|
155,647
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMOptional.java
|
JMOptional.ifExistIntoStream
|
public static <T, C extends Collection<T>> Stream<T>
ifExistIntoStream(C collection) {
return getOptional(collection).map(Collection::stream)
.orElseGet(Stream::empty);
}
|
java
|
public static <T, C extends Collection<T>> Stream<T>
ifExistIntoStream(C collection) {
return getOptional(collection).map(Collection::stream)
.orElseGet(Stream::empty);
}
|
[
"public",
"static",
"<",
"T",
",",
"C",
"extends",
"Collection",
"<",
"T",
">",
">",
"Stream",
"<",
"T",
">",
"ifExistIntoStream",
"(",
"C",
"collection",
")",
"{",
"return",
"getOptional",
"(",
"collection",
")",
".",
"map",
"(",
"Collection",
"::",
"stream",
")",
".",
"orElseGet",
"(",
"Stream",
"::",
"empty",
")",
";",
"}"
] |
If exist into stream stream.
@param <T> the type parameter
@param <C> the type parameter
@param collection the collection
@return the stream
|
[
"If",
"exist",
"into",
"stream",
"stream",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L253-L257
|
155,648
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMOptional.java
|
JMOptional.isPresentAll
|
public static boolean isPresentAll(Optional<?>... optionals) {
for (Optional<?> optional : optionals)
if (!optional.isPresent())
return false;
return true;
}
|
java
|
public static boolean isPresentAll(Optional<?>... optionals) {
for (Optional<?> optional : optionals)
if (!optional.isPresent())
return false;
return true;
}
|
[
"public",
"static",
"boolean",
"isPresentAll",
"(",
"Optional",
"<",
"?",
">",
"...",
"optionals",
")",
"{",
"for",
"(",
"Optional",
"<",
"?",
">",
"optional",
":",
"optionals",
")",
"if",
"(",
"!",
"optional",
".",
"isPresent",
"(",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] |
Is present all boolean.
@param optionals the optionals
@return the boolean
|
[
"Is",
"present",
"all",
"boolean",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L265-L270
|
155,649
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMOptional.java
|
JMOptional.getListIfIsPresent
|
public static <T> List<T> getListIfIsPresent(Optional<T>... optionals) {
return Arrays.stream(optionals).filter(Optional::isPresent)
.map(Optional::get).collect(Collectors.toList());
}
|
java
|
public static <T> List<T> getListIfIsPresent(Optional<T>... optionals) {
return Arrays.stream(optionals).filter(Optional::isPresent)
.map(Optional::get).collect(Collectors.toList());
}
|
[
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getListIfIsPresent",
"(",
"Optional",
"<",
"T",
">",
"...",
"optionals",
")",
"{",
"return",
"Arrays",
".",
"stream",
"(",
"optionals",
")",
".",
"filter",
"(",
"Optional",
"::",
"isPresent",
")",
".",
"map",
"(",
"Optional",
"::",
"get",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] |
Gets list if is present.
@param <T> the type parameter
@param optionals the optionals
@return the list if is present
|
[
"Gets",
"list",
"if",
"is",
"present",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L279-L282
|
155,650
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMOptional.java
|
JMOptional.getOrNullList
|
public static <T> List<T> getOrNullList(Optional<T>... optionals) {
return Arrays.stream(optionals).map(opt -> opt.orElse(null))
.collect(Collectors.toList());
}
|
java
|
public static <T> List<T> getOrNullList(Optional<T>... optionals) {
return Arrays.stream(optionals).map(opt -> opt.orElse(null))
.collect(Collectors.toList());
}
|
[
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getOrNullList",
"(",
"Optional",
"<",
"T",
">",
"...",
"optionals",
")",
"{",
"return",
"Arrays",
".",
"stream",
"(",
"optionals",
")",
".",
"map",
"(",
"opt",
"->",
"opt",
".",
"orElse",
"(",
"null",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] |
Gets or null list.
@param <T> the type parameter
@param optionals the optionals
@return the or null list
|
[
"Gets",
"or",
"null",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMOptional.java#L291-L294
|
155,651
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/db/ColumnMetaData.java
|
ColumnMetaData.createMapByLabelOrName
|
static public Map<String, ColumnMetaData> createMapByLabelOrName(ResultSetMetaData m) throws SQLException{
Map<String, ColumnMetaData> result = new HashMap<String, ColumnMetaData>();
for (int i = 1; i <= m.getColumnCount(); i ++){
ColumnMetaData cm = new ColumnMetaData(m, i);
result.put(cm.getLabelOrName(), cm);
}
return result;
}
|
java
|
static public Map<String, ColumnMetaData> createMapByLabelOrName(ResultSetMetaData m) throws SQLException{
Map<String, ColumnMetaData> result = new HashMap<String, ColumnMetaData>();
for (int i = 1; i <= m.getColumnCount(); i ++){
ColumnMetaData cm = new ColumnMetaData(m, i);
result.put(cm.getLabelOrName(), cm);
}
return result;
}
|
[
"static",
"public",
"Map",
"<",
"String",
",",
"ColumnMetaData",
">",
"createMapByLabelOrName",
"(",
"ResultSetMetaData",
"m",
")",
"throws",
"SQLException",
"{",
"Map",
"<",
"String",
",",
"ColumnMetaData",
">",
"result",
"=",
"new",
"HashMap",
"<",
"String",
",",
"ColumnMetaData",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"m",
".",
"getColumnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"ColumnMetaData",
"cm",
"=",
"new",
"ColumnMetaData",
"(",
"m",
",",
"i",
")",
";",
"result",
".",
"put",
"(",
"cm",
".",
"getLabelOrName",
"(",
")",
",",
"cm",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Get all the column meta data and put them into a map keyed by column label or name
@param m the result set meta data
@return the map of column label/name and column meta data
@throws SQLException
|
[
"Get",
"all",
"the",
"column",
"meta",
"data",
"and",
"put",
"them",
"into",
"a",
"map",
"keyed",
"by",
"column",
"label",
"or",
"name"
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/db/ColumnMetaData.java#L85-L92
|
155,652
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/db/ColumnMetaData.java
|
ColumnMetaData.createList
|
static public List<ColumnMetaData> createList(ResultSetMetaData m) throws SQLException{
List<ColumnMetaData> result = new ArrayList<ColumnMetaData>(m.getColumnCount());
for (int i = 1; i <= m.getColumnCount(); i ++){
ColumnMetaData cm = new ColumnMetaData(m, i);
result.add(cm);
}
return result;
}
|
java
|
static public List<ColumnMetaData> createList(ResultSetMetaData m) throws SQLException{
List<ColumnMetaData> result = new ArrayList<ColumnMetaData>(m.getColumnCount());
for (int i = 1; i <= m.getColumnCount(); i ++){
ColumnMetaData cm = new ColumnMetaData(m, i);
result.add(cm);
}
return result;
}
|
[
"static",
"public",
"List",
"<",
"ColumnMetaData",
">",
"createList",
"(",
"ResultSetMetaData",
"m",
")",
"throws",
"SQLException",
"{",
"List",
"<",
"ColumnMetaData",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"ColumnMetaData",
">",
"(",
"m",
".",
"getColumnCount",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"m",
".",
"getColumnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"ColumnMetaData",
"cm",
"=",
"new",
"ColumnMetaData",
"(",
"m",
",",
"i",
")",
";",
"result",
".",
"add",
"(",
"cm",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Get all the column meta data and put them into a list in their default order
@param m the result set meta data
@return a list of column meta data
@throws SQLException
|
[
"Get",
"all",
"the",
"column",
"meta",
"data",
"and",
"put",
"them",
"into",
"a",
"list",
"in",
"their",
"default",
"order"
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/db/ColumnMetaData.java#L100-L107
|
155,653
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/GroupAnalyzerByStyles.java
|
GroupAnalyzerByStyles.expandToLimit
|
private void expandToLimit(AreaImpl sub, Rectangular gp, Rectangular limit, AreaImpl template,
boolean hsep, boolean vsep,
short prefDir, short required)
{
//System.out.println();
System.out.println(" Expand " + sub + " DIR=" + prefDir + " sep=" + hsep + ":" + vsep);
//debugColor = new java.awt.Color(debugColor.getBlue(), debugColor.getRed(), debugColor.getGreen());*/
//hsep = true;
//vsep = true;
if (getTopology().getTopologyWidth() > 0 && getTopology().getTopologyHeight() > 0 && !sub.isBackgroundSeparated())
{
int dir = prefDir;
int attempts = 0;
while (attempts < 4 && !limitReached(gp, limit, required))
{
boolean change = false;
int newx, newy;
//System.out.println(dir + " - " +gp);
switch (dir)
{
case DIR_DOWN:
//expand down
if (gp.getY2() < limit.getY2() &&
(!hsep || !separatorDown(sub.getGridPosition().replaceY(gp)))) //look for the separator under the current expanded bounds
{
newy = expandVertically(gp, limit, template, true, hsep);
if (newy > gp.getY2())
{
gp.setY2(newy);
change = true;
}
}
break;
case DIR_RIGHT:
//expand right
if (gp.getX2() < limit.getX2() &&
(!vsep || !separatorRight(sub.getGridPosition().replaceX(gp))))
{
newx = expandHorizontally(gp, limit, template, true, vsep);
if (newx > gp.getX2())
{
gp.setX2(newx);
change = true;
}
}
break;
case DIR_UP:
//expand up
if (gp.getY1() > limit.getY1() &&
(!hsep || !separatorUp(sub.getGridPosition().replaceY(gp))))
{
newy = expandVertically(gp, limit, template, false, hsep);
if (newy < gp.getY1())
{
gp.setY1(newy);
change = true;
}
}
break;
case DIR_LEFT:
//expand left
if (gp.getX1() > limit.getX1() &&
(!vsep || !separatorLeft(sub.getGridPosition().replaceX(gp))))
{
newx = expandHorizontally(gp, limit, template, false, vsep);
if (newx < gp.getX1())
{
gp.setX1(newx);
change = true;
}
}
break;
}
if (!change) //not succeeded in this direction
{
dir++; //another direction
if (dir >= 4) dir = 0;
attempts++;
}
else //succeeded - keep the direction
{
attempts = 0;
}
/*if (Config.DEBUG_AREAS)
{
dispArea(gp);
wait(Config.DEBUG_DELAY);
}*/
}
}
}
|
java
|
private void expandToLimit(AreaImpl sub, Rectangular gp, Rectangular limit, AreaImpl template,
boolean hsep, boolean vsep,
short prefDir, short required)
{
//System.out.println();
System.out.println(" Expand " + sub + " DIR=" + prefDir + " sep=" + hsep + ":" + vsep);
//debugColor = new java.awt.Color(debugColor.getBlue(), debugColor.getRed(), debugColor.getGreen());*/
//hsep = true;
//vsep = true;
if (getTopology().getTopologyWidth() > 0 && getTopology().getTopologyHeight() > 0 && !sub.isBackgroundSeparated())
{
int dir = prefDir;
int attempts = 0;
while (attempts < 4 && !limitReached(gp, limit, required))
{
boolean change = false;
int newx, newy;
//System.out.println(dir + " - " +gp);
switch (dir)
{
case DIR_DOWN:
//expand down
if (gp.getY2() < limit.getY2() &&
(!hsep || !separatorDown(sub.getGridPosition().replaceY(gp)))) //look for the separator under the current expanded bounds
{
newy = expandVertically(gp, limit, template, true, hsep);
if (newy > gp.getY2())
{
gp.setY2(newy);
change = true;
}
}
break;
case DIR_RIGHT:
//expand right
if (gp.getX2() < limit.getX2() &&
(!vsep || !separatorRight(sub.getGridPosition().replaceX(gp))))
{
newx = expandHorizontally(gp, limit, template, true, vsep);
if (newx > gp.getX2())
{
gp.setX2(newx);
change = true;
}
}
break;
case DIR_UP:
//expand up
if (gp.getY1() > limit.getY1() &&
(!hsep || !separatorUp(sub.getGridPosition().replaceY(gp))))
{
newy = expandVertically(gp, limit, template, false, hsep);
if (newy < gp.getY1())
{
gp.setY1(newy);
change = true;
}
}
break;
case DIR_LEFT:
//expand left
if (gp.getX1() > limit.getX1() &&
(!vsep || !separatorLeft(sub.getGridPosition().replaceX(gp))))
{
newx = expandHorizontally(gp, limit, template, false, vsep);
if (newx < gp.getX1())
{
gp.setX1(newx);
change = true;
}
}
break;
}
if (!change) //not succeeded in this direction
{
dir++; //another direction
if (dir >= 4) dir = 0;
attempts++;
}
else //succeeded - keep the direction
{
attempts = 0;
}
/*if (Config.DEBUG_AREAS)
{
dispArea(gp);
wait(Config.DEBUG_DELAY);
}*/
}
}
}
|
[
"private",
"void",
"expandToLimit",
"(",
"AreaImpl",
"sub",
",",
"Rectangular",
"gp",
",",
"Rectangular",
"limit",
",",
"AreaImpl",
"template",
",",
"boolean",
"hsep",
",",
"boolean",
"vsep",
",",
"short",
"prefDir",
",",
"short",
"required",
")",
"{",
"//System.out.println();",
"System",
".",
"out",
".",
"println",
"(",
"\" Expand \"",
"+",
"sub",
"+",
"\" DIR=\"",
"+",
"prefDir",
"+",
"\" sep=\"",
"+",
"hsep",
"+",
"\":\"",
"+",
"vsep",
")",
";",
"//debugColor = new java.awt.Color(debugColor.getBlue(), debugColor.getRed(), debugColor.getGreen());*/",
"//hsep = true;",
"//vsep = true;",
"if",
"(",
"getTopology",
"(",
")",
".",
"getTopologyWidth",
"(",
")",
">",
"0",
"&&",
"getTopology",
"(",
")",
".",
"getTopologyHeight",
"(",
")",
">",
"0",
"&&",
"!",
"sub",
".",
"isBackgroundSeparated",
"(",
")",
")",
"{",
"int",
"dir",
"=",
"prefDir",
";",
"int",
"attempts",
"=",
"0",
";",
"while",
"(",
"attempts",
"<",
"4",
"&&",
"!",
"limitReached",
"(",
"gp",
",",
"limit",
",",
"required",
")",
")",
"{",
"boolean",
"change",
"=",
"false",
";",
"int",
"newx",
",",
"newy",
";",
"//System.out.println(dir + \" - \" +gp);",
"switch",
"(",
"dir",
")",
"{",
"case",
"DIR_DOWN",
":",
"//expand down",
"if",
"(",
"gp",
".",
"getY2",
"(",
")",
"<",
"limit",
".",
"getY2",
"(",
")",
"&&",
"(",
"!",
"hsep",
"||",
"!",
"separatorDown",
"(",
"sub",
".",
"getGridPosition",
"(",
")",
".",
"replaceY",
"(",
"gp",
")",
")",
")",
")",
"//look for the separator under the current expanded bounds",
"{",
"newy",
"=",
"expandVertically",
"(",
"gp",
",",
"limit",
",",
"template",
",",
"true",
",",
"hsep",
")",
";",
"if",
"(",
"newy",
">",
"gp",
".",
"getY2",
"(",
")",
")",
"{",
"gp",
".",
"setY2",
"(",
"newy",
")",
";",
"change",
"=",
"true",
";",
"}",
"}",
"break",
";",
"case",
"DIR_RIGHT",
":",
"//expand right",
"if",
"(",
"gp",
".",
"getX2",
"(",
")",
"<",
"limit",
".",
"getX2",
"(",
")",
"&&",
"(",
"!",
"vsep",
"||",
"!",
"separatorRight",
"(",
"sub",
".",
"getGridPosition",
"(",
")",
".",
"replaceX",
"(",
"gp",
")",
")",
")",
")",
"{",
"newx",
"=",
"expandHorizontally",
"(",
"gp",
",",
"limit",
",",
"template",
",",
"true",
",",
"vsep",
")",
";",
"if",
"(",
"newx",
">",
"gp",
".",
"getX2",
"(",
")",
")",
"{",
"gp",
".",
"setX2",
"(",
"newx",
")",
";",
"change",
"=",
"true",
";",
"}",
"}",
"break",
";",
"case",
"DIR_UP",
":",
"//expand up",
"if",
"(",
"gp",
".",
"getY1",
"(",
")",
">",
"limit",
".",
"getY1",
"(",
")",
"&&",
"(",
"!",
"hsep",
"||",
"!",
"separatorUp",
"(",
"sub",
".",
"getGridPosition",
"(",
")",
".",
"replaceY",
"(",
"gp",
")",
")",
")",
")",
"{",
"newy",
"=",
"expandVertically",
"(",
"gp",
",",
"limit",
",",
"template",
",",
"false",
",",
"hsep",
")",
";",
"if",
"(",
"newy",
"<",
"gp",
".",
"getY1",
"(",
")",
")",
"{",
"gp",
".",
"setY1",
"(",
"newy",
")",
";",
"change",
"=",
"true",
";",
"}",
"}",
"break",
";",
"case",
"DIR_LEFT",
":",
"//expand left",
"if",
"(",
"gp",
".",
"getX1",
"(",
")",
">",
"limit",
".",
"getX1",
"(",
")",
"&&",
"(",
"!",
"vsep",
"||",
"!",
"separatorLeft",
"(",
"sub",
".",
"getGridPosition",
"(",
")",
".",
"replaceX",
"(",
"gp",
")",
")",
")",
")",
"{",
"newx",
"=",
"expandHorizontally",
"(",
"gp",
",",
"limit",
",",
"template",
",",
"false",
",",
"vsep",
")",
";",
"if",
"(",
"newx",
"<",
"gp",
".",
"getX1",
"(",
")",
")",
"{",
"gp",
".",
"setX1",
"(",
"newx",
")",
";",
"change",
"=",
"true",
";",
"}",
"}",
"break",
";",
"}",
"if",
"(",
"!",
"change",
")",
"//not succeeded in this direction ",
"{",
"dir",
"++",
";",
"//another direction",
"if",
"(",
"dir",
">=",
"4",
")",
"dir",
"=",
"0",
";",
"attempts",
"++",
";",
"}",
"else",
"//succeeded - keep the direction",
"{",
"attempts",
"=",
"0",
";",
"}",
"/*if (Config.DEBUG_AREAS)\n {\n dispArea(gp);\n wait(Config.DEBUG_DELAY);\n }*/",
"}",
"}",
"}"
] |
Tries to expand the area in the grid to a greater rectangle in the given limits.
@param sub the area to be expanded
@param gp the initial grid position of the area. This structure is modified by the expansion.
@param limit the maximal size to expand to
@param hsep stop on horizontal separators
@param vsep stop on vertical separators
@param prefDir preferred expansion direction (use DIR_DOWN for vertical
or DIR_RIGHT for horizontal)
@param required indicates whether it is required to reach the specified limit horizontaly
vertically or in both directions (use REQ_* constants)
|
[
"Tries",
"to",
"expand",
"the",
"area",
"in",
"the",
"grid",
"to",
"a",
"greater",
"rectangle",
"in",
"the",
"given",
"limits",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/GroupAnalyzerByStyles.java#L116-L212
|
155,654
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/GroupAnalyzerByStyles.java
|
GroupAnalyzerByStyles.limitReached
|
private boolean limitReached(Rectangular gp, Rectangular limit, short required)
{
switch (required)
{
case REQ_HORIZONTAL:
return gp.getX1() <= limit.getX1() && gp.getX2() >= limit.getX2();
case REQ_VERTICAL:
return gp.getY1() <= limit.getY1() && gp.getY2() >= limit.getY2();
case REQ_BOTH:
return gp.getX1() <= limit.getX1() && gp.getX2() >= limit.getX2()
&& gp.getY1() <= limit.getY1() && gp.getY2() >= limit.getY2();
}
return false;
}
|
java
|
private boolean limitReached(Rectangular gp, Rectangular limit, short required)
{
switch (required)
{
case REQ_HORIZONTAL:
return gp.getX1() <= limit.getX1() && gp.getX2() >= limit.getX2();
case REQ_VERTICAL:
return gp.getY1() <= limit.getY1() && gp.getY2() >= limit.getY2();
case REQ_BOTH:
return gp.getX1() <= limit.getX1() && gp.getX2() >= limit.getX2()
&& gp.getY1() <= limit.getY1() && gp.getY2() >= limit.getY2();
}
return false;
}
|
[
"private",
"boolean",
"limitReached",
"(",
"Rectangular",
"gp",
",",
"Rectangular",
"limit",
",",
"short",
"required",
")",
"{",
"switch",
"(",
"required",
")",
"{",
"case",
"REQ_HORIZONTAL",
":",
"return",
"gp",
".",
"getX1",
"(",
")",
"<=",
"limit",
".",
"getX1",
"(",
")",
"&&",
"gp",
".",
"getX2",
"(",
")",
">=",
"limit",
".",
"getX2",
"(",
")",
";",
"case",
"REQ_VERTICAL",
":",
"return",
"gp",
".",
"getY1",
"(",
")",
"<=",
"limit",
".",
"getY1",
"(",
")",
"&&",
"gp",
".",
"getY2",
"(",
")",
">=",
"limit",
".",
"getY2",
"(",
")",
";",
"case",
"REQ_BOTH",
":",
"return",
"gp",
".",
"getX1",
"(",
")",
"<=",
"limit",
".",
"getX1",
"(",
")",
"&&",
"gp",
".",
"getX2",
"(",
")",
">=",
"limit",
".",
"getX2",
"(",
")",
"&&",
"gp",
".",
"getY1",
"(",
")",
"<=",
"limit",
".",
"getY1",
"(",
")",
"&&",
"gp",
".",
"getY2",
"(",
")",
">=",
"limit",
".",
"getY2",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if the grid bounds have reached a specified limit in the specified direction.
@param gp the bounds to check
@param limit the limit to be reached
@param required the required direction (use the REQ_* constants)
@return true if the limit has been reached or exceeded
|
[
"Checks",
"if",
"the",
"grid",
"bounds",
"have",
"reached",
"a",
"specified",
"limit",
"in",
"the",
"specified",
"direction",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/GroupAnalyzerByStyles.java#L221-L235
|
155,655
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/GroupAnalyzerByStyles.java
|
GroupAnalyzerByStyles.expandHorizontally
|
private int expandHorizontally(Rectangular gp, Rectangular limit, AreaImpl template, boolean right, boolean sep)
{
//System.out.println("exp: " + gp + (right?" ->":" <-") + " " + sep);
int na = right ? gp.getX2() : gp.getX1(); //what to return when it's not possible to expand
int targetx = right ? (gp.getX2() + 1) : (gp.getX1() - 1);
//find candidate boxes
boolean found = false;
int y = gp.getY1();
while (y <= gp.getY2()) //scan everything at the target position
{
AreaImpl cand = (AreaImpl) getTopology().findAreaAt(targetx, y);
//ignore candidates that intersect with our area (could leat to an infinite loop)
if (cand != null && !cand.getGridPosition().intersects(gp))
{
found = true;
if (sep &&
((right && separatorLeft(cand.getGridPosition())) ||
(!right && separatorRight(cand.getGridPosition()))))
return na; //separated, cannot expand
else if ((matchstyles && !cand.hasSameStyle(cand)) || cand.getLevel() > maxlevel)
return na; //not the same style or level
else
{
Rectangular cgp = new Rectangular(cand.getGridPosition());
if (cgp.getY1() == gp.getY1() && cgp.getY2() == gp.getY2())
return targetx; //simple match
else if (cgp.getY1() < gp.getY1() || cgp.getY2() > gp.getY2())
return na; //area overflows, cannot expand
else //candidate is smaller, try to expand align to our width
{
if (right)
{
Rectangular newlimit = new Rectangular(targetx, gp.getY1(), limit.getX2(), gp.getY2());
expandToLimit(cand, cgp, newlimit, template, false, true, DIR_DOWN, REQ_VERTICAL);
if (cgp.getY1() == gp.getY1() && cgp.getY2() == gp.getY2())
return cgp.getX2(); //successfully aligned
}
else
{
Rectangular newlimit = new Rectangular(limit.getX1(), gp.getY1(), targetx, gp.getY2());
expandToLimit(cand, cgp, newlimit, template, false, true, DIR_DOWN, REQ_VERTICAL);
if (cgp.getY1() == gp.getY1() && cgp.getY2() == gp.getY2())
return cgp.getX1(); //successfully aligned
}
}
}
//skip the candidate
y += cand.getGridPosition().getY2() + 1;
}
else
y++;
}
if (!found)
return targetx; //everything below/above empty, can safely expand
else
return na; //some candidates but none usable
}
|
java
|
private int expandHorizontally(Rectangular gp, Rectangular limit, AreaImpl template, boolean right, boolean sep)
{
//System.out.println("exp: " + gp + (right?" ->":" <-") + " " + sep);
int na = right ? gp.getX2() : gp.getX1(); //what to return when it's not possible to expand
int targetx = right ? (gp.getX2() + 1) : (gp.getX1() - 1);
//find candidate boxes
boolean found = false;
int y = gp.getY1();
while (y <= gp.getY2()) //scan everything at the target position
{
AreaImpl cand = (AreaImpl) getTopology().findAreaAt(targetx, y);
//ignore candidates that intersect with our area (could leat to an infinite loop)
if (cand != null && !cand.getGridPosition().intersects(gp))
{
found = true;
if (sep &&
((right && separatorLeft(cand.getGridPosition())) ||
(!right && separatorRight(cand.getGridPosition()))))
return na; //separated, cannot expand
else if ((matchstyles && !cand.hasSameStyle(cand)) || cand.getLevel() > maxlevel)
return na; //not the same style or level
else
{
Rectangular cgp = new Rectangular(cand.getGridPosition());
if (cgp.getY1() == gp.getY1() && cgp.getY2() == gp.getY2())
return targetx; //simple match
else if (cgp.getY1() < gp.getY1() || cgp.getY2() > gp.getY2())
return na; //area overflows, cannot expand
else //candidate is smaller, try to expand align to our width
{
if (right)
{
Rectangular newlimit = new Rectangular(targetx, gp.getY1(), limit.getX2(), gp.getY2());
expandToLimit(cand, cgp, newlimit, template, false, true, DIR_DOWN, REQ_VERTICAL);
if (cgp.getY1() == gp.getY1() && cgp.getY2() == gp.getY2())
return cgp.getX2(); //successfully aligned
}
else
{
Rectangular newlimit = new Rectangular(limit.getX1(), gp.getY1(), targetx, gp.getY2());
expandToLimit(cand, cgp, newlimit, template, false, true, DIR_DOWN, REQ_VERTICAL);
if (cgp.getY1() == gp.getY1() && cgp.getY2() == gp.getY2())
return cgp.getX1(); //successfully aligned
}
}
}
//skip the candidate
y += cand.getGridPosition().getY2() + 1;
}
else
y++;
}
if (!found)
return targetx; //everything below/above empty, can safely expand
else
return na; //some candidates but none usable
}
|
[
"private",
"int",
"expandHorizontally",
"(",
"Rectangular",
"gp",
",",
"Rectangular",
"limit",
",",
"AreaImpl",
"template",
",",
"boolean",
"right",
",",
"boolean",
"sep",
")",
"{",
"//System.out.println(\"exp: \" + gp + (right?\" ->\":\" <-\") + \" \" + sep);",
"int",
"na",
"=",
"right",
"?",
"gp",
".",
"getX2",
"(",
")",
":",
"gp",
".",
"getX1",
"(",
")",
";",
"//what to return when it's not possible to expand",
"int",
"targetx",
"=",
"right",
"?",
"(",
"gp",
".",
"getX2",
"(",
")",
"+",
"1",
")",
":",
"(",
"gp",
".",
"getX1",
"(",
")",
"-",
"1",
")",
";",
"//find candidate boxes",
"boolean",
"found",
"=",
"false",
";",
"int",
"y",
"=",
"gp",
".",
"getY1",
"(",
")",
";",
"while",
"(",
"y",
"<=",
"gp",
".",
"getY2",
"(",
")",
")",
"//scan everything at the target position",
"{",
"AreaImpl",
"cand",
"=",
"(",
"AreaImpl",
")",
"getTopology",
"(",
")",
".",
"findAreaAt",
"(",
"targetx",
",",
"y",
")",
";",
"//ignore candidates that intersect with our area (could leat to an infinite loop)",
"if",
"(",
"cand",
"!=",
"null",
"&&",
"!",
"cand",
".",
"getGridPosition",
"(",
")",
".",
"intersects",
"(",
"gp",
")",
")",
"{",
"found",
"=",
"true",
";",
"if",
"(",
"sep",
"&&",
"(",
"(",
"right",
"&&",
"separatorLeft",
"(",
"cand",
".",
"getGridPosition",
"(",
")",
")",
")",
"||",
"(",
"!",
"right",
"&&",
"separatorRight",
"(",
"cand",
".",
"getGridPosition",
"(",
")",
")",
")",
")",
")",
"return",
"na",
";",
"//separated, cannot expand",
"else",
"if",
"(",
"(",
"matchstyles",
"&&",
"!",
"cand",
".",
"hasSameStyle",
"(",
"cand",
")",
")",
"||",
"cand",
".",
"getLevel",
"(",
")",
">",
"maxlevel",
")",
"return",
"na",
";",
"//not the same style or level",
"else",
"{",
"Rectangular",
"cgp",
"=",
"new",
"Rectangular",
"(",
"cand",
".",
"getGridPosition",
"(",
")",
")",
";",
"if",
"(",
"cgp",
".",
"getY1",
"(",
")",
"==",
"gp",
".",
"getY1",
"(",
")",
"&&",
"cgp",
".",
"getY2",
"(",
")",
"==",
"gp",
".",
"getY2",
"(",
")",
")",
"return",
"targetx",
";",
"//simple match",
"else",
"if",
"(",
"cgp",
".",
"getY1",
"(",
")",
"<",
"gp",
".",
"getY1",
"(",
")",
"||",
"cgp",
".",
"getY2",
"(",
")",
">",
"gp",
".",
"getY2",
"(",
")",
")",
"return",
"na",
";",
"//area overflows, cannot expand",
"else",
"//candidate is smaller, try to expand align to our width",
"{",
"if",
"(",
"right",
")",
"{",
"Rectangular",
"newlimit",
"=",
"new",
"Rectangular",
"(",
"targetx",
",",
"gp",
".",
"getY1",
"(",
")",
",",
"limit",
".",
"getX2",
"(",
")",
",",
"gp",
".",
"getY2",
"(",
")",
")",
";",
"expandToLimit",
"(",
"cand",
",",
"cgp",
",",
"newlimit",
",",
"template",
",",
"false",
",",
"true",
",",
"DIR_DOWN",
",",
"REQ_VERTICAL",
")",
";",
"if",
"(",
"cgp",
".",
"getY1",
"(",
")",
"==",
"gp",
".",
"getY1",
"(",
")",
"&&",
"cgp",
".",
"getY2",
"(",
")",
"==",
"gp",
".",
"getY2",
"(",
")",
")",
"return",
"cgp",
".",
"getX2",
"(",
")",
";",
"//successfully aligned",
"}",
"else",
"{",
"Rectangular",
"newlimit",
"=",
"new",
"Rectangular",
"(",
"limit",
".",
"getX1",
"(",
")",
",",
"gp",
".",
"getY1",
"(",
")",
",",
"targetx",
",",
"gp",
".",
"getY2",
"(",
")",
")",
";",
"expandToLimit",
"(",
"cand",
",",
"cgp",
",",
"newlimit",
",",
"template",
",",
"false",
",",
"true",
",",
"DIR_DOWN",
",",
"REQ_VERTICAL",
")",
";",
"if",
"(",
"cgp",
".",
"getY1",
"(",
")",
"==",
"gp",
".",
"getY1",
"(",
")",
"&&",
"cgp",
".",
"getY2",
"(",
")",
"==",
"gp",
".",
"getY2",
"(",
")",
")",
"return",
"cgp",
".",
"getX1",
"(",
")",
";",
"//successfully aligned",
"}",
"}",
"}",
"//skip the candidate",
"y",
"+=",
"cand",
".",
"getGridPosition",
"(",
")",
".",
"getY2",
"(",
")",
"+",
"1",
";",
"}",
"else",
"y",
"++",
";",
"}",
"if",
"(",
"!",
"found",
")",
"return",
"targetx",
";",
"//everything below/above empty, can safely expand",
"else",
"return",
"na",
";",
"//some candidates but none usable",
"}"
] |
Try to expand the area horizontally by a smallest step possible
@param gp the area position in the grid
@param limit the maximal expansion limit
@param right <code>true</code> meand expand right, <code>false<code> means expand left
@param sep stop on separators
@return the new vertical end of the area.
|
[
"Try",
"to",
"expand",
"the",
"area",
"horizontally",
"by",
"a",
"smallest",
"step",
"possible"
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/GroupAnalyzerByStyles.java#L316-L372
|
155,656
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/stdr/view/TemplateJstlView.java
|
TemplateJstlView.extractTemplateUrl
|
static protected String extractTemplateUrl(String viewName){
int i1 = -1;
int i2 = -1;
int i3 = -1;
int i4 = -1;
i1 = viewName.indexOf(LEFT_BRACKET);
if (i1 != -1){
i2 = viewName.indexOf(LEFT_BRACKET, i1+1);
}
i4 = viewName.lastIndexOf(RIGHT_BRACKET);
if (i4 != -1){
i3 = viewName.lastIndexOf(RIGHT_BRACKET, i4-1);
}
if ((i1 == -1 || i4 == -1) // no starting or ending
|| (i2*i3 < 0) // not matching
|| (i2 > i3)){ // not matching
return viewName; // no valid template descriptor
}
//////// the format is guaranteed to be valid after this point
String url = null;
if (i2 != -1){
url = viewName.substring(i1+1, i2); // prefix{url{...}}postfix
}else{
url = viewName.substring(i1+1, i4); // prefix{url}postfix
}
if (i1 > 0){
String prefix = viewName.substring(0, i1);
url = prefix + url;
}
if (i4 < viewName.length() - 1){
String postfix = viewName.substring(i4 + 1);
url = url + postfix;
}
return url;
}
|
java
|
static protected String extractTemplateUrl(String viewName){
int i1 = -1;
int i2 = -1;
int i3 = -1;
int i4 = -1;
i1 = viewName.indexOf(LEFT_BRACKET);
if (i1 != -1){
i2 = viewName.indexOf(LEFT_BRACKET, i1+1);
}
i4 = viewName.lastIndexOf(RIGHT_BRACKET);
if (i4 != -1){
i3 = viewName.lastIndexOf(RIGHT_BRACKET, i4-1);
}
if ((i1 == -1 || i4 == -1) // no starting or ending
|| (i2*i3 < 0) // not matching
|| (i2 > i3)){ // not matching
return viewName; // no valid template descriptor
}
//////// the format is guaranteed to be valid after this point
String url = null;
if (i2 != -1){
url = viewName.substring(i1+1, i2); // prefix{url{...}}postfix
}else{
url = viewName.substring(i1+1, i4); // prefix{url}postfix
}
if (i1 > 0){
String prefix = viewName.substring(0, i1);
url = prefix + url;
}
if (i4 < viewName.length() - 1){
String postfix = viewName.substring(i4 + 1);
url = url + postfix;
}
return url;
}
|
[
"static",
"protected",
"String",
"extractTemplateUrl",
"(",
"String",
"viewName",
")",
"{",
"int",
"i1",
"=",
"-",
"1",
";",
"int",
"i2",
"=",
"-",
"1",
";",
"int",
"i3",
"=",
"-",
"1",
";",
"int",
"i4",
"=",
"-",
"1",
";",
"i1",
"=",
"viewName",
".",
"indexOf",
"(",
"LEFT_BRACKET",
")",
";",
"if",
"(",
"i1",
"!=",
"-",
"1",
")",
"{",
"i2",
"=",
"viewName",
".",
"indexOf",
"(",
"LEFT_BRACKET",
",",
"i1",
"+",
"1",
")",
";",
"}",
"i4",
"=",
"viewName",
".",
"lastIndexOf",
"(",
"RIGHT_BRACKET",
")",
";",
"if",
"(",
"i4",
"!=",
"-",
"1",
")",
"{",
"i3",
"=",
"viewName",
".",
"lastIndexOf",
"(",
"RIGHT_BRACKET",
",",
"i4",
"-",
"1",
")",
";",
"}",
"if",
"(",
"(",
"i1",
"==",
"-",
"1",
"||",
"i4",
"==",
"-",
"1",
")",
"// no starting or ending ",
"||",
"(",
"i2",
"*",
"i3",
"<",
"0",
")",
"// not matching",
"||",
"(",
"i2",
">",
"i3",
")",
")",
"{",
"// not matching",
"return",
"viewName",
";",
"// no valid template descriptor",
"}",
"//////// the format is guaranteed to be valid after this point",
"String",
"url",
"=",
"null",
";",
"if",
"(",
"i2",
"!=",
"-",
"1",
")",
"{",
"url",
"=",
"viewName",
".",
"substring",
"(",
"i1",
"+",
"1",
",",
"i2",
")",
";",
"// prefix{url{...}}postfix",
"}",
"else",
"{",
"url",
"=",
"viewName",
".",
"substring",
"(",
"i1",
"+",
"1",
",",
"i4",
")",
";",
"// prefix{url}postfix",
"}",
"if",
"(",
"i1",
">",
"0",
")",
"{",
"String",
"prefix",
"=",
"viewName",
".",
"substring",
"(",
"0",
",",
"i1",
")",
";",
"url",
"=",
"prefix",
"+",
"url",
";",
"}",
"if",
"(",
"i4",
"<",
"viewName",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"String",
"postfix",
"=",
"viewName",
".",
"substring",
"(",
"i4",
"+",
"1",
")",
";",
"url",
"=",
"url",
"+",
"postfix",
";",
"}",
"return",
"url",
";",
"}"
] |
Parse the template descriptor to extract template URL
@param viewName
@return URL of the template
|
[
"Parse",
"the",
"template",
"descriptor",
"to",
"extract",
"template",
"URL"
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/stdr/view/TemplateJstlView.java#L71-L111
|
155,657
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/stdr/view/TemplateJstlView.java
|
TemplateJstlView.extractTemplateParameters
|
static protected Map<String, String> extractTemplateParameters(String viewName){
int i1 = -1;
int i2 = -1;
int i3 = -1;
int i4 = -1;
i1 = viewName.indexOf(LEFT_BRACKET);
if (i1 != -1){
i2 = viewName.indexOf(LEFT_BRACKET, i1+1);
}
i4 = viewName.lastIndexOf(RIGHT_BRACKET);
if (i4 != -1){
i3 = viewName.lastIndexOf(RIGHT_BRACKET, i4-1);
}
if ((i1 == -1 || i4 == -1) // no starting or ending
|| (i2 == -1 || i3 == -1) // not found
|| (i2 > i3)){ // not matching
return null; // no valid template descriptor
}
//////// the format is guaranteed to be valid after this point
Map<String, String> parameters = new HashMap<String, String>();
if (i1 > 0){
String prefix = viewName.substring(0, i1);
parameters.put(StdrUtil.URL_PREFIX_PARAMETER, prefix);
}
if (i4 < viewName.length() - 1){
String postfix = viewName.substring(i4 + 1);
parameters.put(StdrUtil.URL_POSTFIX_PARAMETER, postfix);
}
StrTokenizer tokenizer = new StrTokenizer(viewName.substring(i2+1, i3),
StrMatcher.charSetMatcher(',', '='),
StrMatcher.singleQuoteMatcher());
tokenizer.setEmptyTokenAsNull(true);
while(tokenizer.hasNext()){
String name = tokenizer.next();
String value = null;
try{
value = tokenizer.next();
}catch(NoSuchElementException e){
// do nothing, value should be null anyway.
}
parameters.put(name, value);
}
return parameters;
}
|
java
|
static protected Map<String, String> extractTemplateParameters(String viewName){
int i1 = -1;
int i2 = -1;
int i3 = -1;
int i4 = -1;
i1 = viewName.indexOf(LEFT_BRACKET);
if (i1 != -1){
i2 = viewName.indexOf(LEFT_BRACKET, i1+1);
}
i4 = viewName.lastIndexOf(RIGHT_BRACKET);
if (i4 != -1){
i3 = viewName.lastIndexOf(RIGHT_BRACKET, i4-1);
}
if ((i1 == -1 || i4 == -1) // no starting or ending
|| (i2 == -1 || i3 == -1) // not found
|| (i2 > i3)){ // not matching
return null; // no valid template descriptor
}
//////// the format is guaranteed to be valid after this point
Map<String, String> parameters = new HashMap<String, String>();
if (i1 > 0){
String prefix = viewName.substring(0, i1);
parameters.put(StdrUtil.URL_PREFIX_PARAMETER, prefix);
}
if (i4 < viewName.length() - 1){
String postfix = viewName.substring(i4 + 1);
parameters.put(StdrUtil.URL_POSTFIX_PARAMETER, postfix);
}
StrTokenizer tokenizer = new StrTokenizer(viewName.substring(i2+1, i3),
StrMatcher.charSetMatcher(',', '='),
StrMatcher.singleQuoteMatcher());
tokenizer.setEmptyTokenAsNull(true);
while(tokenizer.hasNext()){
String name = tokenizer.next();
String value = null;
try{
value = tokenizer.next();
}catch(NoSuchElementException e){
// do nothing, value should be null anyway.
}
parameters.put(name, value);
}
return parameters;
}
|
[
"static",
"protected",
"Map",
"<",
"String",
",",
"String",
">",
"extractTemplateParameters",
"(",
"String",
"viewName",
")",
"{",
"int",
"i1",
"=",
"-",
"1",
";",
"int",
"i2",
"=",
"-",
"1",
";",
"int",
"i3",
"=",
"-",
"1",
";",
"int",
"i4",
"=",
"-",
"1",
";",
"i1",
"=",
"viewName",
".",
"indexOf",
"(",
"LEFT_BRACKET",
")",
";",
"if",
"(",
"i1",
"!=",
"-",
"1",
")",
"{",
"i2",
"=",
"viewName",
".",
"indexOf",
"(",
"LEFT_BRACKET",
",",
"i1",
"+",
"1",
")",
";",
"}",
"i4",
"=",
"viewName",
".",
"lastIndexOf",
"(",
"RIGHT_BRACKET",
")",
";",
"if",
"(",
"i4",
"!=",
"-",
"1",
")",
"{",
"i3",
"=",
"viewName",
".",
"lastIndexOf",
"(",
"RIGHT_BRACKET",
",",
"i4",
"-",
"1",
")",
";",
"}",
"if",
"(",
"(",
"i1",
"==",
"-",
"1",
"||",
"i4",
"==",
"-",
"1",
")",
"// no starting or ending ",
"||",
"(",
"i2",
"==",
"-",
"1",
"||",
"i3",
"==",
"-",
"1",
")",
"// not found",
"||",
"(",
"i2",
">",
"i3",
")",
")",
"{",
"// not matching",
"return",
"null",
";",
"// no valid template descriptor",
"}",
"//////// the format is guaranteed to be valid after this point",
"Map",
"<",
"String",
",",
"String",
">",
"parameters",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"i1",
">",
"0",
")",
"{",
"String",
"prefix",
"=",
"viewName",
".",
"substring",
"(",
"0",
",",
"i1",
")",
";",
"parameters",
".",
"put",
"(",
"StdrUtil",
".",
"URL_PREFIX_PARAMETER",
",",
"prefix",
")",
";",
"}",
"if",
"(",
"i4",
"<",
"viewName",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"String",
"postfix",
"=",
"viewName",
".",
"substring",
"(",
"i4",
"+",
"1",
")",
";",
"parameters",
".",
"put",
"(",
"StdrUtil",
".",
"URL_POSTFIX_PARAMETER",
",",
"postfix",
")",
";",
"}",
"StrTokenizer",
"tokenizer",
"=",
"new",
"StrTokenizer",
"(",
"viewName",
".",
"substring",
"(",
"i2",
"+",
"1",
",",
"i3",
")",
",",
"StrMatcher",
".",
"charSetMatcher",
"(",
"'",
"'",
",",
"'",
"'",
")",
",",
"StrMatcher",
".",
"singleQuoteMatcher",
"(",
")",
")",
";",
"tokenizer",
".",
"setEmptyTokenAsNull",
"(",
"true",
")",
";",
"while",
"(",
"tokenizer",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"name",
"=",
"tokenizer",
".",
"next",
"(",
")",
";",
"String",
"value",
"=",
"null",
";",
"try",
"{",
"value",
"=",
"tokenizer",
".",
"next",
"(",
")",
";",
"}",
"catch",
"(",
"NoSuchElementException",
"e",
")",
"{",
"// do nothing, value should be null anyway.",
"}",
"parameters",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}",
"return",
"parameters",
";",
"}"
] |
Parse the template descriptor to extract template parameters
@param viewName structs view name
@return template parameters retrieved from the vew name
|
[
"Parse",
"the",
"template",
"descriptor",
"to",
"extract",
"template",
"parameters"
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/stdr/view/TemplateJstlView.java#L118-L166
|
155,658
|
bushidowallet/bushido-java-service
|
bushido-service-lib/src/main/java/com/bccapi/bitlib/util/StringUtils.java
|
StringUtils.join
|
public static String join(String[] strings, String separator) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String s : strings) {
if (first) {
first = false;
} else {
sb.append(separator);
}
sb.append(s);
}
return sb.toString();
}
|
java
|
public static String join(String[] strings, String separator) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String s : strings) {
if (first) {
first = false;
} else {
sb.append(separator);
}
sb.append(s);
}
return sb.toString();
}
|
[
"public",
"static",
"String",
"join",
"(",
"String",
"[",
"]",
"strings",
",",
"String",
"separator",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"String",
"s",
":",
"strings",
")",
"{",
"if",
"(",
"first",
")",
"{",
"first",
"=",
"false",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"separator",
")",
";",
"}",
"sb",
".",
"append",
"(",
"s",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Join an array of strings with the given separator.
@param strings
The strings to join
@param separator
The separator to use
@return The concatenation of the collection of strings with the given
separator.
|
[
"Join",
"an",
"array",
"of",
"strings",
"with",
"the",
"given",
"separator",
"."
] |
e1a0157527e57459b509718044d2df44084876a2
|
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/util/StringUtils.java#L43-L55
|
155,659
|
bushidowallet/bushido-java-service
|
bushido-service-lib/src/main/java/com/bccapi/bitlib/util/StringUtils.java
|
StringUtils.cap
|
public static String cap(String str, int capSize) {
if (str.length() <= capSize) {
return str;
}
if (capSize <= 3) {
return str.substring(0, capSize);
}
return str.substring(0, capSize - 3) + "...";
}
|
java
|
public static String cap(String str, int capSize) {
if (str.length() <= capSize) {
return str;
}
if (capSize <= 3) {
return str.substring(0, capSize);
}
return str.substring(0, capSize - 3) + "...";
}
|
[
"public",
"static",
"String",
"cap",
"(",
"String",
"str",
",",
"int",
"capSize",
")",
"{",
"if",
"(",
"str",
".",
"length",
"(",
")",
"<=",
"capSize",
")",
"{",
"return",
"str",
";",
"}",
"if",
"(",
"capSize",
"<=",
"3",
")",
"{",
"return",
"str",
".",
"substring",
"(",
"0",
",",
"capSize",
")",
";",
"}",
"return",
"str",
".",
"substring",
"(",
"0",
",",
"capSize",
"-",
"3",
")",
"+",
"\"...\"",
";",
"}"
] |
Return a string that is no longer than capSize, and pad with "..." if
returning a substring.
@param str
The string to cap
@param capSize
The maximum cap size
@return The string capped at capSize.
|
[
"Return",
"a",
"string",
"that",
"is",
"no",
"longer",
"than",
"capSize",
"and",
"pad",
"with",
"...",
"if",
"returning",
"a",
"substring",
"."
] |
e1a0157527e57459b509718044d2df44084876a2
|
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/util/StringUtils.java#L95-L103
|
155,660
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/agent/LineNumberingClassAdapter.java
|
LineNumberingClassAdapter.visitMethod
|
@Override
public MethodVisitor visitMethod(int access, final String name, String desc,
String signature, String[] exceptions) {
MethodVisitor mv = cv.visitMethod(access | Opcodes.ACC_SYNTHETIC,
name, desc, signature, exceptions);
return new LineNumberingMethodAdapter(mv, access | Opcodes.ACC_SYNTHETIC,
name, desc) {
@Override
protected void onMethodEnter() {
this.lineNumbers = LineNumberingClassAdapter.this.lineNumbers;
super.onMethodEnter();
}
};
}
|
java
|
@Override
public MethodVisitor visitMethod(int access, final String name, String desc,
String signature, String[] exceptions) {
MethodVisitor mv = cv.visitMethod(access | Opcodes.ACC_SYNTHETIC,
name, desc, signature, exceptions);
return new LineNumberingMethodAdapter(mv, access | Opcodes.ACC_SYNTHETIC,
name, desc) {
@Override
protected void onMethodEnter() {
this.lineNumbers = LineNumberingClassAdapter.this.lineNumbers;
super.onMethodEnter();
}
};
}
|
[
"@",
"Override",
"public",
"MethodVisitor",
"visitMethod",
"(",
"int",
"access",
",",
"final",
"String",
"name",
",",
"String",
"desc",
",",
"String",
"signature",
",",
"String",
"[",
"]",
"exceptions",
")",
"{",
"MethodVisitor",
"mv",
"=",
"cv",
".",
"visitMethod",
"(",
"access",
"|",
"Opcodes",
".",
"ACC_SYNTHETIC",
",",
"name",
",",
"desc",
",",
"signature",
",",
"exceptions",
")",
";",
"return",
"new",
"LineNumberingMethodAdapter",
"(",
"mv",
",",
"access",
"|",
"Opcodes",
".",
"ACC_SYNTHETIC",
",",
"name",
",",
"desc",
")",
"{",
"@",
"Override",
"protected",
"void",
"onMethodEnter",
"(",
")",
"{",
"this",
".",
"lineNumbers",
"=",
"LineNumberingClassAdapter",
".",
"this",
".",
"lineNumbers",
";",
"super",
".",
"onMethodEnter",
"(",
")",
";",
"}",
"}",
";",
"}"
] |
Visits the specified method, adding line numbering.
|
[
"Visits",
"the",
"specified",
"method",
"adding",
"line",
"numbering",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/LineNumberingClassAdapter.java#L54-L67
|
155,661
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/apt/MethodContractCreator.java
|
MethodContractCreator.createOldMethods
|
@Requires({
"kind != null",
"pos >= 0",
"id >= 0",
"pos <= id",
"expr != null",
"annotation != null",
"kind.isOld()",
"lineNumber == null || lineNumber >= 1"
})
private void createOldMethods(ContractKind kind,
int pos, int id, String expr, ContractAnnotationModel annotation,
Long lineNumber) {
MethodModel helper =
ContractCreation.createBlankContractHelper(kind, annotation,
"$" + Integer.toString(pos));
helper.setReturnType(new ClassName("java/lang/Object"));
if (helper.getKind() == ElementKind.CONTRACT_METHOD) {
ContractMethodModel helperContract = (ContractMethodModel) helper;
if (lineNumber != null) {
helperContract.setLineNumbers(Collections.singletonList(lineNumber));
}
String code = expr;
if (!annotation.isVirtual()) {
code = ContractCreation
.rebaseLocalCalls(expr, JavaUtils.THAT_VARIABLE, null);
}
helperContract.addStatement("return " + code + ";");
}
ContractMethodModel contract =
ContractCreation.createBlankContractMethod(kind, annotation, "$" + id);
contract.setReturnType(new ClassName("java/lang/Object"));
contract.setId(id);
contract.addStatement("return "
+ ContractCreation.getHelperCallCode(helper, annotation) + ";");
}
|
java
|
@Requires({
"kind != null",
"pos >= 0",
"id >= 0",
"pos <= id",
"expr != null",
"annotation != null",
"kind.isOld()",
"lineNumber == null || lineNumber >= 1"
})
private void createOldMethods(ContractKind kind,
int pos, int id, String expr, ContractAnnotationModel annotation,
Long lineNumber) {
MethodModel helper =
ContractCreation.createBlankContractHelper(kind, annotation,
"$" + Integer.toString(pos));
helper.setReturnType(new ClassName("java/lang/Object"));
if (helper.getKind() == ElementKind.CONTRACT_METHOD) {
ContractMethodModel helperContract = (ContractMethodModel) helper;
if (lineNumber != null) {
helperContract.setLineNumbers(Collections.singletonList(lineNumber));
}
String code = expr;
if (!annotation.isVirtual()) {
code = ContractCreation
.rebaseLocalCalls(expr, JavaUtils.THAT_VARIABLE, null);
}
helperContract.addStatement("return " + code + ";");
}
ContractMethodModel contract =
ContractCreation.createBlankContractMethod(kind, annotation, "$" + id);
contract.setReturnType(new ClassName("java/lang/Object"));
contract.setId(id);
contract.addStatement("return "
+ ContractCreation.getHelperCallCode(helper, annotation) + ";");
}
|
[
"@",
"Requires",
"(",
"{",
"\"kind != null\"",
",",
"\"pos >= 0\"",
",",
"\"id >= 0\"",
",",
"\"pos <= id\"",
",",
"\"expr != null\"",
",",
"\"annotation != null\"",
",",
"\"kind.isOld()\"",
",",
"\"lineNumber == null || lineNumber >= 1\"",
"}",
")",
"private",
"void",
"createOldMethods",
"(",
"ContractKind",
"kind",
",",
"int",
"pos",
",",
"int",
"id",
",",
"String",
"expr",
",",
"ContractAnnotationModel",
"annotation",
",",
"Long",
"lineNumber",
")",
"{",
"MethodModel",
"helper",
"=",
"ContractCreation",
".",
"createBlankContractHelper",
"(",
"kind",
",",
"annotation",
",",
"\"$\"",
"+",
"Integer",
".",
"toString",
"(",
"pos",
")",
")",
";",
"helper",
".",
"setReturnType",
"(",
"new",
"ClassName",
"(",
"\"java/lang/Object\"",
")",
")",
";",
"if",
"(",
"helper",
".",
"getKind",
"(",
")",
"==",
"ElementKind",
".",
"CONTRACT_METHOD",
")",
"{",
"ContractMethodModel",
"helperContract",
"=",
"(",
"ContractMethodModel",
")",
"helper",
";",
"if",
"(",
"lineNumber",
"!=",
"null",
")",
"{",
"helperContract",
".",
"setLineNumbers",
"(",
"Collections",
".",
"singletonList",
"(",
"lineNumber",
")",
")",
";",
"}",
"String",
"code",
"=",
"expr",
";",
"if",
"(",
"!",
"annotation",
".",
"isVirtual",
"(",
")",
")",
"{",
"code",
"=",
"ContractCreation",
".",
"rebaseLocalCalls",
"(",
"expr",
",",
"JavaUtils",
".",
"THAT_VARIABLE",
",",
"null",
")",
";",
"}",
"helperContract",
".",
"addStatement",
"(",
"\"return \"",
"+",
"code",
"+",
"\";\"",
")",
";",
"}",
"ContractMethodModel",
"contract",
"=",
"ContractCreation",
".",
"createBlankContractMethod",
"(",
"kind",
",",
"annotation",
",",
"\"$\"",
"+",
"id",
")",
";",
"contract",
".",
"setReturnType",
"(",
"new",
"ClassName",
"(",
"\"java/lang/Object\"",
")",
")",
";",
"contract",
".",
"setId",
"(",
"id",
")",
";",
"contract",
".",
"addStatement",
"(",
"\"return \"",
"+",
"ContractCreation",
".",
"getHelperCallCode",
"(",
"helper",
",",
"annotation",
")",
"+",
"\";\"",
")",
";",
"}"
] |
Creates contract and helper methods according to the parameters,
and adds it to the parent type.
@param kind the kind of contract method to create
@param pos the relative position of {@code expr} in its
annotation
@param id the contract method ID
@param expr the expression computing the old value
@param annotation the annotation value from which this contract
is created
|
[
"Creates",
"contract",
"and",
"helper",
"methods",
"according",
"to",
"the",
"parameters",
"and",
"adds",
"it",
"to",
"the",
"parent",
"type",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/apt/MethodContractCreator.java#L318-L356
|
155,662
|
blakepettersson/reactmann
|
reactmann-core/src/main/java/reactmann/subscribers/RiemannParser.java
|
RiemannParser.handle
|
public void handle(Buffer buffer) {
if (buff == null) {
buff = buffer;
} else {
buff.appendBuffer(buffer);
}
if(recordSize == -1) {
fixedSizeMode(buff.getInt(0) + 4);
}
handleParsing();
}
|
java
|
public void handle(Buffer buffer) {
if (buff == null) {
buff = buffer;
} else {
buff.appendBuffer(buffer);
}
if(recordSize == -1) {
fixedSizeMode(buff.getInt(0) + 4);
}
handleParsing();
}
|
[
"public",
"void",
"handle",
"(",
"Buffer",
"buffer",
")",
"{",
"if",
"(",
"buff",
"==",
"null",
")",
"{",
"buff",
"=",
"buffer",
";",
"}",
"else",
"{",
"buff",
".",
"appendBuffer",
"(",
"buffer",
")",
";",
"}",
"if",
"(",
"recordSize",
"==",
"-",
"1",
")",
"{",
"fixedSizeMode",
"(",
"buff",
".",
"getInt",
"(",
"0",
")",
"+",
"4",
")",
";",
"}",
"handleParsing",
"(",
")",
";",
"}"
] |
This method is called to provide the parser with data.
@param buffer
|
[
"This",
"method",
"is",
"called",
"to",
"provide",
"the",
"parser",
"with",
"data",
"."
] |
cebb113c8a8db3a27b3d728e00d8f0b2585e9157
|
https://github.com/blakepettersson/reactmann/blob/cebb113c8a8db3a27b3d728e00d8f0b2585e9157/reactmann-core/src/main/java/reactmann/subscribers/RiemannParser.java#L70-L82
|
155,663
|
BellaDati/belladati-sdk-java
|
src/main/java/com/belladati/sdk/dashboard/impl/DashletImpl.java
|
DashletImpl.findType
|
private Type findType(String typeString) throws UnknownDashletTypeException {
if ("viewReport".equalsIgnoreCase(typeString)) {
return Type.VIEW;
} else if ("textContent".equalsIgnoreCase(typeString)) {
return Type.TEXT;
}
throw new UnknownDashletTypeException(typeString);
}
|
java
|
private Type findType(String typeString) throws UnknownDashletTypeException {
if ("viewReport".equalsIgnoreCase(typeString)) {
return Type.VIEW;
} else if ("textContent".equalsIgnoreCase(typeString)) {
return Type.TEXT;
}
throw new UnknownDashletTypeException(typeString);
}
|
[
"private",
"Type",
"findType",
"(",
"String",
"typeString",
")",
"throws",
"UnknownDashletTypeException",
"{",
"if",
"(",
"\"viewReport\"",
".",
"equalsIgnoreCase",
"(",
"typeString",
")",
")",
"{",
"return",
"Type",
".",
"VIEW",
";",
"}",
"else",
"if",
"(",
"\"textContent\"",
".",
"equalsIgnoreCase",
"(",
"typeString",
")",
")",
"{",
"return",
"Type",
".",
"TEXT",
";",
"}",
"throw",
"new",
"UnknownDashletTypeException",
"(",
"typeString",
")",
";",
"}"
] |
Determines the dashlet type from the given type string.
@param typeString string to parse (from JSON)
@return the dashlet type
@throws UnknownDashletTypeException if no such type was found
|
[
"Determines",
"the",
"dashlet",
"type",
"from",
"the",
"given",
"type",
"string",
"."
] |
1a732a57ebc825ddf47ce405723cc958adb1a43f
|
https://github.com/BellaDati/belladati-sdk-java/blob/1a732a57ebc825ddf47ce405723cc958adb1a43f/src/main/java/com/belladati/sdk/dashboard/impl/DashletImpl.java#L47-L54
|
155,664
|
BellaDati/belladati-sdk-java
|
src/main/java/com/belladati/sdk/dashboard/impl/DashletImpl.java
|
DashletImpl.getContentView
|
private View getContentView(BellaDatiServiceImpl service, JsonNode node) throws UnsupportedDashletContentException {
if (!node.hasNonNull("canAccessViewReport") || !node.get("canAccessViewReport").asBoolean()) {
throw new UnsupportedDashletContentException("View not accessible");
}
if (!node.hasNonNull("viewReport")) {
throw new UnsupportedDashletContentException("Missing view element");
}
try {
return ViewImpl.buildView(service, node.get("viewReport"));
} catch (UnknownViewTypeException e) {
throw new UnsupportedDashletContentException(e);
}
}
|
java
|
private View getContentView(BellaDatiServiceImpl service, JsonNode node) throws UnsupportedDashletContentException {
if (!node.hasNonNull("canAccessViewReport") || !node.get("canAccessViewReport").asBoolean()) {
throw new UnsupportedDashletContentException("View not accessible");
}
if (!node.hasNonNull("viewReport")) {
throw new UnsupportedDashletContentException("Missing view element");
}
try {
return ViewImpl.buildView(service, node.get("viewReport"));
} catch (UnknownViewTypeException e) {
throw new UnsupportedDashletContentException(e);
}
}
|
[
"private",
"View",
"getContentView",
"(",
"BellaDatiServiceImpl",
"service",
",",
"JsonNode",
"node",
")",
"throws",
"UnsupportedDashletContentException",
"{",
"if",
"(",
"!",
"node",
".",
"hasNonNull",
"(",
"\"canAccessViewReport\"",
")",
"||",
"!",
"node",
".",
"get",
"(",
"\"canAccessViewReport\"",
")",
".",
"asBoolean",
"(",
")",
")",
"{",
"throw",
"new",
"UnsupportedDashletContentException",
"(",
"\"View not accessible\"",
")",
";",
"}",
"if",
"(",
"!",
"node",
".",
"hasNonNull",
"(",
"\"viewReport\"",
")",
")",
"{",
"throw",
"new",
"UnsupportedDashletContentException",
"(",
"\"Missing view element\"",
")",
";",
"}",
"try",
"{",
"return",
"ViewImpl",
".",
"buildView",
"(",
"service",
",",
"node",
".",
"get",
"(",
"\"viewReport\"",
")",
")",
";",
"}",
"catch",
"(",
"UnknownViewTypeException",
"e",
")",
"{",
"throw",
"new",
"UnsupportedDashletContentException",
"(",
"e",
")",
";",
"}",
"}"
] |
Reads view content from a dashlet node.
|
[
"Reads",
"view",
"content",
"from",
"a",
"dashlet",
"node",
"."
] |
1a732a57ebc825ddf47ce405723cc958adb1a43f
|
https://github.com/BellaDati/belladati-sdk-java/blob/1a732a57ebc825ddf47ce405723cc958adb1a43f/src/main/java/com/belladati/sdk/dashboard/impl/DashletImpl.java#L57-L69
|
155,665
|
BellaDati/belladati-sdk-java
|
src/main/java/com/belladati/sdk/dashboard/impl/DashletImpl.java
|
DashletImpl.getContentText
|
private String getContentText(JsonNode node) throws UnsupportedDashletContentException {
if (node.hasNonNull("textContent")) {
return node.get("textContent").asText();
} else {
throw new UnsupportedDashletContentException("Text content missing");
}
}
|
java
|
private String getContentText(JsonNode node) throws UnsupportedDashletContentException {
if (node.hasNonNull("textContent")) {
return node.get("textContent").asText();
} else {
throw new UnsupportedDashletContentException("Text content missing");
}
}
|
[
"private",
"String",
"getContentText",
"(",
"JsonNode",
"node",
")",
"throws",
"UnsupportedDashletContentException",
"{",
"if",
"(",
"node",
".",
"hasNonNull",
"(",
"\"textContent\"",
")",
")",
"{",
"return",
"node",
".",
"get",
"(",
"\"textContent\"",
")",
".",
"asText",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedDashletContentException",
"(",
"\"Text content missing\"",
")",
";",
"}",
"}"
] |
Reads text content from a dashlet node.
|
[
"Reads",
"text",
"content",
"from",
"a",
"dashlet",
"node",
"."
] |
1a732a57ebc825ddf47ce405723cc958adb1a43f
|
https://github.com/BellaDati/belladati-sdk-java/blob/1a732a57ebc825ddf47ce405723cc958adb1a43f/src/main/java/com/belladati/sdk/dashboard/impl/DashletImpl.java#L72-L78
|
155,666
|
RogerParkinson/madura-objects-parent
|
madura-rules/src/main/java/nz/co/senanque/rules/OperationsImpl.java
|
OperationsImpl.unique
|
@InternalFunction()
public Boolean unique(final List<ProxyField> list)
{
if (list == null)
{
return Boolean.TRUE;
}
int size = list.size();
int index = 0;
for (ProxyField proxyField: list)
{
for (int i=index+1;i<size;i++)
{
if (list.get(i).getValue().equals(proxyField.getValue()))
{
return Boolean.FALSE;
}
}
}
return Boolean.TRUE;
}
|
java
|
@InternalFunction()
public Boolean unique(final List<ProxyField> list)
{
if (list == null)
{
return Boolean.TRUE;
}
int size = list.size();
int index = 0;
for (ProxyField proxyField: list)
{
for (int i=index+1;i<size;i++)
{
if (list.get(i).getValue().equals(proxyField.getValue()))
{
return Boolean.FALSE;
}
}
}
return Boolean.TRUE;
}
|
[
"@",
"InternalFunction",
"(",
")",
"public",
"Boolean",
"unique",
"(",
"final",
"List",
"<",
"ProxyField",
">",
"list",
")",
"{",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"return",
"Boolean",
".",
"TRUE",
";",
"}",
"int",
"size",
"=",
"list",
".",
"size",
"(",
")",
";",
"int",
"index",
"=",
"0",
";",
"for",
"(",
"ProxyField",
"proxyField",
":",
"list",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"index",
"+",
"1",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"if",
"(",
"list",
".",
"get",
"(",
"i",
")",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"proxyField",
".",
"getValue",
"(",
")",
")",
")",
"{",
"return",
"Boolean",
".",
"FALSE",
";",
"}",
"}",
"}",
"return",
"Boolean",
".",
"TRUE",
";",
"}"
] |
Every item in the list must be unique
@param list
@return true if all unique
|
[
"Every",
"item",
"in",
"the",
"list",
"must",
"be",
"unique"
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-rules/src/main/java/nz/co/senanque/rules/OperationsImpl.java#L271-L291
|
155,667
|
RogerParkinson/madura-objects-parent
|
madura-rules/src/main/java/nz/co/senanque/rules/OperationsImpl.java
|
OperationsImpl.match
|
@InternalFunction()
public Boolean match(final List<ProxyField> list,final List<ProxyField> list2)
{
if (list == null)
{
return Boolean.TRUE;
}
for (ProxyField proxyField: list)
{
boolean found = false;
for (ProxyField proxyField2: list2)
{
if (proxyField.getValue().equals(proxyField2.getValue()))
{
found = true;
break;
}
}
if (!found)
{
return Boolean.FALSE;
}
}
return Boolean.TRUE;
}
|
java
|
@InternalFunction()
public Boolean match(final List<ProxyField> list,final List<ProxyField> list2)
{
if (list == null)
{
return Boolean.TRUE;
}
for (ProxyField proxyField: list)
{
boolean found = false;
for (ProxyField proxyField2: list2)
{
if (proxyField.getValue().equals(proxyField2.getValue()))
{
found = true;
break;
}
}
if (!found)
{
return Boolean.FALSE;
}
}
return Boolean.TRUE;
}
|
[
"@",
"InternalFunction",
"(",
")",
"public",
"Boolean",
"match",
"(",
"final",
"List",
"<",
"ProxyField",
">",
"list",
",",
"final",
"List",
"<",
"ProxyField",
">",
"list2",
")",
"{",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"return",
"Boolean",
".",
"TRUE",
";",
"}",
"for",
"(",
"ProxyField",
"proxyField",
":",
"list",
")",
"{",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"ProxyField",
"proxyField2",
":",
"list2",
")",
"{",
"if",
"(",
"proxyField",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"proxyField2",
".",
"getValue",
"(",
")",
")",
")",
"{",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"return",
"Boolean",
".",
"FALSE",
";",
"}",
"}",
"return",
"Boolean",
".",
"TRUE",
";",
"}"
] |
Everything in the first list must be in the second list too
But not necessarily the reverse.
@param list
@param list2
@return true if first list is in the second
|
[
"Everything",
"in",
"the",
"first",
"list",
"must",
"be",
"in",
"the",
"second",
"list",
"too",
"But",
"not",
"necessarily",
"the",
"reverse",
"."
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-rules/src/main/java/nz/co/senanque/rules/OperationsImpl.java#L300-L324
|
155,668
|
bushidowallet/bushido-java-service
|
bushido-service-lib/src/main/java/com/bccapi/bitlib/util/HexUtils.java
|
HexUtils.toHex
|
public static String toHex(byte b) {
StringBuilder sb = new StringBuilder();
appendByteAsHex(sb, b);
return sb.toString();
}
|
java
|
public static String toHex(byte b) {
StringBuilder sb = new StringBuilder();
appendByteAsHex(sb, b);
return sb.toString();
}
|
[
"public",
"static",
"String",
"toHex",
"(",
"byte",
"b",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"appendByteAsHex",
"(",
"sb",
",",
"b",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Encodes a single byte to hex symbols.
@param b the byte to encode
@return the resulting hex string
|
[
"Encodes",
"a",
"single",
"byte",
"to",
"hex",
"symbols",
"."
] |
e1a0157527e57459b509718044d2df44084876a2
|
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/util/HexUtils.java#L69-L73
|
155,669
|
bushidowallet/bushido-java-service
|
bushido-service-lib/src/main/java/com/bccapi/bitlib/util/HexUtils.java
|
HexUtils.toBytes
|
public static byte[] toBytes(String hexString) {
if (hexString == null || hexString.length() % 2 != 0) {
throw new RuntimeException("Input string must contain an even number of characters");
}
char[] hex = hexString.toCharArray();
int length = hex.length / 2;
byte[] raw = new byte[length];
for (int i = 0; i < length; i++) {
int high = Character.digit(hex[i * 2], 16);
int low = Character.digit(hex[i * 2 + 1], 16);
int value = (high << 4) | low;
if (value > 127)
value -= 256;
raw[i] = (byte) value;
}
return raw;
}
|
java
|
public static byte[] toBytes(String hexString) {
if (hexString == null || hexString.length() % 2 != 0) {
throw new RuntimeException("Input string must contain an even number of characters");
}
char[] hex = hexString.toCharArray();
int length = hex.length / 2;
byte[] raw = new byte[length];
for (int i = 0; i < length; i++) {
int high = Character.digit(hex[i * 2], 16);
int low = Character.digit(hex[i * 2 + 1], 16);
int value = (high << 4) | low;
if (value > 127)
value -= 256;
raw[i] = (byte) value;
}
return raw;
}
|
[
"public",
"static",
"byte",
"[",
"]",
"toBytes",
"(",
"String",
"hexString",
")",
"{",
"if",
"(",
"hexString",
"==",
"null",
"||",
"hexString",
".",
"length",
"(",
")",
"%",
"2",
"!=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Input string must contain an even number of characters\"",
")",
";",
"}",
"char",
"[",
"]",
"hex",
"=",
"hexString",
".",
"toCharArray",
"(",
")",
";",
"int",
"length",
"=",
"hex",
".",
"length",
"/",
"2",
";",
"byte",
"[",
"]",
"raw",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"int",
"high",
"=",
"Character",
".",
"digit",
"(",
"hex",
"[",
"i",
"*",
"2",
"]",
",",
"16",
")",
";",
"int",
"low",
"=",
"Character",
".",
"digit",
"(",
"hex",
"[",
"i",
"*",
"2",
"+",
"1",
"]",
",",
"16",
")",
";",
"int",
"value",
"=",
"(",
"high",
"<<",
"4",
")",
"|",
"low",
";",
"if",
"(",
"value",
">",
"127",
")",
"value",
"-=",
"256",
";",
"raw",
"[",
"i",
"]",
"=",
"(",
"byte",
")",
"value",
";",
"}",
"return",
"raw",
";",
"}"
] |
Get the byte representation of an ASCII-HEX string.
@param hexString
The string to convert to bytes
@return The byte representation of the ASCII-HEX string.
|
[
"Get",
"the",
"byte",
"representation",
"of",
"an",
"ASCII",
"-",
"HEX",
"string",
"."
] |
e1a0157527e57459b509718044d2df44084876a2
|
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/util/HexUtils.java#L112-L128
|
155,670
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMCollections.java
|
JMCollections.ifNotNullOrEmptyConsume
|
public static <T, C extends Collection<T>> void
ifNotNullOrEmptyConsume(C collection, Consumer<C> consumer) {
JMOptional.getOptional(collection).ifPresent(consumer);
}
|
java
|
public static <T, C extends Collection<T>> void
ifNotNullOrEmptyConsume(C collection, Consumer<C> consumer) {
JMOptional.getOptional(collection).ifPresent(consumer);
}
|
[
"public",
"static",
"<",
"T",
",",
"C",
"extends",
"Collection",
"<",
"T",
">",
">",
"void",
"ifNotNullOrEmptyConsume",
"(",
"C",
"collection",
",",
"Consumer",
"<",
"C",
">",
"consumer",
")",
"{",
"JMOptional",
".",
"getOptional",
"(",
"collection",
")",
".",
"ifPresent",
"(",
"consumer",
")",
";",
"}"
] |
If not null or empty consume.
@param <T> the type parameter
@param <C> the type parameter
@param collection the collection
@param consumer the consumer
|
[
"If",
"not",
"null",
"or",
"empty",
"consume",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMCollections.java#L31-L34
|
155,671
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMCollections.java
|
JMCollections.buildMergedList
|
public static <E> List<E> buildMergedList(
Collection<E> collection1, Collection<E> collection2) {
List<E> mergedList = new ArrayList<>(collection1);
mergedList.addAll(collection2);
return mergedList;
}
|
java
|
public static <E> List<E> buildMergedList(
Collection<E> collection1, Collection<E> collection2) {
List<E> mergedList = new ArrayList<>(collection1);
mergedList.addAll(collection2);
return mergedList;
}
|
[
"public",
"static",
"<",
"E",
">",
"List",
"<",
"E",
">",
"buildMergedList",
"(",
"Collection",
"<",
"E",
">",
"collection1",
",",
"Collection",
"<",
"E",
">",
"collection2",
")",
"{",
"List",
"<",
"E",
">",
"mergedList",
"=",
"new",
"ArrayList",
"<>",
"(",
"collection1",
")",
";",
"mergedList",
".",
"addAll",
"(",
"collection2",
")",
";",
"return",
"mergedList",
";",
"}"
] |
Build merged list list.
@param <E> the type parameter
@param collection1 the collection 1
@param collection2 the collection 2
@return the list
|
[
"Build",
"merged",
"list",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMCollections.java#L126-L131
|
155,672
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMCollections.java
|
JMCollections.buildListWithDelimiter
|
public static List<String> buildListWithDelimiter(
String stringWithDelimiter, String delimiter) {
return buildTokenStream(stringWithDelimiter, delimiter)
.collect(toList());
}
|
java
|
public static List<String> buildListWithDelimiter(
String stringWithDelimiter, String delimiter) {
return buildTokenStream(stringWithDelimiter, delimiter)
.collect(toList());
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"buildListWithDelimiter",
"(",
"String",
"stringWithDelimiter",
",",
"String",
"delimiter",
")",
"{",
"return",
"buildTokenStream",
"(",
"stringWithDelimiter",
",",
"delimiter",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"}"
] |
Build list with delimiter list.
@param stringWithDelimiter the string with delimiter
@param delimiter the delimiter
@return the list
|
[
"Build",
"list",
"with",
"delimiter",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMCollections.java#L150-L154
|
155,673
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMCollections.java
|
JMCollections.splitIntoSubList
|
public static <E> List<List<E>> splitIntoSubList(List<E> list,
int targetSize) {
int listSize = list.size();
return JMStream.numberRange(0, listSize, targetSize)
.mapToObj(index -> list.subList(index,
Math.min(index + targetSize, listSize)))
.collect(toList());
}
|
java
|
public static <E> List<List<E>> splitIntoSubList(List<E> list,
int targetSize) {
int listSize = list.size();
return JMStream.numberRange(0, listSize, targetSize)
.mapToObj(index -> list.subList(index,
Math.min(index + targetSize, listSize)))
.collect(toList());
}
|
[
"public",
"static",
"<",
"E",
">",
"List",
"<",
"List",
"<",
"E",
">",
">",
"splitIntoSubList",
"(",
"List",
"<",
"E",
">",
"list",
",",
"int",
"targetSize",
")",
"{",
"int",
"listSize",
"=",
"list",
".",
"size",
"(",
")",
";",
"return",
"JMStream",
".",
"numberRange",
"(",
"0",
",",
"listSize",
",",
"targetSize",
")",
".",
"mapToObj",
"(",
"index",
"->",
"list",
".",
"subList",
"(",
"index",
",",
"Math",
".",
"min",
"(",
"index",
"+",
"targetSize",
",",
"listSize",
")",
")",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"}"
] |
Split into sub list list.
@param <E> the type parameter
@param list the list
@param targetSize the target size
@return the list
|
[
"Split",
"into",
"sub",
"list",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMCollections.java#L174-L181
|
155,674
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMCollections.java
|
JMCollections.getReversed
|
public static <T> List<T> getReversed(Collection<T> collection) {
List<T> reversedList = new ArrayList<>(collection);
Collections.reverse(reversedList);
return reversedList;
}
|
java
|
public static <T> List<T> getReversed(Collection<T> collection) {
List<T> reversedList = new ArrayList<>(collection);
Collections.reverse(reversedList);
return reversedList;
}
|
[
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getReversed",
"(",
"Collection",
"<",
"T",
">",
"collection",
")",
"{",
"List",
"<",
"T",
">",
"reversedList",
"=",
"new",
"ArrayList",
"<>",
"(",
"collection",
")",
";",
"Collections",
".",
"reverse",
"(",
"reversedList",
")",
";",
"return",
"reversedList",
";",
"}"
] |
Gets reversed.
@param <T> the type parameter
@param collection the collection
@return the reversed
|
[
"Gets",
"reversed",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMCollections.java#L190-L194
|
155,675
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMCollections.java
|
JMCollections.transformList
|
public static <T, R> List<R> transformList(Collection<T> collection,
Function<T, R> transformFunction) {
return collection.stream().map(transformFunction).collect(toList());
}
|
java
|
public static <T, R> List<R> transformList(Collection<T> collection,
Function<T, R> transformFunction) {
return collection.stream().map(transformFunction).collect(toList());
}
|
[
"public",
"static",
"<",
"T",
",",
"R",
">",
"List",
"<",
"R",
">",
"transformList",
"(",
"Collection",
"<",
"T",
">",
"collection",
",",
"Function",
"<",
"T",
",",
"R",
">",
"transformFunction",
")",
"{",
"return",
"collection",
".",
"stream",
"(",
")",
".",
"map",
"(",
"transformFunction",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"}"
] |
Transform list list.
@param <T> the type parameter
@param <R> the type parameter
@param collection the collection
@param transformFunction the transform function
@return the list
|
[
"Transform",
"list",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMCollections.java#L205-L208
|
155,676
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMCollections.java
|
JMCollections.addAndGet
|
public static <T> T addAndGet(Collection<T> collection, T item) {
collection.add(item);
return item;
}
|
java
|
public static <T> T addAndGet(Collection<T> collection, T item) {
collection.add(item);
return item;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"addAndGet",
"(",
"Collection",
"<",
"T",
">",
"collection",
",",
"T",
"item",
")",
"{",
"collection",
".",
"add",
"(",
"item",
")",
";",
"return",
"item",
";",
"}"
] |
Add and get t.
@param <T> the type parameter
@param collection the collection
@param item the item
@return the t
|
[
"Add",
"and",
"get",
"t",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMCollections.java#L277-L280
|
155,677
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/datastructure/JMCollections.java
|
JMCollections.buildNewList
|
public static <T, R> List<R> buildNewList(Collection<T> collection,
Function<T, R> transformFunction) {
return collection.stream().map(transformFunction)
.collect(Collectors.toList());
}
|
java
|
public static <T, R> List<R> buildNewList(Collection<T> collection,
Function<T, R> transformFunction) {
return collection.stream().map(transformFunction)
.collect(Collectors.toList());
}
|
[
"public",
"static",
"<",
"T",
",",
"R",
">",
"List",
"<",
"R",
">",
"buildNewList",
"(",
"Collection",
"<",
"T",
">",
"collection",
",",
"Function",
"<",
"T",
",",
"R",
">",
"transformFunction",
")",
"{",
"return",
"collection",
".",
"stream",
"(",
")",
".",
"map",
"(",
"transformFunction",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] |
Build new list list.
@param <T> the type parameter
@param <R> the type parameter
@param collection the collection
@param transformFunction the transform function
@return the list
|
[
"Build",
"new",
"list",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/datastructure/JMCollections.java#L291-L295
|
155,678
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/CachedDirectoryLookupService.java
|
CachedDirectoryLookupService.initCacheSyncTask
|
private void initCacheSyncTask(){
int delay = getServiceDirectoryConfig().getInt(
SD_API_CACHE_SYNC_DELAY_PROPERTY,
SD_API_CACHE_SYNC_DELAY_DEFAULT);
int interval = getServiceDirectoryConfig().getInt(
SD_API_CACHE_SYNC_INTERVAL_PROPERTY,
SD_API_CACHE_SYNC_INTERVAL_DEFAULT);
syncService.scheduleWithFixedDelay(new CacheSyncTask(),
delay, interval, TimeUnit.SECONDS);
}
|
java
|
private void initCacheSyncTask(){
int delay = getServiceDirectoryConfig().getInt(
SD_API_CACHE_SYNC_DELAY_PROPERTY,
SD_API_CACHE_SYNC_DELAY_DEFAULT);
int interval = getServiceDirectoryConfig().getInt(
SD_API_CACHE_SYNC_INTERVAL_PROPERTY,
SD_API_CACHE_SYNC_INTERVAL_DEFAULT);
syncService.scheduleWithFixedDelay(new CacheSyncTask(),
delay, interval, TimeUnit.SECONDS);
}
|
[
"private",
"void",
"initCacheSyncTask",
"(",
")",
"{",
"int",
"delay",
"=",
"getServiceDirectoryConfig",
"(",
")",
".",
"getInt",
"(",
"SD_API_CACHE_SYNC_DELAY_PROPERTY",
",",
"SD_API_CACHE_SYNC_DELAY_DEFAULT",
")",
";",
"int",
"interval",
"=",
"getServiceDirectoryConfig",
"(",
")",
".",
"getInt",
"(",
"SD_API_CACHE_SYNC_INTERVAL_PROPERTY",
",",
"SD_API_CACHE_SYNC_INTERVAL_DEFAULT",
")",
";",
"syncService",
".",
"scheduleWithFixedDelay",
"(",
"new",
"CacheSyncTask",
"(",
")",
",",
"delay",
",",
"interval",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}"
] |
initialization of the CacheSyncTask
|
[
"initialization",
"of",
"the",
"CacheSyncTask"
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/CachedDirectoryLookupService.java#L205-L215
|
155,679
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/CachedDirectoryLookupService.java
|
CachedDirectoryLookupService.getAllServicesForSync
|
private List<ModelService> getAllServicesForSync(){
List<ModelService> allServices = new ArrayList<ModelService>();
allServices.addAll(this.cache.values());
List<ModelService> syncServices = new ArrayList<ModelService>();
for(ModelService service : allServices){
ModelService syncService = new ModelService(service.getName(), service.getId(), service.getCreateTime());
Date modifiedTime = service.getModifiedTime();
if (modifiedTime != null) {
syncService.setModifiedTime(modifiedTime);
}
syncServices.add(syncService);
}
return syncServices;
}
|
java
|
private List<ModelService> getAllServicesForSync(){
List<ModelService> allServices = new ArrayList<ModelService>();
allServices.addAll(this.cache.values());
List<ModelService> syncServices = new ArrayList<ModelService>();
for(ModelService service : allServices){
ModelService syncService = new ModelService(service.getName(), service.getId(), service.getCreateTime());
Date modifiedTime = service.getModifiedTime();
if (modifiedTime != null) {
syncService.setModifiedTime(modifiedTime);
}
syncServices.add(syncService);
}
return syncServices;
}
|
[
"private",
"List",
"<",
"ModelService",
">",
"getAllServicesForSync",
"(",
")",
"{",
"List",
"<",
"ModelService",
">",
"allServices",
"=",
"new",
"ArrayList",
"<",
"ModelService",
">",
"(",
")",
";",
"allServices",
".",
"addAll",
"(",
"this",
".",
"cache",
".",
"values",
"(",
")",
")",
";",
"List",
"<",
"ModelService",
">",
"syncServices",
"=",
"new",
"ArrayList",
"<",
"ModelService",
">",
"(",
")",
";",
"for",
"(",
"ModelService",
"service",
":",
"allServices",
")",
"{",
"ModelService",
"syncService",
"=",
"new",
"ModelService",
"(",
"service",
".",
"getName",
"(",
")",
",",
"service",
".",
"getId",
"(",
")",
",",
"service",
".",
"getCreateTime",
"(",
")",
")",
";",
"Date",
"modifiedTime",
"=",
"service",
".",
"getModifiedTime",
"(",
")",
";",
"if",
"(",
"modifiedTime",
"!=",
"null",
")",
"{",
"syncService",
".",
"setModifiedTime",
"(",
"modifiedTime",
")",
";",
"}",
"syncServices",
".",
"add",
"(",
"syncService",
")",
";",
"}",
"return",
"syncServices",
";",
"}"
] |
Get the ModelService List for cache sync.
The ModelService doesn't contain the referenced ModelServiceInstances.
@return
the ModelService List.
|
[
"Get",
"the",
"ModelService",
"List",
"for",
"cache",
"sync",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/CachedDirectoryLookupService.java#L249-L263
|
155,680
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/CachedDirectoryLookupService.java
|
CachedDirectoryLookupService.getAllMetadataKeysForSync
|
private List<ModelMetadataKey> getAllMetadataKeysForSync(){
List<ModelMetadataKey> allKeys = new ArrayList<ModelMetadataKey>();
allKeys.addAll(this.metaKeyCache.values());
List<ModelMetadataKey> syncKeys = new ArrayList<ModelMetadataKey>();
for(ModelMetadataKey service : allKeys){
ModelMetadataKey syncKey = new ModelMetadataKey(service.getName(), service.getId(), service.getModifiedTime(), service.getCreateTime());
syncKeys.add(syncKey);
}
return syncKeys;
}
|
java
|
private List<ModelMetadataKey> getAllMetadataKeysForSync(){
List<ModelMetadataKey> allKeys = new ArrayList<ModelMetadataKey>();
allKeys.addAll(this.metaKeyCache.values());
List<ModelMetadataKey> syncKeys = new ArrayList<ModelMetadataKey>();
for(ModelMetadataKey service : allKeys){
ModelMetadataKey syncKey = new ModelMetadataKey(service.getName(), service.getId(), service.getModifiedTime(), service.getCreateTime());
syncKeys.add(syncKey);
}
return syncKeys;
}
|
[
"private",
"List",
"<",
"ModelMetadataKey",
">",
"getAllMetadataKeysForSync",
"(",
")",
"{",
"List",
"<",
"ModelMetadataKey",
">",
"allKeys",
"=",
"new",
"ArrayList",
"<",
"ModelMetadataKey",
">",
"(",
")",
";",
"allKeys",
".",
"addAll",
"(",
"this",
".",
"metaKeyCache",
".",
"values",
"(",
")",
")",
";",
"List",
"<",
"ModelMetadataKey",
">",
"syncKeys",
"=",
"new",
"ArrayList",
"<",
"ModelMetadataKey",
">",
"(",
")",
";",
"for",
"(",
"ModelMetadataKey",
"service",
":",
"allKeys",
")",
"{",
"ModelMetadataKey",
"syncKey",
"=",
"new",
"ModelMetadataKey",
"(",
"service",
".",
"getName",
"(",
")",
",",
"service",
".",
"getId",
"(",
")",
",",
"service",
".",
"getModifiedTime",
"(",
")",
",",
"service",
".",
"getCreateTime",
"(",
")",
")",
";",
"syncKeys",
".",
"add",
"(",
"syncKey",
")",
";",
"}",
"return",
"syncKeys",
";",
"}"
] |
Get the ModelMetadataKey List for cache sync.
The ModelMetadataKey doesn't contain the referenced ModelServiceInstances.
@return
the ModelMetadataKey List.
|
[
"Get",
"the",
"ModelMetadataKey",
"List",
"for",
"cache",
"sync",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/CachedDirectoryLookupService.java#L273-L282
|
155,681
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/CachedDirectoryLookupService.java
|
CachedDirectoryLookupService.getChangedMetadataKeys
|
private Map<String, OperationResult<ModelMetadataKey>> getChangedMetadataKeys(Map<String, ModelMetadataKey> keyMap){
return this.getDirectoryServiceClient().getChangedMetadataKeys(keyMap);
}
|
java
|
private Map<String, OperationResult<ModelMetadataKey>> getChangedMetadataKeys(Map<String, ModelMetadataKey> keyMap){
return this.getDirectoryServiceClient().getChangedMetadataKeys(keyMap);
}
|
[
"private",
"Map",
"<",
"String",
",",
"OperationResult",
"<",
"ModelMetadataKey",
">",
">",
"getChangedMetadataKeys",
"(",
"Map",
"<",
"String",
",",
"ModelMetadataKey",
">",
"keyMap",
")",
"{",
"return",
"this",
".",
"getDirectoryServiceClient",
"(",
")",
".",
"getChangedMetadataKeys",
"(",
"keyMap",
")",
";",
"}"
] |
Get the changed list for the MetadataKey from the server.
@param keyMap
the MetadataKey list.
@return
the ModelMetadataKey list that has been changed.
|
[
"Get",
"the",
"changed",
"list",
"for",
"the",
"MetadataKey",
"from",
"the",
"server",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/CachedDirectoryLookupService.java#L292-L294
|
155,682
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/CachedDirectoryLookupService.java
|
CachedDirectoryLookupService.getChangedServices
|
private Map<String, OperationResult<ModelService>> getChangedServices(Map<String, ModelService> serviceMap){
return this.getDirectoryServiceClient().getChangedServices(serviceMap);
}
|
java
|
private Map<String, OperationResult<ModelService>> getChangedServices(Map<String, ModelService> serviceMap){
return this.getDirectoryServiceClient().getChangedServices(serviceMap);
}
|
[
"private",
"Map",
"<",
"String",
",",
"OperationResult",
"<",
"ModelService",
">",
">",
"getChangedServices",
"(",
"Map",
"<",
"String",
",",
"ModelService",
">",
"serviceMap",
")",
"{",
"return",
"this",
".",
"getDirectoryServiceClient",
"(",
")",
".",
"getChangedServices",
"(",
"serviceMap",
")",
";",
"}"
] |
Get the changed Services list from the server.
@param serviceMap
the Service list.
@return
the Service list that has been changed.
@throws ServiceException
|
[
"Get",
"the",
"changed",
"Services",
"list",
"from",
"the",
"server",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/CachedDirectoryLookupService.java#L305-L307
|
155,683
|
G2G3Digital/substeps-framework
|
core/src/main/java/com/technophobia/substeps/runner/TagManager.java
|
TagManager.acceptTaggedScenario
|
public boolean acceptTaggedScenario(final Set<String> tags) {
if (acceptAll || (acceptedTags.isEmpty() && excludedTags.isEmpty())) {
return true;
} else if (acceptedTags.size() > 0 && (tags == null || tags.isEmpty())) {
return false;
} else if (containsAny(tags, excludedTags)) {
return false;
} else {
return tags == null || tags.containsAll(acceptedTags);
}
}
|
java
|
public boolean acceptTaggedScenario(final Set<String> tags) {
if (acceptAll || (acceptedTags.isEmpty() && excludedTags.isEmpty())) {
return true;
} else if (acceptedTags.size() > 0 && (tags == null || tags.isEmpty())) {
return false;
} else if (containsAny(tags, excludedTags)) {
return false;
} else {
return tags == null || tags.containsAll(acceptedTags);
}
}
|
[
"public",
"boolean",
"acceptTaggedScenario",
"(",
"final",
"Set",
"<",
"String",
">",
"tags",
")",
"{",
"if",
"(",
"acceptAll",
"||",
"(",
"acceptedTags",
".",
"isEmpty",
"(",
")",
"&&",
"excludedTags",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"acceptedTags",
".",
"size",
"(",
")",
">",
"0",
"&&",
"(",
"tags",
"==",
"null",
"||",
"tags",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"containsAny",
"(",
"tags",
",",
"excludedTags",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"tags",
"==",
"null",
"||",
"tags",
".",
"containsAll",
"(",
"acceptedTags",
")",
";",
"}",
"}"
] |
passed a set of tags, works out if we should run this feature or not
|
[
"passed",
"a",
"set",
"of",
"tags",
"works",
"out",
"if",
"we",
"should",
"run",
"this",
"feature",
"or",
"not"
] |
c1ec6487e1673a7dae54b5e7b62a96f602cd280a
|
https://github.com/G2G3Digital/substeps-framework/blob/c1ec6487e1673a7dae54b5e7b62a96f602cd280a/core/src/main/java/com/technophobia/substeps/runner/TagManager.java#L134-L145
|
155,684
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
|
ParserRegistry.getParsersAsListModel
|
public static ListBoxModel getParsersAsListModel() {
ListBoxModel items = new ListBoxModel();
for (ParserDescription parser : getAvailableParsers()) {
items.add(parser.getName(), parser.getGroup());
}
return items;
}
|
java
|
public static ListBoxModel getParsersAsListModel() {
ListBoxModel items = new ListBoxModel();
for (ParserDescription parser : getAvailableParsers()) {
items.add(parser.getName(), parser.getGroup());
}
return items;
}
|
[
"public",
"static",
"ListBoxModel",
"getParsersAsListModel",
"(",
")",
"{",
"ListBoxModel",
"items",
"=",
"new",
"ListBoxModel",
"(",
")",
";",
"for",
"(",
"ParserDescription",
"parser",
":",
"getAvailableParsers",
"(",
")",
")",
"{",
"items",
".",
"add",
"(",
"parser",
".",
"getName",
"(",
")",
",",
"parser",
".",
"getGroup",
"(",
")",
")",
";",
"}",
"return",
"items",
";",
"}"
] |
Returns the available parsers as a list model.
@return the model of the list box
|
[
"Returns",
"the",
"available",
"parsers",
"as",
"a",
"list",
"model",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java#L83-L89
|
155,685
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
|
ParserRegistry.getAvailableParsers
|
public static List<ParserDescription> getAvailableParsers() {
Set<String> groups = Sets.newHashSet();
for (AbstractWarningsParser parser : getAllParsers()) {
groups.add(parser.getGroup());
}
List<ParserDescription> sorted = Lists.newArrayList();
for (String group : groups) {
sorted.add(new ParserDescription(group, getParser(group).getParserName()));
}
Collections.sort(sorted);
return sorted;
}
|
java
|
public static List<ParserDescription> getAvailableParsers() {
Set<String> groups = Sets.newHashSet();
for (AbstractWarningsParser parser : getAllParsers()) {
groups.add(parser.getGroup());
}
List<ParserDescription> sorted = Lists.newArrayList();
for (String group : groups) {
sorted.add(new ParserDescription(group, getParser(group).getParserName()));
}
Collections.sort(sorted);
return sorted;
}
|
[
"public",
"static",
"List",
"<",
"ParserDescription",
">",
"getAvailableParsers",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"groups",
"=",
"Sets",
".",
"newHashSet",
"(",
")",
";",
"for",
"(",
"AbstractWarningsParser",
"parser",
":",
"getAllParsers",
"(",
")",
")",
"{",
"groups",
".",
"add",
"(",
"parser",
".",
"getGroup",
"(",
")",
")",
";",
"}",
"List",
"<",
"ParserDescription",
">",
"sorted",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"for",
"(",
"String",
"group",
":",
"groups",
")",
"{",
"sorted",
".",
"add",
"(",
"new",
"ParserDescription",
"(",
"group",
",",
"getParser",
"(",
"group",
")",
".",
"getParserName",
"(",
")",
")",
")",
";",
"}",
"Collections",
".",
"sort",
"(",
"sorted",
")",
";",
"return",
"sorted",
";",
"}"
] |
Returns all available parsers groups, sorted alphabetically.
@return all available parser names
|
[
"Returns",
"all",
"available",
"parsers",
"groups",
"sorted",
"alphabetically",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java#L96-L108
|
155,686
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
|
ParserRegistry.getParser
|
public static AbstractWarningsParser getParser(@CheckForNull final String group) {
if (StringUtils.isEmpty(group)) {
return new NullWarnigsParser("NULL");
}
List<AbstractWarningsParser> parsers = ParserRegistry.getParsers(group);
if (parsers.isEmpty()) {
return new NullWarnigsParser(group);
}
else {
return parsers.get(0);
}
}
|
java
|
public static AbstractWarningsParser getParser(@CheckForNull final String group) {
if (StringUtils.isEmpty(group)) {
return new NullWarnigsParser("NULL");
}
List<AbstractWarningsParser> parsers = ParserRegistry.getParsers(group);
if (parsers.isEmpty()) {
return new NullWarnigsParser(group);
}
else {
return parsers.get(0);
}
}
|
[
"public",
"static",
"AbstractWarningsParser",
"getParser",
"(",
"@",
"CheckForNull",
"final",
"String",
"group",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"group",
")",
")",
"{",
"return",
"new",
"NullWarnigsParser",
"(",
"\"NULL\"",
")",
";",
"}",
"List",
"<",
"AbstractWarningsParser",
">",
"parsers",
"=",
"ParserRegistry",
".",
"getParsers",
"(",
"group",
")",
";",
"if",
"(",
"parsers",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"new",
"NullWarnigsParser",
"(",
"group",
")",
";",
"}",
"else",
"{",
"return",
"parsers",
".",
"get",
"(",
"0",
")",
";",
"}",
"}"
] |
Returns a parser for the specified group. If there is no such parser,
then a null object is returned.
@param group
the parser group
@return the parser
|
[
"Returns",
"a",
"parser",
"for",
"the",
"specified",
"group",
".",
"If",
"there",
"is",
"no",
"such",
"parser",
"then",
"a",
"null",
"object",
"is",
"returned",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java#L118-L130
|
155,687
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
|
ParserRegistry.getUrl
|
public static int getUrl(final String group) {
List<AbstractWarningsParser> allParsers = getAllParsers();
for (int number = 0; number < allParsers.size(); number++) {
if (allParsers.get(number).isInGroup(group)) {
return number;
}
}
throw new NoSuchElementException("No parser found for group: " + group);
}
|
java
|
public static int getUrl(final String group) {
List<AbstractWarningsParser> allParsers = getAllParsers();
for (int number = 0; number < allParsers.size(); number++) {
if (allParsers.get(number).isInGroup(group)) {
return number;
}
}
throw new NoSuchElementException("No parser found for group: " + group);
}
|
[
"public",
"static",
"int",
"getUrl",
"(",
"final",
"String",
"group",
")",
"{",
"List",
"<",
"AbstractWarningsParser",
">",
"allParsers",
"=",
"getAllParsers",
"(",
")",
";",
"for",
"(",
"int",
"number",
"=",
"0",
";",
"number",
"<",
"allParsers",
".",
"size",
"(",
")",
";",
"number",
"++",
")",
"{",
"if",
"(",
"allParsers",
".",
"get",
"(",
"number",
")",
".",
"isInGroup",
"(",
"group",
")",
")",
"{",
"return",
"number",
";",
"}",
"}",
"throw",
"new",
"NoSuchElementException",
"(",
"\"No parser found for group: \"",
"+",
"group",
")",
";",
"}"
] |
Returns the parser ID which could be used as a URL.
@param group the parser group
@return the ID
|
[
"Returns",
"the",
"parser",
"ID",
"which",
"could",
"be",
"used",
"as",
"a",
"URL",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java#L150-L158
|
155,688
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
|
ParserRegistry.getParsers
|
public static List<AbstractWarningsParser> getParsers(final Collection<String> parserGroups) {
List<AbstractWarningsParser> actualParsers = new ArrayList<AbstractWarningsParser>();
for (String name : parserGroups) {
for (AbstractWarningsParser warningsParser : getAllParsers()) {
if (warningsParser.isInGroup(name)) {
actualParsers.add(warningsParser);
}
}
}
return actualParsers;
}
|
java
|
public static List<AbstractWarningsParser> getParsers(final Collection<String> parserGroups) {
List<AbstractWarningsParser> actualParsers = new ArrayList<AbstractWarningsParser>();
for (String name : parserGroups) {
for (AbstractWarningsParser warningsParser : getAllParsers()) {
if (warningsParser.isInGroup(name)) {
actualParsers.add(warningsParser);
}
}
}
return actualParsers;
}
|
[
"public",
"static",
"List",
"<",
"AbstractWarningsParser",
">",
"getParsers",
"(",
"final",
"Collection",
"<",
"String",
">",
"parserGroups",
")",
"{",
"List",
"<",
"AbstractWarningsParser",
">",
"actualParsers",
"=",
"new",
"ArrayList",
"<",
"AbstractWarningsParser",
">",
"(",
")",
";",
"for",
"(",
"String",
"name",
":",
"parserGroups",
")",
"{",
"for",
"(",
"AbstractWarningsParser",
"warningsParser",
":",
"getAllParsers",
"(",
")",
")",
"{",
"if",
"(",
"warningsParser",
".",
"isInGroup",
"(",
"name",
")",
")",
"{",
"actualParsers",
".",
"add",
"(",
"warningsParser",
")",
";",
"}",
"}",
"}",
"return",
"actualParsers",
";",
"}"
] |
Returns a list of parsers that match the specified names. Note that the
mapping of names to parsers is one to many.
@param parserGroups
the parser names
@return a list of parsers, might be modified by the receiver
|
[
"Returns",
"a",
"list",
"of",
"parsers",
"that",
"match",
"the",
"specified",
"names",
".",
"Note",
"that",
"the",
"mapping",
"of",
"names",
"to",
"parsers",
"is",
"one",
"to",
"many",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java#L168-L178
|
155,689
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
|
ParserRegistry.getAllParsers
|
private static List<AbstractWarningsParser> getAllParsers() {
List<AbstractWarningsParser> parsers = Lists.newArrayList();
parsers.add(new MsBuildParser(Messages._Warnings_PCLint_ParserName(),
Messages._Warnings_PCLint_LinkName(),
Messages._Warnings_PCLint_TrendName()));
if (PluginDescriptor.isPluginInstalled("violations")) {
ViolationsRegistry.addParsers(parsers);
}
Iterable<GroovyParser> parserDescriptions = getDynamicParserDescriptions();
parsers.addAll(getDynamicParsers(parserDescriptions));
parsers.addAll(all());
return ImmutableList.copyOf(parsers);
}
|
java
|
private static List<AbstractWarningsParser> getAllParsers() {
List<AbstractWarningsParser> parsers = Lists.newArrayList();
parsers.add(new MsBuildParser(Messages._Warnings_PCLint_ParserName(),
Messages._Warnings_PCLint_LinkName(),
Messages._Warnings_PCLint_TrendName()));
if (PluginDescriptor.isPluginInstalled("violations")) {
ViolationsRegistry.addParsers(parsers);
}
Iterable<GroovyParser> parserDescriptions = getDynamicParserDescriptions();
parsers.addAll(getDynamicParsers(parserDescriptions));
parsers.addAll(all());
return ImmutableList.copyOf(parsers);
}
|
[
"private",
"static",
"List",
"<",
"AbstractWarningsParser",
">",
"getAllParsers",
"(",
")",
"{",
"List",
"<",
"AbstractWarningsParser",
">",
"parsers",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"parsers",
".",
"add",
"(",
"new",
"MsBuildParser",
"(",
"Messages",
".",
"_Warnings_PCLint_ParserName",
"(",
")",
",",
"Messages",
".",
"_Warnings_PCLint_LinkName",
"(",
")",
",",
"Messages",
".",
"_Warnings_PCLint_TrendName",
"(",
")",
")",
")",
";",
"if",
"(",
"PluginDescriptor",
".",
"isPluginInstalled",
"(",
"\"violations\"",
")",
")",
"{",
"ViolationsRegistry",
".",
"addParsers",
"(",
"parsers",
")",
";",
"}",
"Iterable",
"<",
"GroovyParser",
">",
"parserDescriptions",
"=",
"getDynamicParserDescriptions",
"(",
")",
";",
"parsers",
".",
"addAll",
"(",
"getDynamicParsers",
"(",
"parserDescriptions",
")",
")",
";",
"parsers",
".",
"addAll",
"(",
"all",
"(",
")",
")",
";",
"return",
"ImmutableList",
".",
"copyOf",
"(",
"parsers",
")",
";",
"}"
] |
Returns all available parsers. Parsers are automatically detected using
the extension point mechanism.
@return all available parsers
|
[
"Returns",
"all",
"available",
"parsers",
".",
"Parsers",
"are",
"automatically",
"detected",
"using",
"the",
"extension",
"point",
"mechanism",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java#L197-L211
|
155,690
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
|
ParserRegistry.applyExcludeFilter
|
private Set<FileAnnotation> applyExcludeFilter(final Set<FileAnnotation> allAnnotations) {
Set<FileAnnotation> includedAnnotations;
if (includePatterns.isEmpty()) {
includedAnnotations = allAnnotations;
}
else {
includedAnnotations = Sets.newHashSet();
for (FileAnnotation annotation : allAnnotations) {
for (Pattern include : includePatterns) {
if (include.matcher(annotation.getFileName()).matches()) {
includedAnnotations.add(annotation);
}
}
}
}
if (excludePatterns.isEmpty()) {
return includedAnnotations;
}
else {
Set<FileAnnotation> excludedAnnotations = Sets.newHashSet(includedAnnotations);
for (FileAnnotation annotation : includedAnnotations) {
for (Pattern exclude : excludePatterns) {
if (exclude.matcher(annotation.getFileName()).matches()) {
excludedAnnotations.remove(annotation);
}
}
}
return excludedAnnotations;
}
}
|
java
|
private Set<FileAnnotation> applyExcludeFilter(final Set<FileAnnotation> allAnnotations) {
Set<FileAnnotation> includedAnnotations;
if (includePatterns.isEmpty()) {
includedAnnotations = allAnnotations;
}
else {
includedAnnotations = Sets.newHashSet();
for (FileAnnotation annotation : allAnnotations) {
for (Pattern include : includePatterns) {
if (include.matcher(annotation.getFileName()).matches()) {
includedAnnotations.add(annotation);
}
}
}
}
if (excludePatterns.isEmpty()) {
return includedAnnotations;
}
else {
Set<FileAnnotation> excludedAnnotations = Sets.newHashSet(includedAnnotations);
for (FileAnnotation annotation : includedAnnotations) {
for (Pattern exclude : excludePatterns) {
if (exclude.matcher(annotation.getFileName()).matches()) {
excludedAnnotations.remove(annotation);
}
}
}
return excludedAnnotations;
}
}
|
[
"private",
"Set",
"<",
"FileAnnotation",
">",
"applyExcludeFilter",
"(",
"final",
"Set",
"<",
"FileAnnotation",
">",
"allAnnotations",
")",
"{",
"Set",
"<",
"FileAnnotation",
">",
"includedAnnotations",
";",
"if",
"(",
"includePatterns",
".",
"isEmpty",
"(",
")",
")",
"{",
"includedAnnotations",
"=",
"allAnnotations",
";",
"}",
"else",
"{",
"includedAnnotations",
"=",
"Sets",
".",
"newHashSet",
"(",
")",
";",
"for",
"(",
"FileAnnotation",
"annotation",
":",
"allAnnotations",
")",
"{",
"for",
"(",
"Pattern",
"include",
":",
"includePatterns",
")",
"{",
"if",
"(",
"include",
".",
"matcher",
"(",
"annotation",
".",
"getFileName",
"(",
")",
")",
".",
"matches",
"(",
")",
")",
"{",
"includedAnnotations",
".",
"add",
"(",
"annotation",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"excludePatterns",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"includedAnnotations",
";",
"}",
"else",
"{",
"Set",
"<",
"FileAnnotation",
">",
"excludedAnnotations",
"=",
"Sets",
".",
"newHashSet",
"(",
"includedAnnotations",
")",
";",
"for",
"(",
"FileAnnotation",
"annotation",
":",
"includedAnnotations",
")",
"{",
"for",
"(",
"Pattern",
"exclude",
":",
"excludePatterns",
")",
"{",
"if",
"(",
"exclude",
".",
"matcher",
"(",
"annotation",
".",
"getFileName",
"(",
")",
")",
".",
"matches",
"(",
")",
")",
"{",
"excludedAnnotations",
".",
"remove",
"(",
"annotation",
")",
";",
"}",
"}",
"}",
"return",
"excludedAnnotations",
";",
"}",
"}"
] |
Applies the exclude filter to the found annotations.
@param allAnnotations
all annotations
@return the filtered annotations if there is a filter defined
|
[
"Applies",
"the",
"exclude",
"filter",
"to",
"the",
"found",
"annotations",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java#L353-L382
|
155,691
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
|
ParserRegistry.createReader
|
@edu.umd.cs.findbugs.annotations.SuppressWarnings("OBL")
protected Reader createReader(final File file) throws FileNotFoundException {
return createReader(new FileInputStream(file));
}
|
java
|
@edu.umd.cs.findbugs.annotations.SuppressWarnings("OBL")
protected Reader createReader(final File file) throws FileNotFoundException {
return createReader(new FileInputStream(file));
}
|
[
"@",
"edu",
".",
"umd",
".",
"cs",
".",
"findbugs",
".",
"annotations",
".",
"SuppressWarnings",
"(",
"\"OBL\"",
")",
"protected",
"Reader",
"createReader",
"(",
"final",
"File",
"file",
")",
"throws",
"FileNotFoundException",
"{",
"return",
"createReader",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
")",
";",
"}"
] |
Creates a reader from the specified file. Uses the defined character set to
read the content of the input stream.
@param file the file
@return the reader
@throws FileNotFoundException if the file does not exist
|
[
"Creates",
"a",
"reader",
"from",
"the",
"specified",
"file",
".",
"Uses",
"the",
"defined",
"character",
"set",
"to",
"read",
"the",
"content",
"of",
"the",
"input",
"stream",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java#L392-L395
|
155,692
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/io/HtmlNotebookOutput.java
|
HtmlNotebookOutput.create
|
public static com.simiacryptus.util.io.HtmlNotebookOutput create(final File parentDirectory) throws FileNotFoundException {
@javax.annotation.Nonnull final FileOutputStream out = new FileOutputStream(new File(parentDirectory, "index.html"));
return new com.simiacryptus.util.io.HtmlNotebookOutput(parentDirectory, out) {
@Override
public void close() throws IOException {
out.close();
}
};
}
|
java
|
public static com.simiacryptus.util.io.HtmlNotebookOutput create(final File parentDirectory) throws FileNotFoundException {
@javax.annotation.Nonnull final FileOutputStream out = new FileOutputStream(new File(parentDirectory, "index.html"));
return new com.simiacryptus.util.io.HtmlNotebookOutput(parentDirectory, out) {
@Override
public void close() throws IOException {
out.close();
}
};
}
|
[
"public",
"static",
"com",
".",
"simiacryptus",
".",
"util",
".",
"io",
".",
"HtmlNotebookOutput",
"create",
"(",
"final",
"File",
"parentDirectory",
")",
"throws",
"FileNotFoundException",
"{",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"FileOutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"new",
"File",
"(",
"parentDirectory",
",",
"\"index.html\"",
")",
")",
";",
"return",
"new",
"com",
".",
"simiacryptus",
".",
"util",
".",
"io",
".",
"HtmlNotebookOutput",
"(",
"parentDirectory",
",",
"out",
")",
"{",
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
";",
"}"
] |
Create html notebook output.
@param parentDirectory the parent directory
@return the html notebook output
@throws FileNotFoundException the file not found exception
|
[
"Create",
"html",
"notebook",
"output",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/io/HtmlNotebookOutput.java#L96-L104
|
155,693
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/io/HtmlNotebookOutput.java
|
HtmlNotebookOutput.setSourceRoot
|
@javax.annotation.Nonnull
public com.simiacryptus.util.io.HtmlNotebookOutput setSourceRoot(final String sourceRoot) {
this.sourceRoot = sourceRoot;
return this;
}
|
java
|
@javax.annotation.Nonnull
public com.simiacryptus.util.io.HtmlNotebookOutput setSourceRoot(final String sourceRoot) {
this.sourceRoot = sourceRoot;
return this;
}
|
[
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"public",
"com",
".",
"simiacryptus",
".",
"util",
".",
"io",
".",
"HtmlNotebookOutput",
"setSourceRoot",
"(",
"final",
"String",
"sourceRoot",
")",
"{",
"this",
".",
"sourceRoot",
"=",
"sourceRoot",
";",
"return",
"this",
";",
"}"
] |
Sets source root.
@param sourceRoot the source root
@return the source root
|
[
"Sets",
"source",
"root",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/io/HtmlNotebookOutput.java#L274-L278
|
155,694
|
PureSolTechnologies/genesis
|
commons.hadoop/src/main/java/com/puresoltechnologies/genesis/commons/hadoop/HadoopClientHelper.java
|
HadoopClientHelper.createConfiguration
|
public static Configuration createConfiguration(File configurationDirectory) {
Configuration hadoopConfiguration = new Configuration();
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/core-site.xml").toString()));
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/hdfs-site.xml").toString()));
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/mapred-site.xml").toString()));
return hadoopConfiguration;
}
|
java
|
public static Configuration createConfiguration(File configurationDirectory) {
Configuration hadoopConfiguration = new Configuration();
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/core-site.xml").toString()));
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/hdfs-site.xml").toString()));
hadoopConfiguration
.addResource(new Path(new File(configurationDirectory, "etc/hadoop/mapred-site.xml").toString()));
return hadoopConfiguration;
}
|
[
"public",
"static",
"Configuration",
"createConfiguration",
"(",
"File",
"configurationDirectory",
")",
"{",
"Configuration",
"hadoopConfiguration",
"=",
"new",
"Configuration",
"(",
")",
";",
"hadoopConfiguration",
".",
"addResource",
"(",
"new",
"Path",
"(",
"new",
"File",
"(",
"configurationDirectory",
",",
"\"etc/hadoop/core-site.xml\"",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"hadoopConfiguration",
".",
"addResource",
"(",
"new",
"Path",
"(",
"new",
"File",
"(",
"configurationDirectory",
",",
"\"etc/hadoop/hdfs-site.xml\"",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"hadoopConfiguration",
".",
"addResource",
"(",
"new",
"Path",
"(",
"new",
"File",
"(",
"configurationDirectory",
",",
"\"etc/hadoop/mapred-site.xml\"",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"return",
"hadoopConfiguration",
";",
"}"
] |
This method provides the default configuration for Hadoop client. The
configuration for the client is looked up in the provided directory. The
Hadoop etc directory is expected there.
@param configurationDirectory
is the directory where Hadoop's etc configuration directory can be
found.
@return A {@link Configuration} object is returned for the client to connect
with.
|
[
"This",
"method",
"provides",
"the",
"default",
"configuration",
"for",
"Hadoop",
"client",
".",
"The",
"configuration",
"for",
"the",
"client",
"is",
"looked",
"up",
"in",
"the",
"provided",
"directory",
".",
"The",
"Hadoop",
"etc",
"directory",
"is",
"expected",
"there",
"."
] |
1031027c5edcfeaad670896802058f78a2f7b159
|
https://github.com/PureSolTechnologies/genesis/blob/1031027c5edcfeaad670896802058f78a2f7b159/commons.hadoop/src/main/java/com/puresoltechnologies/genesis/commons/hadoop/HadoopClientHelper.java#L48-L58
|
155,695
|
PureSolTechnologies/genesis
|
commons.hadoop/src/main/java/com/puresoltechnologies/genesis/commons/hadoop/HadoopClientHelper.java
|
HadoopClientHelper.connect
|
public static FileSystem connect(Properties configuration) throws IOException {
String host = configuration.getProperty("transformator.dfs.host");
String port = configuration.getProperty("transformator.dfs.port");
String hdfsUrl = "hdfs://" + host + ":" + port;
Configuration conf = new Configuration();
conf.set("fs.defaultFS", hdfsUrl);
return FileSystem.get(conf);
}
|
java
|
public static FileSystem connect(Properties configuration) throws IOException {
String host = configuration.getProperty("transformator.dfs.host");
String port = configuration.getProperty("transformator.dfs.port");
String hdfsUrl = "hdfs://" + host + ":" + port;
Configuration conf = new Configuration();
conf.set("fs.defaultFS", hdfsUrl);
return FileSystem.get(conf);
}
|
[
"public",
"static",
"FileSystem",
"connect",
"(",
"Properties",
"configuration",
")",
"throws",
"IOException",
"{",
"String",
"host",
"=",
"configuration",
".",
"getProperty",
"(",
"\"transformator.dfs.host\"",
")",
";",
"String",
"port",
"=",
"configuration",
".",
"getProperty",
"(",
"\"transformator.dfs.port\"",
")",
";",
"String",
"hdfsUrl",
"=",
"\"hdfs://\"",
"+",
"host",
"+",
"\":\"",
"+",
"port",
";",
"Configuration",
"conf",
"=",
"new",
"Configuration",
"(",
")",
";",
"conf",
".",
"set",
"(",
"\"fs.defaultFS\"",
",",
"hdfsUrl",
")",
";",
"return",
"FileSystem",
".",
"get",
"(",
"conf",
")",
";",
"}"
] |
This method connects to Hadoop. The configuration for the client is looked up
in the provided directory. The Hadoop etc directory is expected there.
@param configurationDirectory
is the directory where Hadoop's etc configuration directory can be
found.
@return A {@link FileSystem} object is returned to be used from the client.
@throws IOException
is thrown in cases of unexpected events.
|
[
"This",
"method",
"connects",
"to",
"Hadoop",
".",
"The",
"configuration",
"for",
"the",
"client",
"is",
"looked",
"up",
"in",
"the",
"provided",
"directory",
".",
"The",
"Hadoop",
"etc",
"directory",
"is",
"expected",
"there",
"."
] |
1031027c5edcfeaad670896802058f78a2f7b159
|
https://github.com/PureSolTechnologies/genesis/blob/1031027c5edcfeaad670896802058f78a2f7b159/commons.hadoop/src/main/java/com/puresoltechnologies/genesis/commons/hadoop/HadoopClientHelper.java#L84-L91
|
155,696
|
xmlet/XsdAsmFaster
|
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
|
XsdAsmInterfaces.generateHierarchyAttributeInterfaces
|
private void generateHierarchyAttributeInterfaces(Map<String, List<XsdAttribute>> createdAttributes, ElementHierarchyItem hierarchyInterface, String apiName) {
String interfaceName = hierarchyInterface.getInterfaceName();
List<String> extendedInterfaceList = hierarchyInterface.getInterfaces();
String[] extendedInterfaces = listToArray(extendedInterfaceList, ELEMENT);
ClassWriter classWriter = generateClass(interfaceName, JAVA_OBJECT, extendedInterfaces, getInterfaceSignature(extendedInterfaces, apiName), ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, apiName);
hierarchyInterface.getAttributes().forEach(attribute ->
generateMethodsAndCreateAttribute(createdAttributes, classWriter, attribute, elementTypeDesc, interfaceName, apiName)
);
writeClassToFile(interfaceName, classWriter, apiName);
}
|
java
|
private void generateHierarchyAttributeInterfaces(Map<String, List<XsdAttribute>> createdAttributes, ElementHierarchyItem hierarchyInterface, String apiName) {
String interfaceName = hierarchyInterface.getInterfaceName();
List<String> extendedInterfaceList = hierarchyInterface.getInterfaces();
String[] extendedInterfaces = listToArray(extendedInterfaceList, ELEMENT);
ClassWriter classWriter = generateClass(interfaceName, JAVA_OBJECT, extendedInterfaces, getInterfaceSignature(extendedInterfaces, apiName), ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, apiName);
hierarchyInterface.getAttributes().forEach(attribute ->
generateMethodsAndCreateAttribute(createdAttributes, classWriter, attribute, elementTypeDesc, interfaceName, apiName)
);
writeClassToFile(interfaceName, classWriter, apiName);
}
|
[
"private",
"void",
"generateHierarchyAttributeInterfaces",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"XsdAttribute",
">",
">",
"createdAttributes",
",",
"ElementHierarchyItem",
"hierarchyInterface",
",",
"String",
"apiName",
")",
"{",
"String",
"interfaceName",
"=",
"hierarchyInterface",
".",
"getInterfaceName",
"(",
")",
";",
"List",
"<",
"String",
">",
"extendedInterfaceList",
"=",
"hierarchyInterface",
".",
"getInterfaces",
"(",
")",
";",
"String",
"[",
"]",
"extendedInterfaces",
"=",
"listToArray",
"(",
"extendedInterfaceList",
",",
"ELEMENT",
")",
";",
"ClassWriter",
"classWriter",
"=",
"generateClass",
"(",
"interfaceName",
",",
"JAVA_OBJECT",
",",
"extendedInterfaces",
",",
"getInterfaceSignature",
"(",
"extendedInterfaces",
",",
"apiName",
")",
",",
"ACC_PUBLIC",
"+",
"ACC_ABSTRACT",
"+",
"ACC_INTERFACE",
",",
"apiName",
")",
";",
"hierarchyInterface",
".",
"getAttributes",
"(",
")",
".",
"forEach",
"(",
"attribute",
"->",
"generateMethodsAndCreateAttribute",
"(",
"createdAttributes",
",",
"classWriter",
",",
"attribute",
",",
"elementTypeDesc",
",",
"interfaceName",
",",
"apiName",
")",
")",
";",
"writeClassToFile",
"(",
"interfaceName",
",",
"classWriter",
",",
"apiName",
")",
";",
"}"
] |
Generates all the hierarchy interfaces.
@param createdAttributes Information about the attributes that are already created.
@param hierarchyInterface Information about the hierarchy interface to create.
@param apiName The name of the generated fluent interface.
|
[
"Generates",
"all",
"the",
"hierarchy",
"interfaces",
"."
] |
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
|
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L106-L118
|
155,697
|
xmlet/XsdAsmFaster
|
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
|
XsdAsmInterfaces.generateAttributesGroupInterface
|
private void generateAttributesGroupInterface(Map<String, List<XsdAttribute>> createdAttributes, String attributeGroupName, AttributeHierarchyItem attributeHierarchyItem, String apiName){
String baseClassNameCamelCase = firstToUpper(attributeGroupName);
String[] interfaces = getAttributeGroupObjectInterfaces(attributeHierarchyItem.getParentsName());
StringBuilder signature = getAttributeGroupSignature(interfaces, apiName);
ClassWriter interfaceWriter = generateClass(baseClassNameCamelCase, JAVA_OBJECT, interfaces, signature.toString(), ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, apiName);
attributeHierarchyItem.getOwnElements().forEach(elementAttribute -> {
if (createdAttributes.keySet().stream().anyMatch(createdAttributeName -> createdAttributeName.equalsIgnoreCase(elementAttribute.getName()))){
elementAttribute.setName(elementAttribute.getName() + ATTRIBUTE_CASE_SENSITIVE_DIFFERENCE);
}
generateMethodsAndCreateAttribute(createdAttributes, interfaceWriter, elementAttribute, elementTypeDesc, baseClassNameCamelCase, apiName);
});
writeClassToFile(baseClassNameCamelCase, interfaceWriter, apiName);
}
|
java
|
private void generateAttributesGroupInterface(Map<String, List<XsdAttribute>> createdAttributes, String attributeGroupName, AttributeHierarchyItem attributeHierarchyItem, String apiName){
String baseClassNameCamelCase = firstToUpper(attributeGroupName);
String[] interfaces = getAttributeGroupObjectInterfaces(attributeHierarchyItem.getParentsName());
StringBuilder signature = getAttributeGroupSignature(interfaces, apiName);
ClassWriter interfaceWriter = generateClass(baseClassNameCamelCase, JAVA_OBJECT, interfaces, signature.toString(), ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, apiName);
attributeHierarchyItem.getOwnElements().forEach(elementAttribute -> {
if (createdAttributes.keySet().stream().anyMatch(createdAttributeName -> createdAttributeName.equalsIgnoreCase(elementAttribute.getName()))){
elementAttribute.setName(elementAttribute.getName() + ATTRIBUTE_CASE_SENSITIVE_DIFFERENCE);
}
generateMethodsAndCreateAttribute(createdAttributes, interfaceWriter, elementAttribute, elementTypeDesc, baseClassNameCamelCase, apiName);
});
writeClassToFile(baseClassNameCamelCase, interfaceWriter, apiName);
}
|
[
"private",
"void",
"generateAttributesGroupInterface",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"XsdAttribute",
">",
">",
"createdAttributes",
",",
"String",
"attributeGroupName",
",",
"AttributeHierarchyItem",
"attributeHierarchyItem",
",",
"String",
"apiName",
")",
"{",
"String",
"baseClassNameCamelCase",
"=",
"firstToUpper",
"(",
"attributeGroupName",
")",
";",
"String",
"[",
"]",
"interfaces",
"=",
"getAttributeGroupObjectInterfaces",
"(",
"attributeHierarchyItem",
".",
"getParentsName",
"(",
")",
")",
";",
"StringBuilder",
"signature",
"=",
"getAttributeGroupSignature",
"(",
"interfaces",
",",
"apiName",
")",
";",
"ClassWriter",
"interfaceWriter",
"=",
"generateClass",
"(",
"baseClassNameCamelCase",
",",
"JAVA_OBJECT",
",",
"interfaces",
",",
"signature",
".",
"toString",
"(",
")",
",",
"ACC_PUBLIC",
"+",
"ACC_ABSTRACT",
"+",
"ACC_INTERFACE",
",",
"apiName",
")",
";",
"attributeHierarchyItem",
".",
"getOwnElements",
"(",
")",
".",
"forEach",
"(",
"elementAttribute",
"->",
"{",
"if",
"(",
"createdAttributes",
".",
"keySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"createdAttributeName",
"->",
"createdAttributeName",
".",
"equalsIgnoreCase",
"(",
"elementAttribute",
".",
"getName",
"(",
")",
")",
")",
")",
"{",
"elementAttribute",
".",
"setName",
"(",
"elementAttribute",
".",
"getName",
"(",
")",
"+",
"ATTRIBUTE_CASE_SENSITIVE_DIFFERENCE",
")",
";",
"}",
"generateMethodsAndCreateAttribute",
"(",
"createdAttributes",
",",
"interfaceWriter",
",",
"elementAttribute",
",",
"elementTypeDesc",
",",
"baseClassNameCamelCase",
",",
"apiName",
")",
";",
"}",
")",
";",
"writeClassToFile",
"(",
"baseClassNameCamelCase",
",",
"interfaceWriter",
",",
"apiName",
")",
";",
"}"
] |
Generates an attribute group interface with all the required methods. It uses the information gathered about in
attributeGroupInterfaces.
@param createdAttributes A list with the names of the attribute classes already created.
@param attributeGroupName The interface name.
@param attributeHierarchyItem An object containing information about the methods of this interface and which interface, if any,
this interface extends.
@param apiName The name of the generated fluent interface.
|
[
"Generates",
"an",
"attribute",
"group",
"interface",
"with",
"all",
"the",
"required",
"methods",
".",
"It",
"uses",
"the",
"information",
"gathered",
"about",
"in",
"attributeGroupInterfaces",
"."
] |
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
|
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L150-L166
|
155,698
|
xmlet/XsdAsmFaster
|
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
|
XsdAsmInterfaces.getTypeAttributeGroups
|
private Collection<String> getTypeAttributeGroups(XsdComplexType complexType, Stream<XsdAttributeGroup> extensionAttributeGroups) {
Stream<XsdAttributeGroup> attributeGroups = complexType.getXsdAttributes()
.filter(attribute -> attribute.getParent() instanceof XsdAttributeGroup)
.map(attribute -> (XsdAttributeGroup) attribute.getParent())
.distinct();
attributeGroups = Stream.concat(attributeGroups, extensionAttributeGroups);
attributeGroups = Stream.concat(attributeGroups, complexType.getXsdAttributeGroup());
List<XsdAttributeGroup> attributeGroupList = attributeGroups.distinct().collect(Collectors.toList());
attributeGroupList.forEach(this::addAttributeGroup);
if (!attributeGroupList.isEmpty()){
return getBaseAttributeGroupInterface(complexType.getXsdAttributeGroup().collect(Collectors.toList()));
}
return Collections.emptyList();
}
|
java
|
private Collection<String> getTypeAttributeGroups(XsdComplexType complexType, Stream<XsdAttributeGroup> extensionAttributeGroups) {
Stream<XsdAttributeGroup> attributeGroups = complexType.getXsdAttributes()
.filter(attribute -> attribute.getParent() instanceof XsdAttributeGroup)
.map(attribute -> (XsdAttributeGroup) attribute.getParent())
.distinct();
attributeGroups = Stream.concat(attributeGroups, extensionAttributeGroups);
attributeGroups = Stream.concat(attributeGroups, complexType.getXsdAttributeGroup());
List<XsdAttributeGroup> attributeGroupList = attributeGroups.distinct().collect(Collectors.toList());
attributeGroupList.forEach(this::addAttributeGroup);
if (!attributeGroupList.isEmpty()){
return getBaseAttributeGroupInterface(complexType.getXsdAttributeGroup().collect(Collectors.toList()));
}
return Collections.emptyList();
}
|
[
"private",
"Collection",
"<",
"String",
">",
"getTypeAttributeGroups",
"(",
"XsdComplexType",
"complexType",
",",
"Stream",
"<",
"XsdAttributeGroup",
">",
"extensionAttributeGroups",
")",
"{",
"Stream",
"<",
"XsdAttributeGroup",
">",
"attributeGroups",
"=",
"complexType",
".",
"getXsdAttributes",
"(",
")",
".",
"filter",
"(",
"attribute",
"->",
"attribute",
".",
"getParent",
"(",
")",
"instanceof",
"XsdAttributeGroup",
")",
".",
"map",
"(",
"attribute",
"->",
"(",
"XsdAttributeGroup",
")",
"attribute",
".",
"getParent",
"(",
")",
")",
".",
"distinct",
"(",
")",
";",
"attributeGroups",
"=",
"Stream",
".",
"concat",
"(",
"attributeGroups",
",",
"extensionAttributeGroups",
")",
";",
"attributeGroups",
"=",
"Stream",
".",
"concat",
"(",
"attributeGroups",
",",
"complexType",
".",
"getXsdAttributeGroup",
"(",
")",
")",
";",
"List",
"<",
"XsdAttributeGroup",
">",
"attributeGroupList",
"=",
"attributeGroups",
".",
"distinct",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"attributeGroupList",
".",
"forEach",
"(",
"this",
"::",
"addAttributeGroup",
")",
";",
"if",
"(",
"!",
"attributeGroupList",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"getBaseAttributeGroupInterface",
"(",
"complexType",
".",
"getXsdAttributeGroup",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"}",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}"
] |
Obtains the attribute groups of a given element that are present in its type attribute.
@param complexType The {@link XsdComplexType} object with the type attribute.
@param extensionAttributeGroups A {@link Stream} of {@link XsdAttributeGroup} obtained from {@link XsdExtension}.
@return The names of the attribute groups present in the type attribute.
|
[
"Obtains",
"the",
"attribute",
"groups",
"of",
"a",
"given",
"element",
"that",
"are",
"present",
"in",
"its",
"type",
"attribute",
"."
] |
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
|
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L227-L246
|
155,699
|
xmlet/XsdAsmFaster
|
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
|
XsdAsmInterfaces.getBaseAttributeGroupInterface
|
private List<String> getBaseAttributeGroupInterface(List<XsdAttributeGroup> attributeGroups){
List<XsdAttributeGroup> parents = new ArrayList<>();
attributeGroups.forEach(attributeGroup -> {
XsdAbstractElement parent = attributeGroup.getParent();
if (parent instanceof XsdAttributeGroup && !parents.contains(parent)){
parents.add((XsdAttributeGroup) parent);
}
});
if (attributeGroups.size() == 1 || parents.isEmpty()){
return attributeGroups.stream().map(attributeGroup -> firstToUpper(attributeGroup.getName())).collect(Collectors.toList());
}
return getBaseAttributeGroupInterface(parents);
}
|
java
|
private List<String> getBaseAttributeGroupInterface(List<XsdAttributeGroup> attributeGroups){
List<XsdAttributeGroup> parents = new ArrayList<>();
attributeGroups.forEach(attributeGroup -> {
XsdAbstractElement parent = attributeGroup.getParent();
if (parent instanceof XsdAttributeGroup && !parents.contains(parent)){
parents.add((XsdAttributeGroup) parent);
}
});
if (attributeGroups.size() == 1 || parents.isEmpty()){
return attributeGroups.stream().map(attributeGroup -> firstToUpper(attributeGroup.getName())).collect(Collectors.toList());
}
return getBaseAttributeGroupInterface(parents);
}
|
[
"private",
"List",
"<",
"String",
">",
"getBaseAttributeGroupInterface",
"(",
"List",
"<",
"XsdAttributeGroup",
">",
"attributeGroups",
")",
"{",
"List",
"<",
"XsdAttributeGroup",
">",
"parents",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"attributeGroups",
".",
"forEach",
"(",
"attributeGroup",
"->",
"{",
"XsdAbstractElement",
"parent",
"=",
"attributeGroup",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"parent",
"instanceof",
"XsdAttributeGroup",
"&&",
"!",
"parents",
".",
"contains",
"(",
"parent",
")",
")",
"{",
"parents",
".",
"add",
"(",
"(",
"XsdAttributeGroup",
")",
"parent",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"attributeGroups",
".",
"size",
"(",
")",
"==",
"1",
"||",
"parents",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"attributeGroups",
".",
"stream",
"(",
")",
".",
"map",
"(",
"attributeGroup",
"->",
"firstToUpper",
"(",
"attributeGroup",
".",
"getName",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}",
"return",
"getBaseAttributeGroupInterface",
"(",
"parents",
")",
";",
"}"
] |
Recursively iterates order to define an hierarchy on the attribute group interfaces.
@param attributeGroups The attributeGroups contained in the element.
@return A {@link List} of attribute group interface names.
|
[
"Recursively",
"iterates",
"order",
"to",
"define",
"an",
"hierarchy",
"on",
"the",
"attribute",
"group",
"interfaces",
"."
] |
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
|
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L253-L269
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.