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
12,600
apache/groovy
subprojects/groovy-json/src/main/java/groovy/json/JsonSlurperClassic.java
JsonSlurperClassic.parseArray
private List parseArray(JsonLexer lexer) { List content = new ArrayList(); JsonToken currentToken; for(;;) { currentToken = lexer.nextToken(); if (currentToken == null) { throw new JsonException( "Expected a value on line: " + lexer.getReader().getLine() + ", " + "column: " + lexer.getReader().getColumn() + ".\n" + "But got an unterminated array." ); } if (currentToken.getType() == OPEN_CURLY) { content.add(parseObject(lexer)); } else if (currentToken.getType() == OPEN_BRACKET) { content.add(parseArray(lexer)); } else if (currentToken.getType().ordinal() >= NULL.ordinal()) { content.add(currentToken.getValue()); } else if (currentToken.getType() == CLOSE_BRACKET) { return content; } else { throw new JsonException( "Expected a value, an array, or an object " + "on line: " + currentToken.getStartLine() + ", " + "column: " + currentToken.getStartColumn() + ".\n" + "But got '" + currentToken.getText() + "' instead." ); } currentToken = lexer.nextToken(); if (currentToken == null) { throw new JsonException( "Expected " + CLOSE_BRACKET.getLabel() + " " + "or " + COMMA.getLabel() + " " + "on line: " + lexer.getReader().getLine() + ", " + "column: " + lexer.getReader().getColumn() + ".\n" + "But got an unterminated array." ); } // Expect a comma for an upcoming value // or a closing bracket for the end of the array if (currentToken.getType() == CLOSE_BRACKET) { break; } else if (currentToken.getType() != COMMA) { throw new JsonException( "Expected a value or " + CLOSE_BRACKET.getLabel() + " " + "on line: " + currentToken.getStartLine() + " " + "column: " + currentToken.getStartColumn() + ".\n" + "But got '" + currentToken.getText() + "' instead." ); } } return content; }
java
private List parseArray(JsonLexer lexer) { List content = new ArrayList(); JsonToken currentToken; for(;;) { currentToken = lexer.nextToken(); if (currentToken == null) { throw new JsonException( "Expected a value on line: " + lexer.getReader().getLine() + ", " + "column: " + lexer.getReader().getColumn() + ".\n" + "But got an unterminated array." ); } if (currentToken.getType() == OPEN_CURLY) { content.add(parseObject(lexer)); } else if (currentToken.getType() == OPEN_BRACKET) { content.add(parseArray(lexer)); } else if (currentToken.getType().ordinal() >= NULL.ordinal()) { content.add(currentToken.getValue()); } else if (currentToken.getType() == CLOSE_BRACKET) { return content; } else { throw new JsonException( "Expected a value, an array, or an object " + "on line: " + currentToken.getStartLine() + ", " + "column: " + currentToken.getStartColumn() + ".\n" + "But got '" + currentToken.getText() + "' instead." ); } currentToken = lexer.nextToken(); if (currentToken == null) { throw new JsonException( "Expected " + CLOSE_BRACKET.getLabel() + " " + "or " + COMMA.getLabel() + " " + "on line: " + lexer.getReader().getLine() + ", " + "column: " + lexer.getReader().getColumn() + ".\n" + "But got an unterminated array." ); } // Expect a comma for an upcoming value // or a closing bracket for the end of the array if (currentToken.getType() == CLOSE_BRACKET) { break; } else if (currentToken.getType() != COMMA) { throw new JsonException( "Expected a value or " + CLOSE_BRACKET.getLabel() + " " + "on line: " + currentToken.getStartLine() + " " + "column: " + currentToken.getStartColumn() + ".\n" + "But got '" + currentToken.getText() + "' instead." ); } } return content; }
[ "private", "List", "parseArray", "(", "JsonLexer", "lexer", ")", "{", "List", "content", "=", "new", "ArrayList", "(", ")", ";", "JsonToken", "currentToken", ";", "for", "(", ";", ";", ")", "{", "currentToken", "=", "lexer", ".", "nextToken", "(", ")", ";", "if", "(", "currentToken", "==", "null", ")", "{", "throw", "new", "JsonException", "(", "\"Expected a value on line: \"", "+", "lexer", ".", "getReader", "(", ")", ".", "getLine", "(", ")", "+", "\", \"", "+", "\"column: \"", "+", "lexer", ".", "getReader", "(", ")", ".", "getColumn", "(", ")", "+", "\".\\n\"", "+", "\"But got an unterminated array.\"", ")", ";", "}", "if", "(", "currentToken", ".", "getType", "(", ")", "==", "OPEN_CURLY", ")", "{", "content", ".", "add", "(", "parseObject", "(", "lexer", ")", ")", ";", "}", "else", "if", "(", "currentToken", ".", "getType", "(", ")", "==", "OPEN_BRACKET", ")", "{", "content", ".", "add", "(", "parseArray", "(", "lexer", ")", ")", ";", "}", "else", "if", "(", "currentToken", ".", "getType", "(", ")", ".", "ordinal", "(", ")", ">=", "NULL", ".", "ordinal", "(", ")", ")", "{", "content", ".", "add", "(", "currentToken", ".", "getValue", "(", ")", ")", ";", "}", "else", "if", "(", "currentToken", ".", "getType", "(", ")", "==", "CLOSE_BRACKET", ")", "{", "return", "content", ";", "}", "else", "{", "throw", "new", "JsonException", "(", "\"Expected a value, an array, or an object \"", "+", "\"on line: \"", "+", "currentToken", ".", "getStartLine", "(", ")", "+", "\", \"", "+", "\"column: \"", "+", "currentToken", ".", "getStartColumn", "(", ")", "+", "\".\\n\"", "+", "\"But got '\"", "+", "currentToken", ".", "getText", "(", ")", "+", "\"' instead.\"", ")", ";", "}", "currentToken", "=", "lexer", ".", "nextToken", "(", ")", ";", "if", "(", "currentToken", "==", "null", ")", "{", "throw", "new", "JsonException", "(", "\"Expected \"", "+", "CLOSE_BRACKET", ".", "getLabel", "(", ")", "+", "\" \"", "+", "\"or \"", "+", "COMMA", ".", "getLabel", "(", ")", "+", "\" \"", "+", "\"on line: \"", "+", "lexer", ".", "getReader", "(", ")", ".", "getLine", "(", ")", "+", "\", \"", "+", "\"column: \"", "+", "lexer", ".", "getReader", "(", ")", ".", "getColumn", "(", ")", "+", "\".\\n\"", "+", "\"But got an unterminated array.\"", ")", ";", "}", "// Expect a comma for an upcoming value", "// or a closing bracket for the end of the array", "if", "(", "currentToken", ".", "getType", "(", ")", "==", "CLOSE_BRACKET", ")", "{", "break", ";", "}", "else", "if", "(", "currentToken", ".", "getType", "(", ")", "!=", "COMMA", ")", "{", "throw", "new", "JsonException", "(", "\"Expected a value or \"", "+", "CLOSE_BRACKET", ".", "getLabel", "(", ")", "+", "\" \"", "+", "\"on line: \"", "+", "currentToken", ".", "getStartLine", "(", ")", "+", "\" \"", "+", "\"column: \"", "+", "currentToken", ".", "getStartColumn", "(", ")", "+", "\".\\n\"", "+", "\"But got '\"", "+", "currentToken", ".", "getText", "(", ")", "+", "\"' instead.\"", ")", ";", "}", "}", "return", "content", ";", "}" ]
Parse an array from the lexer @param lexer the lexer @return a list of JSON values
[ "Parse", "an", "array", "from", "the", "lexer" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurperClassic.java#L264-L324
12,601
apache/groovy
src/main/java/org/codehaus/groovy/ast/VariableScope.java
VariableScope.getReferencedClassVariables
public Map<String, Variable> getReferencedClassVariables() { if (referencedClassVariables == Collections.EMPTY_MAP) { return referencedClassVariables; } else { return Collections.unmodifiableMap(referencedClassVariables); } }
java
public Map<String, Variable> getReferencedClassVariables() { if (referencedClassVariables == Collections.EMPTY_MAP) { return referencedClassVariables; } else { return Collections.unmodifiableMap(referencedClassVariables); } }
[ "public", "Map", "<", "String", ",", "Variable", ">", "getReferencedClassVariables", "(", ")", "{", "if", "(", "referencedClassVariables", "==", "Collections", ".", "EMPTY_MAP", ")", "{", "return", "referencedClassVariables", ";", "}", "else", "{", "return", "Collections", ".", "unmodifiableMap", "(", "referencedClassVariables", ")", ";", "}", "}" ]
Gets a map containing the class variables referenced by this scope. This not can not be modified. @return a map containing the class variable references
[ "Gets", "a", "map", "containing", "the", "class", "variables", "referenced", "by", "this", "scope", ".", "This", "not", "can", "not", "be", "modified", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/ast/VariableScope.java#L159-L165
12,602
apache/groovy
src/main/java/org/codehaus/groovy/ast/VariableScope.java
VariableScope.getDeclaredVariables
public Map<String, Variable> getDeclaredVariables() { if (declaredVariables == Collections.EMPTY_MAP) { return declaredVariables; } else { return Collections.unmodifiableMap(declaredVariables); } }
java
public Map<String, Variable> getDeclaredVariables() { if (declaredVariables == Collections.EMPTY_MAP) { return declaredVariables; } else { return Collections.unmodifiableMap(declaredVariables); } }
[ "public", "Map", "<", "String", ",", "Variable", ">", "getDeclaredVariables", "(", ")", "{", "if", "(", "declaredVariables", "==", "Collections", ".", "EMPTY_MAP", ")", "{", "return", "declaredVariables", ";", "}", "else", "{", "return", "Collections", ".", "unmodifiableMap", "(", "declaredVariables", ")", ";", "}", "}" ]
Gets a map containing the variables declared in this scope. This map cannot be modified. @return a map containing the declared variable references
[ "Gets", "a", "map", "containing", "the", "variables", "declared", "in", "this", "scope", ".", "This", "map", "cannot", "be", "modified", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/ast/VariableScope.java#L181-L187
12,603
apache/groovy
src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/LinkedDeque.java
LinkedDeque.unlinkFirst
E unlinkFirst() { final E f = first; final E next = f.getNext(); f.setNext(null); first = next; if (next == null) { last = null; } else { next.setPrevious(null); } return f; }
java
E unlinkFirst() { final E f = first; final E next = f.getNext(); f.setNext(null); first = next; if (next == null) { last = null; } else { next.setPrevious(null); } return f; }
[ "E", "unlinkFirst", "(", ")", "{", "final", "E", "f", "=", "first", ";", "final", "E", "next", "=", "f", ".", "getNext", "(", ")", ";", "f", ".", "setNext", "(", "null", ")", ";", "first", "=", "next", ";", "if", "(", "next", "==", "null", ")", "{", "last", "=", "null", ";", "}", "else", "{", "next", ".", "setPrevious", "(", "null", ")", ";", "}", "return", "f", ";", "}" ]
Unlinks the non-null first element.
[ "Unlinks", "the", "non", "-", "null", "first", "element", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/LinkedDeque.java#L107-L119
12,604
apache/groovy
src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/LinkedDeque.java
LinkedDeque.unlinkLast
E unlinkLast() { final E l = last; final E prev = l.getPrevious(); l.setPrevious(null); last = prev; if (prev == null) { first = null; } else { prev.setNext(null); } return l; }
java
E unlinkLast() { final E l = last; final E prev = l.getPrevious(); l.setPrevious(null); last = prev; if (prev == null) { first = null; } else { prev.setNext(null); } return l; }
[ "E", "unlinkLast", "(", ")", "{", "final", "E", "l", "=", "last", ";", "final", "E", "prev", "=", "l", ".", "getPrevious", "(", ")", ";", "l", ".", "setPrevious", "(", "null", ")", ";", "last", "=", "prev", ";", "if", "(", "prev", "==", "null", ")", "{", "first", "=", "null", ";", "}", "else", "{", "prev", ".", "setNext", "(", "null", ")", ";", "}", "return", "l", ";", "}" ]
Unlinks the non-null last element.
[ "Unlinks", "the", "non", "-", "null", "last", "element", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/apache/groovy/util/concurrentlinkedhashmap/LinkedDeque.java#L122-L133
12,605
apache/groovy
subprojects/groovy-jsr223/src/main/java/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java
GroovyScriptEngineImpl.callGlobal
private Object callGlobal(String name, Object[] args) { return callGlobal(name, args, context); }
java
private Object callGlobal(String name, Object[] args) { return callGlobal(name, args, context); }
[ "private", "Object", "callGlobal", "(", "String", "name", ",", "Object", "[", "]", "args", ")", "{", "return", "callGlobal", "(", "name", ",", "args", ",", "context", ")", ";", "}" ]
call the script global function of the given name
[ "call", "the", "script", "global", "function", "of", "the", "given", "name" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-jsr223/src/main/java/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java#L383-L385
12,606
apache/groovy
subprojects/groovy-jsr223/src/main/java/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java
GroovyScriptEngineImpl.getParentLoader
private static ClassLoader getParentLoader() { // check whether thread context loader can "see" Groovy Script class ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader(); try { Class<?> c = ctxtLoader.loadClass(Script.class.getName()); if (c == Script.class) { return ctxtLoader; } } catch (ClassNotFoundException cnfe) { /* ignore */ } // exception was thrown or we get wrong class return Script.class.getClassLoader(); }
java
private static ClassLoader getParentLoader() { // check whether thread context loader can "see" Groovy Script class ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader(); try { Class<?> c = ctxtLoader.loadClass(Script.class.getName()); if (c == Script.class) { return ctxtLoader; } } catch (ClassNotFoundException cnfe) { /* ignore */ } // exception was thrown or we get wrong class return Script.class.getClassLoader(); }
[ "private", "static", "ClassLoader", "getParentLoader", "(", ")", "{", "// check whether thread context loader can \"see\" Groovy Script class", "ClassLoader", "ctxtLoader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "try", "{", "Class", "<", "?", ">", "c", "=", "ctxtLoader", ".", "loadClass", "(", "Script", ".", "class", ".", "getName", "(", ")", ")", ";", "if", "(", "c", "==", "Script", ".", "class", ")", "{", "return", "ctxtLoader", ";", "}", "}", "catch", "(", "ClassNotFoundException", "cnfe", ")", "{", "/* ignore */", "}", "// exception was thrown or we get wrong class", "return", "Script", ".", "class", ".", "getClassLoader", "(", ")", ";", "}" ]
for GroovyClassLoader instance
[ "for", "GroovyClassLoader", "instance" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-jsr223/src/main/java/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java#L426-L439
12,607
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.dump
public static String dump(Object self) { if (self == null) { return "null"; } StringBuilder buffer = new StringBuilder("<"); Class klass = self.getClass(); buffer.append(klass.getName()); buffer.append("@"); buffer.append(Integer.toHexString(self.hashCode())); boolean groovyObject = self instanceof GroovyObject; /*jes this may be rewritten to use the new getProperties() stuff * but the original pulls out private variables, whereas getProperties() * does not. What's the real use of dump() here? */ while (klass != null) { for (final Field field : klass.getDeclaredFields()) { if ((field.getModifiers() & Modifier.STATIC) == 0) { if (groovyObject && field.getName().equals("metaClass")) { continue; } AccessController.doPrivileged(new PrivilegedAction() { public Object run() { field.setAccessible(true); return null; } }); buffer.append(" "); buffer.append(field.getName()); buffer.append("="); try { buffer.append(InvokerHelper.toString(field.get(self))); } catch (Exception e) { buffer.append(e); } } } klass = klass.getSuperclass(); } /* here is a different implementation that uses getProperties(). I have left * it commented out because it returns a slightly different list of properties; * i.e. it does not return privates. I don't know what dump() really should be doing, * although IMO showing private fields is a no-no */ /* List props = getProperties(self); for(Iterator itr = props.keySet().iterator(); itr.hasNext(); ) { String propName = itr.next().toString(); // the original skipped this, so I will too if(pv.getName().equals("class")) continue; if(pv.getName().equals("metaClass")) continue; buffer.append(" "); buffer.append(propName); buffer.append("="); try { buffer.append(InvokerHelper.toString(props.get(propName))); } catch (Exception e) { buffer.append(e); } } */ buffer.append(">"); return buffer.toString(); }
java
public static String dump(Object self) { if (self == null) { return "null"; } StringBuilder buffer = new StringBuilder("<"); Class klass = self.getClass(); buffer.append(klass.getName()); buffer.append("@"); buffer.append(Integer.toHexString(self.hashCode())); boolean groovyObject = self instanceof GroovyObject; /*jes this may be rewritten to use the new getProperties() stuff * but the original pulls out private variables, whereas getProperties() * does not. What's the real use of dump() here? */ while (klass != null) { for (final Field field : klass.getDeclaredFields()) { if ((field.getModifiers() & Modifier.STATIC) == 0) { if (groovyObject && field.getName().equals("metaClass")) { continue; } AccessController.doPrivileged(new PrivilegedAction() { public Object run() { field.setAccessible(true); return null; } }); buffer.append(" "); buffer.append(field.getName()); buffer.append("="); try { buffer.append(InvokerHelper.toString(field.get(self))); } catch (Exception e) { buffer.append(e); } } } klass = klass.getSuperclass(); } /* here is a different implementation that uses getProperties(). I have left * it commented out because it returns a slightly different list of properties; * i.e. it does not return privates. I don't know what dump() really should be doing, * although IMO showing private fields is a no-no */ /* List props = getProperties(self); for(Iterator itr = props.keySet().iterator(); itr.hasNext(); ) { String propName = itr.next().toString(); // the original skipped this, so I will too if(pv.getName().equals("class")) continue; if(pv.getName().equals("metaClass")) continue; buffer.append(" "); buffer.append(propName); buffer.append("="); try { buffer.append(InvokerHelper.toString(props.get(propName))); } catch (Exception e) { buffer.append(e); } } */ buffer.append(">"); return buffer.toString(); }
[ "public", "static", "String", "dump", "(", "Object", "self", ")", "{", "if", "(", "self", "==", "null", ")", "{", "return", "\"null\"", ";", "}", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", "\"<\"", ")", ";", "Class", "klass", "=", "self", ".", "getClass", "(", ")", ";", "buffer", ".", "append", "(", "klass", ".", "getName", "(", ")", ")", ";", "buffer", ".", "append", "(", "\"@\"", ")", ";", "buffer", ".", "append", "(", "Integer", ".", "toHexString", "(", "self", ".", "hashCode", "(", ")", ")", ")", ";", "boolean", "groovyObject", "=", "self", "instanceof", "GroovyObject", ";", "/*jes this may be rewritten to use the new getProperties() stuff\n * but the original pulls out private variables, whereas getProperties()\n * does not. What's the real use of dump() here?\n */", "while", "(", "klass", "!=", "null", ")", "{", "for", "(", "final", "Field", "field", ":", "klass", ".", "getDeclaredFields", "(", ")", ")", "{", "if", "(", "(", "field", ".", "getModifiers", "(", ")", "&", "Modifier", ".", "STATIC", ")", "==", "0", ")", "{", "if", "(", "groovyObject", "&&", "field", ".", "getName", "(", ")", ".", "equals", "(", "\"metaClass\"", ")", ")", "{", "continue", ";", "}", "AccessController", ".", "doPrivileged", "(", "new", "PrivilegedAction", "(", ")", "{", "public", "Object", "run", "(", ")", "{", "field", ".", "setAccessible", "(", "true", ")", ";", "return", "null", ";", "}", "}", ")", ";", "buffer", ".", "append", "(", "\" \"", ")", ";", "buffer", ".", "append", "(", "field", ".", "getName", "(", ")", ")", ";", "buffer", ".", "append", "(", "\"=\"", ")", ";", "try", "{", "buffer", ".", "append", "(", "InvokerHelper", ".", "toString", "(", "field", ".", "get", "(", "self", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "buffer", ".", "append", "(", "e", ")", ";", "}", "}", "}", "klass", "=", "klass", ".", "getSuperclass", "(", ")", ";", "}", "/* here is a different implementation that uses getProperties(). I have left\n * it commented out because it returns a slightly different list of properties;\n * i.e. it does not return privates. I don't know what dump() really should be doing,\n * although IMO showing private fields is a no-no\n */", "/*\n List props = getProperties(self);\n for(Iterator itr = props.keySet().iterator(); itr.hasNext(); ) {\n String propName = itr.next().toString();\n\n // the original skipped this, so I will too\n if(pv.getName().equals(\"class\")) continue;\n if(pv.getName().equals(\"metaClass\")) continue;\n\n buffer.append(\" \");\n buffer.append(propName);\n buffer.append(\"=\");\n try {\n buffer.append(InvokerHelper.toString(props.get(propName)));\n }\n catch (Exception e) {\n buffer.append(e);\n }\n }\n */", "buffer", ".", "append", "(", "\">\"", ")", ";", "return", "buffer", ".", "toString", "(", ")", ";", "}" ]
Generates a detailed dump string of an object showing its class, hashCode and fields. @param self an object @return the dump representation @since 1.0
[ "Generates", "a", "detailed", "dump", "string", "of", "an", "object", "showing", "its", "class", "hashCode", "and", "fields", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L431-L500
12,608
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.use
public static <T> T use(Object self, Class categoryClass, Closure<T> closure) { return GroovyCategorySupport.use(categoryClass, closure); }
java
public static <T> T use(Object self, Class categoryClass, Closure<T> closure) { return GroovyCategorySupport.use(categoryClass, closure); }
[ "public", "static", "<", "T", ">", "T", "use", "(", "Object", "self", ",", "Class", "categoryClass", ",", "Closure", "<", "T", ">", "closure", ")", "{", "return", "GroovyCategorySupport", ".", "use", "(", "categoryClass", ",", "closure", ")", ";", "}" ]
Scoped use method @param self any Object @param categoryClass a category class to use @param closure the closure to invoke with the category in place @return the value returned from the closure @since 1.0
[ "Scoped", "use", "method" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L554-L556
12,609
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.mixin
public static void mixin(MetaClass self, List<Class> categoryClasses) { MixinInMetaClass.mixinClassesToMetaClass(self, categoryClasses); }
java
public static void mixin(MetaClass self, List<Class> categoryClasses) { MixinInMetaClass.mixinClassesToMetaClass(self, categoryClasses); }
[ "public", "static", "void", "mixin", "(", "MetaClass", "self", ",", "List", "<", "Class", ">", "categoryClasses", ")", "{", "MixinInMetaClass", ".", "mixinClassesToMetaClass", "(", "self", ",", "categoryClasses", ")", ";", "}" ]
Extend object with category methods. All methods for given class and all super classes will be added to the object. @param self any Class @param categoryClasses a category classes to use @since 1.6.0
[ "Extend", "object", "with", "category", "methods", ".", "All", "methods", "for", "given", "class", "and", "all", "super", "classes", "will", "be", "added", "to", "the", "object", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L566-L568
12,610
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.mixin
public static void mixin(Class self, List<Class> categoryClasses) { mixin(getMetaClass(self), categoryClasses); }
java
public static void mixin(Class self, List<Class> categoryClasses) { mixin(getMetaClass(self), categoryClasses); }
[ "public", "static", "void", "mixin", "(", "Class", "self", ",", "List", "<", "Class", ">", "categoryClasses", ")", "{", "mixin", "(", "getMetaClass", "(", "self", ")", ",", "categoryClasses", ")", ";", "}" ]
Extend class globally with category methods. All methods for given class and all super classes will be added to the class. @param self any Class @param categoryClasses a category classes to use @since 1.6.0
[ "Extend", "class", "globally", "with", "category", "methods", ".", "All", "methods", "for", "given", "class", "and", "all", "super", "classes", "will", "be", "added", "to", "the", "class", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L578-L580
12,611
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.use
public static <T> T use(Object self, List<Class> categoryClassList, Closure<T> closure) { return GroovyCategorySupport.use(categoryClassList, closure); }
java
public static <T> T use(Object self, List<Class> categoryClassList, Closure<T> closure) { return GroovyCategorySupport.use(categoryClassList, closure); }
[ "public", "static", "<", "T", ">", "T", "use", "(", "Object", "self", ",", "List", "<", "Class", ">", "categoryClassList", ",", "Closure", "<", "T", ">", "closure", ")", "{", "return", "GroovyCategorySupport", ".", "use", "(", "categoryClassList", ",", "closure", ")", ";", "}" ]
Scoped use method with list of categories. @param self any Object @param categoryClassList a list of category classes @param closure the closure to invoke with the categories in place @return the value returned from the closure @since 1.0
[ "Scoped", "use", "method", "with", "list", "of", "categories", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L648-L650
12,612
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.addShutdownHook
public static void addShutdownHook(Object self, Closure closure) { Runtime.getRuntime().addShutdownHook(new Thread(closure)); }
java
public static void addShutdownHook(Object self, Closure closure) { Runtime.getRuntime().addShutdownHook(new Thread(closure)); }
[ "public", "static", "void", "addShutdownHook", "(", "Object", "self", ",", "Closure", "closure", ")", "{", "Runtime", ".", "getRuntime", "(", ")", ".", "addShutdownHook", "(", "new", "Thread", "(", "closure", ")", ")", ";", "}" ]
Allows the usage of addShutdownHook without getting the runtime first. @param self the object the method is called on (ignored) @param closure the shutdown hook action @since 1.5.0
[ "Allows", "the", "usage", "of", "addShutdownHook", "without", "getting", "the", "runtime", "first", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L659-L661
12,613
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.print
public static void print(Object self, Object value) { // we won't get here if we are a PrintWriter if (self instanceof Writer) { try { ((Writer) self).write(InvokerHelper.toString(value)); } catch (IOException e) { // TODO: Should we have some unified function like PrintWriter.checkError()? } } else { System.out.print(InvokerHelper.toString(value)); } }
java
public static void print(Object self, Object value) { // we won't get here if we are a PrintWriter if (self instanceof Writer) { try { ((Writer) self).write(InvokerHelper.toString(value)); } catch (IOException e) { // TODO: Should we have some unified function like PrintWriter.checkError()? } } else { System.out.print(InvokerHelper.toString(value)); } }
[ "public", "static", "void", "print", "(", "Object", "self", ",", "Object", "value", ")", "{", "// we won't get here if we are a PrintWriter", "if", "(", "self", "instanceof", "Writer", ")", "{", "try", "{", "(", "(", "Writer", ")", "self", ")", ".", "write", "(", "InvokerHelper", ".", "toString", "(", "value", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// TODO: Should we have some unified function like PrintWriter.checkError()?", "}", "}", "else", "{", "System", ".", "out", ".", "print", "(", "InvokerHelper", ".", "toString", "(", "value", ")", ")", ";", "}", "}" ]
Print a value formatted Groovy style to self if it is a Writer, otherwise to the standard output stream. @param self any Object @param value the value to print @since 1.0
[ "Print", "a", "value", "formatted", "Groovy", "style", "to", "self", "if", "it", "is", "a", "Writer", "otherwise", "to", "the", "standard", "output", "stream", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L705-L716
12,614
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.print
public static void print(PrintWriter self, Object value) { self.print(InvokerHelper.toString(value)); }
java
public static void print(PrintWriter self, Object value) { self.print(InvokerHelper.toString(value)); }
[ "public", "static", "void", "print", "(", "PrintWriter", "self", ",", "Object", "value", ")", "{", "self", ".", "print", "(", "InvokerHelper", ".", "toString", "(", "value", ")", ")", ";", "}" ]
Print a value formatted Groovy style to the print writer. @param self a PrintWriter @param value the value to print @since 1.0
[ "Print", "a", "value", "formatted", "Groovy", "style", "to", "the", "print", "writer", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L725-L727
12,615
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.print
public static void print(PrintStream self, Object value) { self.print(InvokerHelper.toString(value)); }
java
public static void print(PrintStream self, Object value) { self.print(InvokerHelper.toString(value)); }
[ "public", "static", "void", "print", "(", "PrintStream", "self", ",", "Object", "value", ")", "{", "self", ".", "print", "(", "InvokerHelper", ".", "toString", "(", "value", ")", ")", ";", "}" ]
Print a value formatted Groovy style to the print stream. @param self a PrintStream @param value the value to print @since 1.6.0
[ "Print", "a", "value", "formatted", "Groovy", "style", "to", "the", "print", "stream", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L736-L738
12,616
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.println
public static void println(Object self) { // we won't get here if we are a PrintWriter if (self instanceof Writer) { PrintWriter pw = new GroovyPrintWriter((Writer) self); pw.println(); } else { System.out.println(); } }
java
public static void println(Object self) { // we won't get here if we are a PrintWriter if (self instanceof Writer) { PrintWriter pw = new GroovyPrintWriter((Writer) self); pw.println(); } else { System.out.println(); } }
[ "public", "static", "void", "println", "(", "Object", "self", ")", "{", "// we won't get here if we are a PrintWriter", "if", "(", "self", "instanceof", "Writer", ")", "{", "PrintWriter", "pw", "=", "new", "GroovyPrintWriter", "(", "(", "Writer", ")", "self", ")", ";", "pw", ".", "println", "(", ")", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", ")", ";", "}", "}" ]
Print a linebreak to the standard output stream. @param self any Object @since 1.0
[ "Print", "a", "linebreak", "to", "the", "standard", "output", "stream", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L759-L767
12,617
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.println
public static void println(Closure self) { Object owner = getClosureOwner(self); InvokerHelper.invokeMethod(owner, "println", EMPTY_OBJECT_ARRAY); }
java
public static void println(Closure self) { Object owner = getClosureOwner(self); InvokerHelper.invokeMethod(owner, "println", EMPTY_OBJECT_ARRAY); }
[ "public", "static", "void", "println", "(", "Closure", "self", ")", "{", "Object", "owner", "=", "getClosureOwner", "(", "self", ")", ";", "InvokerHelper", ".", "invokeMethod", "(", "owner", ",", "\"println\"", ",", "EMPTY_OBJECT_ARRAY", ")", ";", "}" ]
Print a linebreak to the standard output stream. This method delegates to the owner to execute the method. @param self a closure @since 1.0
[ "Print", "a", "linebreak", "to", "the", "standard", "output", "stream", ".", "This", "method", "delegates", "to", "the", "owner", "to", "execute", "the", "method", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L776-L779
12,618
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.printf
public static void printf(Object self, String format, Object[] values) { if (self instanceof PrintStream) ((PrintStream)self).printf(format, values); else System.out.printf(format, values); }
java
public static void printf(Object self, String format, Object[] values) { if (self instanceof PrintStream) ((PrintStream)self).printf(format, values); else System.out.printf(format, values); }
[ "public", "static", "void", "printf", "(", "Object", "self", ",", "String", "format", ",", "Object", "[", "]", "values", ")", "{", "if", "(", "self", "instanceof", "PrintStream", ")", "(", "(", "PrintStream", ")", "self", ")", ".", "printf", "(", "format", ",", "values", ")", ";", "else", "System", ".", "out", ".", "printf", "(", "format", ",", "values", ")", ";", "}" ]
Printf to the standard output stream. @param self any Object @param format a format string @param values values referenced by the format specifiers in the format string @since 1.0
[ "Printf", "to", "the", "standard", "output", "stream", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L850-L855
12,619
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.printf
public static void printf(Closure self, String format, Object[] values) { Object owner = getClosureOwner(self); Object[] newValues = new Object[values.length + 1]; newValues[0] = format; System.arraycopy(values, 0, newValues, 1, values.length); InvokerHelper.invokeMethod(owner, "printf", newValues); }
java
public static void printf(Closure self, String format, Object[] values) { Object owner = getClosureOwner(self); Object[] newValues = new Object[values.length + 1]; newValues[0] = format; System.arraycopy(values, 0, newValues, 1, values.length); InvokerHelper.invokeMethod(owner, "printf", newValues); }
[ "public", "static", "void", "printf", "(", "Closure", "self", ",", "String", "format", ",", "Object", "[", "]", "values", ")", "{", "Object", "owner", "=", "getClosureOwner", "(", "self", ")", ";", "Object", "[", "]", "newValues", "=", "new", "Object", "[", "values", ".", "length", "+", "1", "]", ";", "newValues", "[", "0", "]", "=", "format", ";", "System", ".", "arraycopy", "(", "values", ",", "0", ",", "newValues", ",", "1", ",", "values", ".", "length", ")", ";", "InvokerHelper", ".", "invokeMethod", "(", "owner", ",", "\"printf\"", ",", "newValues", ")", ";", "}" ]
Printf 0 or more values to the standard output stream using a format string. This method delegates to the owner to execute the method. @param self a generated closure @param format a format string @param values values referenced by the format specifiers in the format string @since 3.0.0
[ "Printf", "0", "or", "more", "values", "to", "the", "standard", "output", "stream", "using", "a", "format", "string", ".", "This", "method", "delegates", "to", "the", "owner", "to", "execute", "the", "method", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L866-L872
12,620
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.printf
public static void printf(Closure self, String format, Object value) { Object owner = getClosureOwner(self); Object[] newValues = new Object[2]; newValues[0] = format; newValues[1] = value; InvokerHelper.invokeMethod(owner, "printf", newValues); }
java
public static void printf(Closure self, String format, Object value) { Object owner = getClosureOwner(self); Object[] newValues = new Object[2]; newValues[0] = format; newValues[1] = value; InvokerHelper.invokeMethod(owner, "printf", newValues); }
[ "public", "static", "void", "printf", "(", "Closure", "self", ",", "String", "format", ",", "Object", "value", ")", "{", "Object", "owner", "=", "getClosureOwner", "(", "self", ")", ";", "Object", "[", "]", "newValues", "=", "new", "Object", "[", "2", "]", ";", "newValues", "[", "0", "]", "=", "format", ";", "newValues", "[", "1", "]", "=", "value", ";", "InvokerHelper", ".", "invokeMethod", "(", "owner", ",", "\"printf\"", ",", "newValues", ")", ";", "}" ]
Printf a value to the standard output stream using a format string. This method delegates to the owner to execute the method. @param self a generated closure @param format a format string @param value value referenced by the format specifier in the format string @since 3.0.0
[ "Printf", "a", "value", "to", "the", "standard", "output", "stream", "using", "a", "format", "string", ".", "This", "method", "delegates", "to", "the", "owner", "to", "execute", "the", "method", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L883-L889
12,621
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.sprintf
public static String sprintf(Object self, String format, Object[] values) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(outputStream); out.printf(format, values); return outputStream.toString(); }
java
public static String sprintf(Object self, String format, Object[] values) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(outputStream); out.printf(format, values); return outputStream.toString(); }
[ "public", "static", "String", "sprintf", "(", "Object", "self", ",", "String", "format", ",", "Object", "[", "]", "values", ")", "{", "ByteArrayOutputStream", "outputStream", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "PrintStream", "out", "=", "new", "PrintStream", "(", "outputStream", ")", ";", "out", ".", "printf", "(", "format", ",", "values", ")", ";", "return", "outputStream", ".", "toString", "(", ")", ";", "}" ]
Sprintf to a string. @param self any Object @param format a format string @param values values referenced by the format specifiers in the format string @return the resulting formatted string @since 1.5.0
[ "Sprintf", "to", "a", "string", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L900-L905
12,622
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.print
public static void print(Object self, PrintWriter out) { if (out == null) { out = new PrintWriter(System.out); } out.print(InvokerHelper.toString(self)); }
java
public static void print(Object self, PrintWriter out) { if (out == null) { out = new PrintWriter(System.out); } out.print(InvokerHelper.toString(self)); }
[ "public", "static", "void", "print", "(", "Object", "self", ",", "PrintWriter", "out", ")", "{", "if", "(", "out", "==", "null", ")", "{", "out", "=", "new", "PrintWriter", "(", "System", ".", "out", ")", ";", "}", "out", ".", "print", "(", "InvokerHelper", ".", "toString", "(", "self", ")", ")", ";", "}" ]
Print to a console in interactive format. @param self any Object @param out the PrintWriter used for printing @since 1.0
[ "Print", "to", "a", "console", "in", "interactive", "format", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L1057-L1062
12,623
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.invokeMethod
public static Object invokeMethod(Object object, String method, Object arguments) { return InvokerHelper.invokeMethod(object, method, arguments); }
java
public static Object invokeMethod(Object object, String method, Object arguments) { return InvokerHelper.invokeMethod(object, method, arguments); }
[ "public", "static", "Object", "invokeMethod", "(", "Object", "object", ",", "String", "method", ",", "Object", "arguments", ")", "{", "return", "InvokerHelper", ".", "invokeMethod", "(", "object", ",", "method", ",", "arguments", ")", ";", "}" ]
Provide a dynamic method invocation method which can be overloaded in classes to implement dynamic proxies easily. @param object any Object @param method the name of the method to call @param arguments the arguments to use @return the result of the method call @since 1.0
[ "Provide", "a", "dynamic", "method", "invocation", "method", "which", "can", "be", "overloaded", "in", "classes", "to", "implement", "dynamic", "proxies", "easily", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L1088-L1090
12,624
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.unique
public static <T> Iterator<T> unique(Iterator<T> self) { return uniqueItems(new IteratorIterableAdapter<T>(self)).listIterator(); }
java
public static <T> Iterator<T> unique(Iterator<T> self) { return uniqueItems(new IteratorIterableAdapter<T>(self)).listIterator(); }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "unique", "(", "Iterator", "<", "T", ">", "self", ")", "{", "return", "uniqueItems", "(", "new", "IteratorIterableAdapter", "<", "T", ">", "(", "self", ")", ")", ".", "listIterator", "(", ")", ";", "}" ]
Returns an iterator equivalent to this iterator with all duplicated items removed by using Groovy's default number-aware comparator. The original iterator will become exhausted of elements after determining the unique values. A new iterator for the unique values will be returned. @param self an Iterator @return a new Iterator of the unique items from the original iterator @since 1.5.5
[ "Returns", "an", "iterator", "equivalent", "to", "this", "iterator", "with", "all", "duplicated", "items", "removed", "by", "using", "Groovy", "s", "default", "number", "-", "aware", "comparator", ".", "The", "original", "iterator", "will", "become", "exhausted", "of", "elements", "after", "determining", "the", "unique", "values", ".", "A", "new", "iterator", "for", "the", "unique", "values", "will", "be", "returned", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L1209-L1211
12,625
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.unique
public static <T> Iterator<T> unique(Iterator<T> self, Comparator<T> comparator) { return uniqueItems(new IteratorIterableAdapter<T>(self), comparator).listIterator(); }
java
public static <T> Iterator<T> unique(Iterator<T> self, Comparator<T> comparator) { return uniqueItems(new IteratorIterableAdapter<T>(self), comparator).listIterator(); }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "unique", "(", "Iterator", "<", "T", ">", "self", ",", "Comparator", "<", "T", ">", "comparator", ")", "{", "return", "uniqueItems", "(", "new", "IteratorIterableAdapter", "<", "T", ">", "(", "self", ")", ",", "comparator", ")", ".", "listIterator", "(", ")", ";", "}" ]
Returns an iterator equivalent to this iterator with all duplicated items removed by using the supplied comparator. The original iterator will be exhausted upon returning. @param self an Iterator @param comparator a Comparator @return the modified Iterator @since 1.5.5
[ "Returns", "an", "iterator", "equivalent", "to", "this", "iterator", "with", "all", "duplicated", "items", "removed", "by", "using", "the", "supplied", "comparator", ".", "The", "original", "iterator", "will", "be", "exhausted", "upon", "returning", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L1472-L1474
12,626
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.each
public static <T> Iterable<T> each(Iterable<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure closure) { each(self.iterator(), closure); return self; }
java
public static <T> Iterable<T> each(Iterable<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure closure) { each(self.iterator(), closure); return self; }
[ "public", "static", "<", "T", ">", "Iterable", "<", "T", ">", "each", "(", "Iterable", "<", "T", ">", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "closure", ")", "{", "each", "(", "self", ".", "iterator", "(", ")", ",", "closure", ")", ";", "return", "self", ";", "}" ]
Iterates through an Iterable, passing each item to the given closure. @param self the Iterable over which we iterate @param closure the closure applied on each element found @return the self Iterable
[ "Iterates", "through", "an", "Iterable", "passing", "each", "item", "to", "the", "given", "closure", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L2293-L2296
12,627
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.each
public static <T> Iterator<T> each(Iterator<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure closure) { while (self.hasNext()) { Object arg = self.next(); closure.call(arg); } return self; }
java
public static <T> Iterator<T> each(Iterator<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure closure) { while (self.hasNext()) { Object arg = self.next(); closure.call(arg); } return self; }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "each", "(", "Iterator", "<", "T", ">", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "closure", ")", "{", "while", "(", "self", ".", "hasNext", "(", ")", ")", "{", "Object", "arg", "=", "self", ".", "next", "(", ")", ";", "closure", ".", "call", "(", "arg", ")", ";", "}", "return", "self", ";", "}" ]
Iterates through an Iterator, passing each item to the given closure. @param self the Iterator over which we iterate @param closure the closure applied on each element found @return the self Iterator @since 2.4.0
[ "Iterates", "through", "an", "Iterator", "passing", "each", "item", "to", "the", "given", "closure", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L2306-L2312
12,628
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.each
public static <T> SortedSet<T> each(SortedSet<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure closure) { return (SortedSet<T>) each((Iterable<T>) self, closure); }
java
public static <T> SortedSet<T> each(SortedSet<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure closure) { return (SortedSet<T>) each((Iterable<T>) self, closure); }
[ "public", "static", "<", "T", ">", "SortedSet", "<", "T", ">", "each", "(", "SortedSet", "<", "T", ">", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "closure", ")", "{", "return", "(", "SortedSet", "<", "T", ">", ")", "each", "(", "(", "Iterable", "<", "T", ">", ")", "self", ",", "closure", ")", ";", "}" ]
Iterates through a SortedSet, passing each item to the given closure. @param self the SortedSet over which we iterate @param closure the closure applied on each element found @return the self SortedSet @since 2.4.0
[ "Iterates", "through", "a", "SortedSet", "passing", "each", "item", "to", "the", "given", "closure", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L2358-L2360
12,629
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.reverseEach
public static <K, V> Map<K, V> reverseEach(Map<K, V> self, @ClosureParams(MapEntryOrKeyValue.class) Closure closure) { final Iterator<Map.Entry<K, V>> entries = reverse(self.entrySet().iterator()); while (entries.hasNext()) { callClosureForMapEntry(closure, entries.next()); } return self; }
java
public static <K, V> Map<K, V> reverseEach(Map<K, V> self, @ClosureParams(MapEntryOrKeyValue.class) Closure closure) { final Iterator<Map.Entry<K, V>> entries = reverse(self.entrySet().iterator()); while (entries.hasNext()) { callClosureForMapEntry(closure, entries.next()); } return self; }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "reverseEach", "(", "Map", "<", "K", ",", "V", ">", "self", ",", "@", "ClosureParams", "(", "MapEntryOrKeyValue", ".", "class", ")", "Closure", "closure", ")", "{", "final", "Iterator", "<", "Map", ".", "Entry", "<", "K", ",", "V", ">", ">", "entries", "=", "reverse", "(", "self", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ")", ";", "while", "(", "entries", ".", "hasNext", "(", ")", ")", "{", "callClosureForMapEntry", "(", "closure", ",", "entries", ".", "next", "(", ")", ")", ";", "}", "return", "self", ";", "}" ]
Allows a Map to be iterated through in reverse order using a closure. In general, the order in which the map contents are processed cannot be guaranteed. In practise, specialized forms of Map, e.g. a TreeMap will have its contents processed according to the reverse of the natural ordering of the map. @param self the map over which we iterate @param closure the 1 or 2 arg closure applied on each entry of the map @return returns the self parameter @see #each(Map, Closure) @since 1.7.2
[ "Allows", "a", "Map", "to", "be", "iterated", "through", "in", "reverse", "order", "using", "a", "closure", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L2405-L2411
12,630
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.reverseEach
public static <T> T[] reverseEach(T[] self, @ClosureParams(FirstParam.Component.class) Closure closure) { each(new ReverseListIterator<T>(Arrays.asList(self)), closure); return self; }
java
public static <T> T[] reverseEach(T[] self, @ClosureParams(FirstParam.Component.class) Closure closure) { each(new ReverseListIterator<T>(Arrays.asList(self)), closure); return self; }
[ "public", "static", "<", "T", ">", "T", "[", "]", "reverseEach", "(", "T", "[", "]", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "Component", ".", "class", ")", "Closure", "closure", ")", "{", "each", "(", "new", "ReverseListIterator", "<", "T", ">", "(", "Arrays", ".", "asList", "(", "self", ")", ")", ",", "closure", ")", ";", "return", "self", ";", "}" ]
Iterate over each element of the array in the reverse order. @param self an array @param closure a closure to which each item is passed @return the original array @since 1.5.2
[ "Iterate", "over", "each", "element", "of", "the", "array", "in", "the", "reverse", "order", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L2463-L2466
12,631
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.count
public static <T> Number count(T[] self, @ClosureParams(FirstParam.Component.class) Closure closure) { return count((Iterable)Arrays.asList(self), closure); }
java
public static <T> Number count(T[] self, @ClosureParams(FirstParam.Component.class) Closure closure) { return count((Iterable)Arrays.asList(self), closure); }
[ "public", "static", "<", "T", ">", "Number", "count", "(", "T", "[", "]", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "Component", ".", "class", ")", "Closure", "closure", ")", "{", "return", "count", "(", "(", "Iterable", ")", "Arrays", ".", "asList", "(", "self", ")", ",", "closure", ")", ";", "}" ]
Counts the number of occurrences which satisfy the given closure from inside this array. @param self the array within which we count the number of occurrences @param closure a closure condition @return the number of occurrences @since 1.8.0
[ "Counts", "the", "number", "of", "occurrences", "which", "satisfy", "the", "given", "closure", "from", "inside", "this", "array", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L3086-L3088
12,632
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.toList
public static <T> List<T> toList(Iterator<T> self) { List<T> answer = new ArrayList<T>(); while (self.hasNext()) { answer.add(self.next()); } return answer; }
java
public static <T> List<T> toList(Iterator<T> self) { List<T> answer = new ArrayList<T>(); while (self.hasNext()) { answer.add(self.next()); } return answer; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "toList", "(", "Iterator", "<", "T", ">", "self", ")", "{", "List", "<", "T", ">", "answer", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "while", "(", "self", ".", "hasNext", "(", ")", ")", "{", "answer", ".", "add", "(", "self", ".", "next", "(", ")", ")", ";", "}", "return", "answer", ";", "}" ]
Convert an iterator to a List. The iterator will become exhausted of elements after making this conversion. @param self an iterator @return a List @since 1.5.0
[ "Convert", "an", "iterator", "to", "a", "List", ".", "The", "iterator", "will", "become", "exhausted", "of", "elements", "after", "making", "this", "conversion", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L3222-L3228
12,633
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.toList
public static <T> List<T> toList(Enumeration<T> self) { List<T> answer = new ArrayList<T>(); while (self.hasMoreElements()) { answer.add(self.nextElement()); } return answer; }
java
public static <T> List<T> toList(Enumeration<T> self) { List<T> answer = new ArrayList<T>(); while (self.hasMoreElements()) { answer.add(self.nextElement()); } return answer; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "toList", "(", "Enumeration", "<", "T", ">", "self", ")", "{", "List", "<", "T", ">", "answer", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "while", "(", "self", ".", "hasMoreElements", "(", ")", ")", "{", "answer", ".", "add", "(", "self", ".", "nextElement", "(", ")", ")", ";", "}", "return", "answer", ";", "}" ]
Convert an enumeration to a List. @param self an enumeration @return a List @since 1.5.0
[ "Convert", "an", "enumeration", "to", "a", "List", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L3254-L3260
12,634
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.collectEntries
public static <K, V, E> Map<K, V> collectEntries(Iterator<E> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<?> transform) { return collectEntries(self, new LinkedHashMap<K, V>(), transform); }
java
public static <K, V, E> Map<K, V> collectEntries(Iterator<E> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<?> transform) { return collectEntries(self, new LinkedHashMap<K, V>(), transform); }
[ "public", "static", "<", "K", ",", "V", ",", "E", ">", "Map", "<", "K", ",", "V", ">", "collectEntries", "(", "Iterator", "<", "E", ">", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "<", "?", ">", "transform", ")", "{", "return", "collectEntries", "(", "self", ",", "new", "LinkedHashMap", "<", "K", ",", "V", ">", "(", ")", ",", "transform", ")", ";", "}" ]
A variant of collectEntries for Iterators. @param self an Iterator @param transform the closure used for transforming, which has an item from self as the parameter and should return a Map.Entry, a Map or a two-element list containing the resulting key and value @return a Map of the transformed entries @see #collectEntries(Iterable, Closure) @since 1.8.7
[ "A", "variant", "of", "collectEntries", "for", "Iterators", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4022-L4024
12,635
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.collectEntries
public static <K, V> Map<K, V> collectEntries(Iterator<?> self) { return collectEntries(self, Closure.IDENTITY); }
java
public static <K, V> Map<K, V> collectEntries(Iterator<?> self) { return collectEntries(self, Closure.IDENTITY); }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "collectEntries", "(", "Iterator", "<", "?", ">", "self", ")", "{", "return", "collectEntries", "(", "self", ",", "Closure", ".", "IDENTITY", ")", ";", "}" ]
A variant of collectEntries for Iterators using the identity closure as the transform. @param self an Iterator @return a Map of the transformed entries @see #collectEntries(Iterable) @since 1.8.7
[ "A", "variant", "of", "collectEntries", "for", "Iterators", "using", "the", "identity", "closure", "as", "the", "transform", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4069-L4071
12,636
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.collectEntries
public static <K, V, E> Map<K, V> collectEntries(Iterator<E> self, Map<K, V> collector, @ClosureParams(FirstParam.FirstGenericType.class) Closure<?> transform) { while (self.hasNext()) { E next = self.next(); addEntry(collector, transform.call(next)); } return collector; }
java
public static <K, V, E> Map<K, V> collectEntries(Iterator<E> self, Map<K, V> collector, @ClosureParams(FirstParam.FirstGenericType.class) Closure<?> transform) { while (self.hasNext()) { E next = self.next(); addEntry(collector, transform.call(next)); } return collector; }
[ "public", "static", "<", "K", ",", "V", ",", "E", ">", "Map", "<", "K", ",", "V", ">", "collectEntries", "(", "Iterator", "<", "E", ">", "self", ",", "Map", "<", "K", ",", "V", ">", "collector", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "<", "?", ">", "transform", ")", "{", "while", "(", "self", ".", "hasNext", "(", ")", ")", "{", "E", "next", "=", "self", ".", "next", "(", ")", ";", "addEntry", "(", "collector", ",", "transform", ".", "call", "(", "next", ")", ")", ";", "}", "return", "collector", ";", "}" ]
A variant of collectEntries for Iterators using a supplied map as the destination of transformed entries. @param self an Iterator @param collector the Map into which the transformed entries are put @param transform the closure used for transforming, which has an item from self as the parameter and should return a Map.Entry, a Map or a two-element list containing the resulting key and value @return the collector with all transformed values added to it @since 1.8.7
[ "A", "variant", "of", "collectEntries", "for", "Iterators", "using", "a", "supplied", "map", "as", "the", "destination", "of", "transformed", "entries", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4113-L4119
12,637
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.collectEntries
public static <K, V> Map<K, V> collectEntries(Iterable<?> self, Map<K, V> collector) { return collectEntries(self.iterator(), collector); }
java
public static <K, V> Map<K, V> collectEntries(Iterable<?> self, Map<K, V> collector) { return collectEntries(self.iterator(), collector); }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "collectEntries", "(", "Iterable", "<", "?", ">", "self", ",", "Map", "<", "K", ",", "V", ">", "collector", ")", "{", "return", "collectEntries", "(", "self", ".", "iterator", "(", ")", ",", "collector", ")", ";", "}" ]
A variant of collectEntries for Iterables using the identity closure as the transform and a supplied map as the destination of transformed entries. @param self an Iterable @param collector the Map into which the transformed entries are put @return the collector with all transformed values added to it @see #collectEntries(Iterator, Map) @since 1.8.7
[ "A", "variant", "of", "collectEntries", "for", "Iterables", "using", "the", "identity", "closure", "as", "the", "transform", "and", "a", "supplied", "map", "as", "the", "destination", "of", "transformed", "entries", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4182-L4184
12,638
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.find
public static Object find(Object self, Closure closure) { BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure); for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext();) { Object value = iter.next(); if (bcw.call(value)) { return value; } } return null; }
java
public static Object find(Object self, Closure closure) { BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure); for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext();) { Object value = iter.next(); if (bcw.call(value)) { return value; } } return null; }
[ "public", "static", "Object", "find", "(", "Object", "self", ",", "Closure", "closure", ")", "{", "BooleanClosureWrapper", "bcw", "=", "new", "BooleanClosureWrapper", "(", "closure", ")", ";", "for", "(", "Iterator", "iter", "=", "InvokerHelper", ".", "asIterator", "(", "self", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "Object", "value", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "bcw", ".", "call", "(", "value", ")", ")", "{", "return", "value", ";", "}", "}", "return", "null", ";", "}" ]
Finds the first value matching the closure condition. <pre class="groovyTestCase"> def numbers = [1, 2, 3] def result = numbers.find { it {@code >} 1} assert result == 2 </pre> @param self an Object with an iterator returning its values @param closure a closure condition @return the first Object found or null if none was found @since 1.0
[ "Finds", "the", "first", "value", "matching", "the", "closure", "condition", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4303-L4312
12,639
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findResult
@Deprecated public static <S, T, U extends T, V extends T> T findResult(Collection<S> self, U defaultResult, @ClosureParams(FirstParam.FirstGenericType.class) Closure<V> condition) { return findResult((Iterable<S>) self, defaultResult, condition); }
java
@Deprecated public static <S, T, U extends T, V extends T> T findResult(Collection<S> self, U defaultResult, @ClosureParams(FirstParam.FirstGenericType.class) Closure<V> condition) { return findResult((Iterable<S>) self, defaultResult, condition); }
[ "@", "Deprecated", "public", "static", "<", "S", ",", "T", ",", "U", "extends", "T", ",", "V", "extends", "T", ">", "T", "findResult", "(", "Collection", "<", "S", ">", "self", ",", "U", "defaultResult", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "<", "V", ">", "condition", ")", "{", "return", "findResult", "(", "(", "Iterable", "<", "S", ">", ")", "self", ",", "defaultResult", ",", "condition", ")", ";", "}" ]
Iterates through the collection calling the given closure for each item but stopping once the first non-null result is found and returning that result. If all are null, the defaultResult is returned. @param self a Collection @param defaultResult an Object that should be returned if all closure results are null @param condition a closure that returns a non-null value to indicate that processing should stop and the value should be returned @return the first non-null result from calling the closure, or the defaultValue @since 1.7.5 @deprecated use the Iterable version instead
[ "Iterates", "through", "the", "collection", "calling", "the", "given", "closure", "for", "each", "item", "but", "stopping", "once", "the", "first", "non", "-", "null", "result", "is", "found", "and", "returning", "that", "result", ".", "If", "all", "are", "null", "the", "defaultResult", "is", "returned", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4452-L4455
12,640
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findResult
public static <T, U> T findResult(Iterator<U> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<T> condition) { while (self.hasNext()) { U next = self.next(); T result = condition.call(next); if (result != null) { return result; } } return null; }
java
public static <T, U> T findResult(Iterator<U> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<T> condition) { while (self.hasNext()) { U next = self.next(); T result = condition.call(next); if (result != null) { return result; } } return null; }
[ "public", "static", "<", "T", ",", "U", ">", "T", "findResult", "(", "Iterator", "<", "U", ">", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "<", "T", ">", "condition", ")", "{", "while", "(", "self", ".", "hasNext", "(", ")", ")", "{", "U", "next", "=", "self", ".", "next", "(", ")", ";", "T", "result", "=", "condition", ".", "call", "(", "next", ")", ";", "if", "(", "result", "!=", "null", ")", "{", "return", "result", ";", "}", "}", "return", "null", ";", "}" ]
Iterates through the Iterator calling the given closure condition for each item but stopping once the first non-null result is found and returning that result. If all results are null, null is returned. @param self an Iterator @param condition a closure that returns a non-null value to indicate that processing should stop and the value should be returned @return the first non-null result from calling the closure, or null @since 2.5.0
[ "Iterates", "through", "the", "Iterator", "calling", "the", "given", "closure", "condition", "for", "each", "item", "but", "stopping", "once", "the", "first", "non", "-", "null", "result", "is", "found", "and", "returning", "that", "result", ".", "If", "all", "results", "are", "null", "null", "is", "returned", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4504-L4513
12,641
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findResult
public static <T, U> T findResult(Iterable<U> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<T> condition) { return findResult(self.iterator(), condition); }
java
public static <T, U> T findResult(Iterable<U> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<T> condition) { return findResult(self.iterator(), condition); }
[ "public", "static", "<", "T", ",", "U", ">", "T", "findResult", "(", "Iterable", "<", "U", ">", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "<", "T", ">", "condition", ")", "{", "return", "findResult", "(", "self", ".", "iterator", "(", ")", ",", "condition", ")", ";", "}" ]
Iterates through the Iterable calling the given closure condition for each item but stopping once the first non-null result is found and returning that result. If all results are null, null is returned. @param self an Iterable @param condition a closure that returns a non-null value to indicate that processing should stop and the value should be returned @return the first non-null result from calling the closure, or null @since 2.5.0
[ "Iterates", "through", "the", "Iterable", "calling", "the", "given", "closure", "condition", "for", "each", "item", "but", "stopping", "once", "the", "first", "non", "-", "null", "result", "is", "found", "and", "returning", "that", "result", ".", "If", "all", "results", "are", "null", "null", "is", "returned", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4547-L4549
12,642
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findResult
public static <S, T, U extends T, V extends T> T findResult(S[] self, U defaultResult, @ClosureParams(FirstParam.Component.class) Closure<V> condition) { return findResult(new ArrayIterator<S>(self), defaultResult, condition); }
java
public static <S, T, U extends T, V extends T> T findResult(S[] self, U defaultResult, @ClosureParams(FirstParam.Component.class) Closure<V> condition) { return findResult(new ArrayIterator<S>(self), defaultResult, condition); }
[ "public", "static", "<", "S", ",", "T", ",", "U", "extends", "T", ",", "V", "extends", "T", ">", "T", "findResult", "(", "S", "[", "]", "self", ",", "U", "defaultResult", ",", "@", "ClosureParams", "(", "FirstParam", ".", "Component", ".", "class", ")", "Closure", "<", "V", ">", "condition", ")", "{", "return", "findResult", "(", "new", "ArrayIterator", "<", "S", ">", "(", "self", ")", ",", "defaultResult", ",", "condition", ")", ";", "}" ]
Iterates through the Array calling the given closure condition for each item but stopping once the first non-null result is found and returning that result. If all are null, the defaultResult is returned. @param self an Array @param defaultResult an Object that should be returned if all closure results are null @param condition a closure that returns a non-null value to indicate that processing should stop and the value should be returned @return the first non-null result from calling the closure, or the defaultValue @since 2.5.0
[ "Iterates", "through", "the", "Array", "calling", "the", "given", "closure", "condition", "for", "each", "item", "but", "stopping", "once", "the", "first", "non", "-", "null", "result", "is", "found", "and", "returning", "that", "result", ".", "If", "all", "are", "null", "the", "defaultResult", "is", "returned", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4561-L4563
12,643
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findResult
public static <S, T> T findResult(S[] self, @ClosureParams(FirstParam.Component.class) Closure<T> condition) { return findResult(new ArrayIterator<S>(self), condition); }
java
public static <S, T> T findResult(S[] self, @ClosureParams(FirstParam.Component.class) Closure<T> condition) { return findResult(new ArrayIterator<S>(self), condition); }
[ "public", "static", "<", "S", ",", "T", ">", "T", "findResult", "(", "S", "[", "]", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "Component", ".", "class", ")", "Closure", "<", "T", ">", "condition", ")", "{", "return", "findResult", "(", "new", "ArrayIterator", "<", "S", ">", "(", "self", ")", ",", "condition", ")", ";", "}" ]
Iterates through the Array calling the given closure condition for each item but stopping once the first non-null result is found and returning that result. If all results are null, null is returned. @param self an Array @param condition a closure that returns a non-null value to indicate that processing should stop and the value should be returned @return the first non-null result from calling the closure, or null @since 2.5.0
[ "Iterates", "through", "the", "Array", "calling", "the", "given", "closure", "condition", "for", "each", "item", "but", "stopping", "once", "the", "first", "non", "-", "null", "result", "is", "found", "and", "returning", "that", "result", ".", "If", "all", "results", "are", "null", "null", "is", "returned", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4574-L4576
12,644
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findResults
public static <T, U> Collection<T> findResults(Iterator<U> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<T> filteringTransform) { List<T> result = new ArrayList<T>(); while (self.hasNext()) { U value = self.next(); T transformed = filteringTransform.call(value); if (transformed != null) { result.add(transformed); } } return result; }
java
public static <T, U> Collection<T> findResults(Iterator<U> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<T> filteringTransform) { List<T> result = new ArrayList<T>(); while (self.hasNext()) { U value = self.next(); T transformed = filteringTransform.call(value); if (transformed != null) { result.add(transformed); } } return result; }
[ "public", "static", "<", "T", ",", "U", ">", "Collection", "<", "T", ">", "findResults", "(", "Iterator", "<", "U", ">", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "<", "T", ">", "filteringTransform", ")", "{", "List", "<", "T", ">", "result", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "while", "(", "self", ".", "hasNext", "(", ")", ")", "{", "U", "value", "=", "self", ".", "next", "(", ")", ";", "T", "transformed", "=", "filteringTransform", ".", "call", "(", "value", ")", ";", "if", "(", "transformed", "!=", "null", ")", "{", "result", ".", "add", "(", "transformed", ")", ";", "}", "}", "return", "result", ";", "}" ]
Iterates through the Iterator transforming items using the supplied closure and collecting any non-null results. @param self an Iterator @param filteringTransform a Closure that should return either a non-null transformed value or null for items which should be discarded @return the list of non-null transformed values @since 2.5.0
[ "Iterates", "through", "the", "Iterator", "transforming", "items", "using", "the", "supplied", "closure", "and", "collecting", "any", "non", "-", "null", "results", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4664-L4674
12,645
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findResults
public static <T, U> Collection<T> findResults(U[] self, @ClosureParams(FirstParam.Component.class) Closure<T> filteringTransform) { return findResults(new ArrayIterator<U>(self), filteringTransform); }
java
public static <T, U> Collection<T> findResults(U[] self, @ClosureParams(FirstParam.Component.class) Closure<T> filteringTransform) { return findResults(new ArrayIterator<U>(self), filteringTransform); }
[ "public", "static", "<", "T", ",", "U", ">", "Collection", "<", "T", ">", "findResults", "(", "U", "[", "]", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "Component", ".", "class", ")", "Closure", "<", "T", ">", "filteringTransform", ")", "{", "return", "findResults", "(", "new", "ArrayIterator", "<", "U", ">", "(", "self", ")", ",", "filteringTransform", ")", ";", "}" ]
Iterates through the Array transforming items using the supplied closure and collecting any non-null results. @param self an Array @param filteringTransform a Closure that should return either a non-null transformed value or null for items which should be discarded @return the list of non-null transformed values @since 2.5.0
[ "Iterates", "through", "the", "Array", "transforming", "items", "using", "the", "supplied", "closure", "and", "collecting", "any", "non", "-", "null", "results", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4685-L4687
12,646
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findAll
public static Collection findAll(Object self, Closure closure) { List answer = new ArrayList(); Iterator iter = InvokerHelper.asIterator(self); return findAll(closure, answer, iter); }
java
public static Collection findAll(Object self, Closure closure) { List answer = new ArrayList(); Iterator iter = InvokerHelper.asIterator(self); return findAll(closure, answer, iter); }
[ "public", "static", "Collection", "findAll", "(", "Object", "self", ",", "Closure", "closure", ")", "{", "List", "answer", "=", "new", "ArrayList", "(", ")", ";", "Iterator", "iter", "=", "InvokerHelper", ".", "asIterator", "(", "self", ")", ";", "return", "findAll", "(", "closure", ",", "answer", ",", "iter", ")", ";", "}" ]
Finds all items matching the closure condition. @param self an Object with an Iterator returning its values @param closure a closure condition @return a List of the values found @since 1.6.0
[ "Finds", "all", "items", "matching", "the", "closure", "condition", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4877-L4881
12,647
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.removeAll
public static boolean removeAll(Collection self, Object[] items) { Collection pickFrom = new TreeSet(new NumberAwareComparator()); pickFrom.addAll(Arrays.asList(items)); return self.removeAll(pickFrom); }
java
public static boolean removeAll(Collection self, Object[] items) { Collection pickFrom = new TreeSet(new NumberAwareComparator()); pickFrom.addAll(Arrays.asList(items)); return self.removeAll(pickFrom); }
[ "public", "static", "boolean", "removeAll", "(", "Collection", "self", ",", "Object", "[", "]", "items", ")", "{", "Collection", "pickFrom", "=", "new", "TreeSet", "(", "new", "NumberAwareComparator", "(", ")", ")", ";", "pickFrom", ".", "addAll", "(", "Arrays", ".", "asList", "(", "items", ")", ")", ";", "return", "self", ".", "removeAll", "(", "pickFrom", ")", ";", "}" ]
Modifies this collection by removing its elements that are contained within the specified object array. See also <code>findAll</code> and <code>grep</code> when wanting to produce a new list containing items which don't match some criteria while leaving the original collection unchanged. @param self a Collection to be modified @param items array containing elements to be removed from this collection @return <tt>true</tt> if this collection changed as a result of the call @see Collection#removeAll(Collection) @since 1.7.2
[ "Modifies", "this", "collection", "by", "removing", "its", "elements", "that", "are", "contained", "within", "the", "specified", "object", "array", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L4968-L4972
12,648
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.retainAll
public static <T> boolean retainAll(Collection<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure condition) { Iterator iter = InvokerHelper.asIterator(self); BooleanClosureWrapper bcw = new BooleanClosureWrapper(condition); boolean result = false; while (iter.hasNext()) { Object value = iter.next(); if (!bcw.call(value)) { iter.remove(); result = true; } } return result; }
java
public static <T> boolean retainAll(Collection<T> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure condition) { Iterator iter = InvokerHelper.asIterator(self); BooleanClosureWrapper bcw = new BooleanClosureWrapper(condition); boolean result = false; while (iter.hasNext()) { Object value = iter.next(); if (!bcw.call(value)) { iter.remove(); result = true; } } return result; }
[ "public", "static", "<", "T", ">", "boolean", "retainAll", "(", "Collection", "<", "T", ">", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "FirstGenericType", ".", "class", ")", "Closure", "condition", ")", "{", "Iterator", "iter", "=", "InvokerHelper", ".", "asIterator", "(", "self", ")", ";", "BooleanClosureWrapper", "bcw", "=", "new", "BooleanClosureWrapper", "(", "condition", ")", ";", "boolean", "result", "=", "false", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Object", "value", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "!", "bcw", ".", "call", "(", "value", ")", ")", "{", "iter", ".", "remove", "(", ")", ";", "result", "=", "true", ";", "}", "}", "return", "result", ";", "}" ]
Modifies this collection so that it retains only its elements that are matched according to the specified closure condition. In other words, removes from this collection all of its elements that don't match. <pre class="groovyTestCase">def list = ['a', 'b'] list.retainAll { it == 'b' } assert list == ['b']</pre> See also <code>findAll</code> and <code>grep</code> when wanting to produce a new list containing items which match some criteria but leaving the original collection unchanged. @param self a Collection to be modified @param condition a closure condition @return <tt>true</tt> if this collection changed as a result of the call @see Iterator#remove() @since 1.7.2
[ "Modifies", "this", "collection", "so", "that", "it", "retains", "only", "its", "elements", "that", "are", "matched", "according", "to", "the", "specified", "closure", "condition", ".", "In", "other", "words", "removes", "from", "this", "collection", "all", "of", "its", "elements", "that", "don", "t", "match", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L5012-L5024
12,649
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.addAll
public static <T> boolean addAll(Collection<T> self, T[] items) { return self.addAll(Arrays.asList(items)); }
java
public static <T> boolean addAll(Collection<T> self, T[] items) { return self.addAll(Arrays.asList(items)); }
[ "public", "static", "<", "T", ">", "boolean", "addAll", "(", "Collection", "<", "T", ">", "self", ",", "T", "[", "]", "items", ")", "{", "return", "self", ".", "addAll", "(", "Arrays", ".", "asList", "(", "items", ")", ")", ";", "}" ]
Modifies the collection by adding all of the elements in the specified array to the collection. The behavior of this operation is undefined if the specified array is modified while the operation is in progress. See also <code>plus</code> or the '+' operator if wanting to produce a new collection containing additional items but while leaving the original collection unchanged. @param self a Collection to be modified @param items array containing elements to be added to this collection @return <tt>true</tt> if this collection changed as a result of the call @see Collection#addAll(Collection) @since 1.7.2
[ "Modifies", "the", "collection", "by", "adding", "all", "of", "the", "elements", "in", "the", "specified", "array", "to", "the", "collection", ".", "The", "behavior", "of", "this", "operation", "is", "undefined", "if", "the", "specified", "array", "is", "modified", "while", "the", "operation", "is", "in", "progress", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L5136-L5138
12,650
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.split
public static Collection split(Object self, Closure closure) { List accept = new ArrayList(); List reject = new ArrayList(); return split(closure, accept, reject, InvokerHelper.asIterator(self)); }
java
public static Collection split(Object self, Closure closure) { List accept = new ArrayList(); List reject = new ArrayList(); return split(closure, accept, reject, InvokerHelper.asIterator(self)); }
[ "public", "static", "Collection", "split", "(", "Object", "self", ",", "Closure", "closure", ")", "{", "List", "accept", "=", "new", "ArrayList", "(", ")", ";", "List", "reject", "=", "new", "ArrayList", "(", ")", ";", "return", "split", "(", "closure", ",", "accept", ",", "reject", ",", "InvokerHelper", ".", "asIterator", "(", "self", ")", ")", ";", "}" ]
Splits all items into two lists based on the closure condition. The first list contains all items matching the closure expression. The second list all those that don't. @param self an Object with an Iterator returning its values @param closure a closure condition @return a List whose first item is the accepted values and whose second item is the rejected values @since 1.6.0
[ "Splits", "all", "items", "into", "two", "lists", "based", "on", "the", "closure", "condition", ".", "The", "first", "list", "contains", "all", "items", "matching", "the", "closure", "expression", ".", "The", "second", "list", "all", "those", "that", "don", "t", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L5174-L5178
12,651
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.split
public static <T> Collection<Collection<T>> split(T[] self, @ClosureParams(FirstParam.Component.class) Closure closure) { List<T> accept = new ArrayList<T>(); List<T> reject = new ArrayList<T>(); Iterator<T> iter = new ArrayIterator<T>(self); return split(closure, accept, reject, iter); }
java
public static <T> Collection<Collection<T>> split(T[] self, @ClosureParams(FirstParam.Component.class) Closure closure) { List<T> accept = new ArrayList<T>(); List<T> reject = new ArrayList<T>(); Iterator<T> iter = new ArrayIterator<T>(self); return split(closure, accept, reject, iter); }
[ "public", "static", "<", "T", ">", "Collection", "<", "Collection", "<", "T", ">", ">", "split", "(", "T", "[", "]", "self", ",", "@", "ClosureParams", "(", "FirstParam", ".", "Component", ".", "class", ")", "Closure", "closure", ")", "{", "List", "<", "T", ">", "accept", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "List", "<", "T", ">", "reject", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "Iterator", "<", "T", ">", "iter", "=", "new", "ArrayIterator", "<", "T", ">", "(", "self", ")", ";", "return", "split", "(", "closure", ",", "accept", ",", "reject", ",", "iter", ")", ";", "}" ]
Splits all items into two collections based on the closure condition. The first list contains all items which match the closure expression. The second list all those that don't. @param self an Array @param closure a closure condition @return a List whose first item is the accepted values and whose second item is the rejected values @since 2.5.0
[ "Splits", "all", "items", "into", "two", "collections", "based", "on", "the", "closure", "condition", ".", "The", "first", "list", "contains", "all", "items", "which", "match", "the", "closure", "expression", ".", "The", "second", "list", "all", "those", "that", "don", "t", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L5210-L5215
12,652
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.sum
public static Object sum(Iterator<Object> self) { return sum(toList(self), null, true); }
java
public static Object sum(Iterator<Object> self) { return sum(toList(self), null, true); }
[ "public", "static", "Object", "sum", "(", "Iterator", "<", "Object", ">", "self", ")", "{", "return", "sum", "(", "toList", "(", "self", ")", ",", "null", ",", "true", ")", ";", "}" ]
Sums the items from an Iterator. This is equivalent to invoking the "plus" method on all items from the Iterator. The iterator will become exhausted of elements after determining the sum value. @param self an Iterator for the values to add together @return The sum of all of the items @since 1.5.5
[ "Sums", "the", "items", "from", "an", "Iterator", ".", "This", "is", "equivalent", "to", "invoking", "the", "plus", "method", "on", "all", "items", "from", "the", "Iterator", ".", "The", "iterator", "will", "become", "exhausted", "of", "elements", "after", "determining", "the", "sum", "value", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L6233-L6235
12,653
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.sum
public static Object sum(Object[] self, Object initialValue) { return sum(toList(self), initialValue, false); }
java
public static Object sum(Object[] self, Object initialValue) { return sum(toList(self), initialValue, false); }
[ "public", "static", "Object", "sum", "(", "Object", "[", "]", "self", ",", "Object", "initialValue", ")", "{", "return", "sum", "(", "toList", "(", "self", ")", ",", "initialValue", ",", "false", ")", ";", "}" ]
Sums the items in an array, adding the result to some initial value. @param self an array of values to sum @param initialValue the items in the array will be summed to this initial value @return The sum of all of the items. @since 1.7.1
[ "Sums", "the", "items", "in", "an", "array", "adding", "the", "result", "to", "some", "initial", "value", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L6354-L6356
12,654
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.min
public static <T> T min(Iterator<T> self, Comparator<T> comparator) { return min((Iterable<T>)toList(self), comparator); }
java
public static <T> T min(Iterator<T> self, Comparator<T> comparator) { return min((Iterable<T>)toList(self), comparator); }
[ "public", "static", "<", "T", ">", "T", "min", "(", "Iterator", "<", "T", ">", "self", ",", "Comparator", "<", "T", ">", "comparator", ")", "{", "return", "min", "(", "(", "Iterable", "<", "T", ">", ")", "toList", "(", "self", ")", ",", "comparator", ")", ";", "}" ]
Selects the minimum value found from the Iterator using the given comparator. @param self an Iterator @param comparator a Comparator @return the minimum value @see #min(java.util.Collection, java.util.Comparator) @since 1.5.5
[ "Selects", "the", "minimum", "value", "found", "from", "the", "Iterator", "using", "the", "given", "comparator", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7028-L7030
12,655
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.max
public static <T> T max(Iterator<T> self, Comparator<T> comparator) { return max((Iterable<T>)toList(self), comparator); }
java
public static <T> T max(Iterator<T> self, Comparator<T> comparator) { return max((Iterable<T>)toList(self), comparator); }
[ "public", "static", "<", "T", ">", "T", "max", "(", "Iterator", "<", "T", ">", "self", ",", "Comparator", "<", "T", ">", "comparator", ")", "{", "return", "max", "(", "(", "Iterable", "<", "T", ">", ")", "toList", "(", "self", ")", ",", "comparator", ")", ";", "}" ]
Selects the maximum value found from the Iterator using the given comparator. @param self an Iterator @param comparator a Comparator @return the maximum value @since 1.5.5
[ "Selects", "the", "maximum", "value", "found", "from", "the", "Iterator", "using", "the", "given", "comparator", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7431-L7433
12,656
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.getAt
public static <T> List<T> getAt(T[] array, Range range) { List<T> list = Arrays.asList(array); return getAt(list, range); }
java
public static <T> List<T> getAt(T[] array, Range range) { List<T> list = Arrays.asList(array); return getAt(list, range); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "getAt", "(", "T", "[", "]", "array", ",", "Range", "range", ")", "{", "List", "<", "T", ">", "list", "=", "Arrays", ".", "asList", "(", "array", ")", ";", "return", "getAt", "(", "list", ",", "range", ")", ";", "}" ]
Support the range subscript operator for an Array @param array an Array of Objects @param range a Range @return a range of a list from the range's from index up to but not including the range's to value @since 1.0
[ "Support", "the", "range", "subscript", "operator", "for", "an", "Array" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7784-L7787
12,657
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.toList
public static <T> List<T> toList(T[] array) { return new ArrayList<T>(Arrays.asList(array)); }
java
public static <T> List<T> toList(T[] array) { return new ArrayList<T>(Arrays.asList(array)); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "toList", "(", "T", "[", "]", "array", ")", "{", "return", "new", "ArrayList", "<", "T", ">", "(", "Arrays", ".", "asList", "(", "array", ")", ")", ";", "}" ]
Allows conversion of arrays into a mutable List. @param array an Array of Objects @return the array as a List @since 1.0
[ "Allows", "conversion", "of", "arrays", "into", "a", "mutable", "List", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7837-L7839
12,658
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.getAt
public static <T> T getAt(List<T> self, Number idx) { return getAt(self, idx.intValue()); }
java
public static <T> T getAt(List<T> self, Number idx) { return getAt(self, idx.intValue()); }
[ "public", "static", "<", "T", ">", "T", "getAt", "(", "List", "<", "T", ">", "self", ",", "Number", "idx", ")", "{", "return", "getAt", "(", "self", ",", "idx", ".", "intValue", "(", ")", ")", ";", "}" ]
Support subscript operator for list access.
[ "Support", "subscript", "operator", "for", "list", "access", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7864-L7866
12,659
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.putAt
public static <T> void putAt(List<T> self, Number idx, T value) { putAt(self, idx.intValue(), value); }
java
public static <T> void putAt(List<T> self, Number idx, T value) { putAt(self, idx.intValue(), value); }
[ "public", "static", "<", "T", ">", "void", "putAt", "(", "List", "<", "T", ">", "self", ",", "Number", "idx", ",", "T", "value", ")", "{", "putAt", "(", "self", ",", "idx", ".", "intValue", "(", ")", ",", "value", ")", ";", "}" ]
Support subscript operator for list modification.
[ "Support", "subscript", "operator", "for", "list", "modification", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7968-L7970
12,660
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.putAt
public static <K,V> V putAt(Map<K,V> self, K key, V value) { self.put(key, value); return value; }
java
public static <K,V> V putAt(Map<K,V> self, K key, V value) { self.put(key, value); return value; }
[ "public", "static", "<", "K", ",", "V", ">", "V", "putAt", "(", "Map", "<", "K", ",", "V", ">", "self", ",", "K", "key", ",", "V", "value", ")", "{", "self", ".", "put", "(", "key", ",", "value", ")", ";", "return", "value", ";", "}" ]
A helper method to allow maps to work with subscript operators @param self a Map @param key an Object as a key for the map @param value the value to put into the map @return the value corresponding to the given key @since 1.0
[ "A", "helper", "method", "to", "allow", "maps", "to", "work", "with", "subscript", "operators" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8206-L8209
12,661
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asImmutable
public static <K, V> Map<K, V> asImmutable(Map<K, V> self) { return asUnmodifiable(new LinkedHashMap<K, V>(self)); }
java
public static <K, V> Map<K, V> asImmutable(Map<K, V> self) { return asUnmodifiable(new LinkedHashMap<K, V>(self)); }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "asImmutable", "(", "Map", "<", "K", ",", "V", ">", "self", ")", "{", "return", "asUnmodifiable", "(", "new", "LinkedHashMap", "<", "K", ",", "V", ">", "(", "self", ")", ")", ";", "}" ]
A convenience method for creating an immutable Map. @param self a Map @return an unmodifiable view of a copy of the original, i.e. an effectively immutable copy @see #asImmutable(java.util.List) @see #asUnmodifiable(java.util.Map) @since 1.0
[ "A", "convenience", "method", "for", "creating", "an", "immutable", "Map", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8252-L8254
12,662
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asImmutable
public static <K, V> SortedMap<K, V> asImmutable(SortedMap<K, V> self) { return asUnmodifiable(new TreeMap<K, V>(self)); }
java
public static <K, V> SortedMap<K, V> asImmutable(SortedMap<K, V> self) { return asUnmodifiable(new TreeMap<K, V>(self)); }
[ "public", "static", "<", "K", ",", "V", ">", "SortedMap", "<", "K", ",", "V", ">", "asImmutable", "(", "SortedMap", "<", "K", ",", "V", ">", "self", ")", "{", "return", "asUnmodifiable", "(", "new", "TreeMap", "<", "K", ",", "V", ">", "(", "self", ")", ")", ";", "}" ]
A convenience method for creating an immutable SortedMap. @param self a SortedMap @return an unmodifiable view of a copy of the original, i.e. an effectively immutable copy @see #asImmutable(java.util.List) @see #asUnmodifiable(java.util.SortedMap) @since 1.0
[ "A", "convenience", "method", "for", "creating", "an", "immutable", "SortedMap", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8265-L8267
12,663
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asImmutable
public static <T> Set<T> asImmutable(Set<T> self) { return asUnmodifiable(new LinkedHashSet<T>(self)); }
java
public static <T> Set<T> asImmutable(Set<T> self) { return asUnmodifiable(new LinkedHashSet<T>(self)); }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "asImmutable", "(", "Set", "<", "T", ">", "self", ")", "{", "return", "asUnmodifiable", "(", "new", "LinkedHashSet", "<", "T", ">", "(", "self", ")", ")", ";", "}" ]
A convenience method for creating an immutable Set. @param self a Set @return an unmodifiable view of a copy of the original, i.e. an effectively immutable copy @see #asImmutable(java.util.List) @see #asUnmodifiable(java.util.Set) @since 1.0
[ "A", "convenience", "method", "for", "creating", "an", "immutable", "Set", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8303-L8305
12,664
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asImmutable
public static <T> SortedSet<T> asImmutable(SortedSet<T> self) { return asUnmodifiable(new TreeSet<T>(self)); }
java
public static <T> SortedSet<T> asImmutable(SortedSet<T> self) { return asUnmodifiable(new TreeSet<T>(self)); }
[ "public", "static", "<", "T", ">", "SortedSet", "<", "T", ">", "asImmutable", "(", "SortedSet", "<", "T", ">", "self", ")", "{", "return", "asUnmodifiable", "(", "new", "TreeSet", "<", "T", ">", "(", "self", ")", ")", ";", "}" ]
A convenience method for creating an immutable SortedSet. @param self a SortedSet @return an unmodifiable view of a copy of the original, i.e. an effectively immutable copy @see #asImmutable(java.util.List) @see #asUnmodifiable(java.util.SortedSet) @since 1.0
[ "A", "convenience", "method", "for", "creating", "an", "immutable", "SortedSet", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8316-L8318
12,665
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asImmutable
public static <T> Collection<T> asImmutable(Collection<T> self) { return asUnmodifiable((Collection<T>) new ArrayList<T>(self)); }
java
public static <T> Collection<T> asImmutable(Collection<T> self) { return asUnmodifiable((Collection<T>) new ArrayList<T>(self)); }
[ "public", "static", "<", "T", ">", "Collection", "<", "T", ">", "asImmutable", "(", "Collection", "<", "T", ">", "self", ")", "{", "return", "asUnmodifiable", "(", "(", "Collection", "<", "T", ">", ")", "new", "ArrayList", "<", "T", ">", "(", "self", ")", ")", ";", "}" ]
A convenience method for creating an immutable Collection. @param self a Collection @return an unmodifiable view of a copy of the original, i.e. an effectively immutable copy @see #asImmutable(java.util.List) @see #asUnmodifiable(java.util.Collection) @since 1.5.0
[ "A", "convenience", "method", "for", "creating", "an", "immutable", "Collection", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8329-L8331
12,666
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asUnmodifiable
public static <K, V> Map<K, V> asUnmodifiable(Map<K, V> self) { return Collections.unmodifiableMap(self); }
java
public static <K, V> Map<K, V> asUnmodifiable(Map<K, V> self) { return Collections.unmodifiableMap(self); }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "asUnmodifiable", "(", "Map", "<", "K", ",", "V", ">", "self", ")", "{", "return", "Collections", ".", "unmodifiableMap", "(", "self", ")", ";", "}" ]
Creates an unmodifiable view of a Map. @param self a Map @return an unmodifiable view of the Map @see java.util.Collections#unmodifiableMap(java.util.Map) @see #asUnmodifiable(java.util.List) @since 2.5.0
[ "Creates", "an", "unmodifiable", "view", "of", "a", "Map", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8342-L8344
12,667
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asUnmodifiable
public static <K, V> SortedMap<K, V> asUnmodifiable(SortedMap<K, V> self) { return Collections.unmodifiableSortedMap(self); }
java
public static <K, V> SortedMap<K, V> asUnmodifiable(SortedMap<K, V> self) { return Collections.unmodifiableSortedMap(self); }
[ "public", "static", "<", "K", ",", "V", ">", "SortedMap", "<", "K", ",", "V", ">", "asUnmodifiable", "(", "SortedMap", "<", "K", ",", "V", ">", "self", ")", "{", "return", "Collections", ".", "unmodifiableSortedMap", "(", "self", ")", ";", "}" ]
Creates an unmodifiable view of a SortedMap. @param self a SortedMap @return an unmodifiable view of the SortedMap @see java.util.Collections#unmodifiableSortedMap(java.util.SortedMap) @see #asUnmodifiable(java.util.List) @since 2.5.0
[ "Creates", "an", "unmodifiable", "view", "of", "a", "SortedMap", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8355-L8357
12,668
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asUnmodifiable
public static <T> Set<T> asUnmodifiable(Set<T> self) { return Collections.unmodifiableSet(self); }
java
public static <T> Set<T> asUnmodifiable(Set<T> self) { return Collections.unmodifiableSet(self); }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "asUnmodifiable", "(", "Set", "<", "T", ">", "self", ")", "{", "return", "Collections", ".", "unmodifiableSet", "(", "self", ")", ";", "}" ]
Creates an unmodifiable view of a Set. @param self a Set @return an unmodifiable view of the Set @see java.util.Collections#unmodifiableSet(java.util.Set) @see #asUnmodifiable(java.util.List) @since 2.5.0
[ "Creates", "an", "unmodifiable", "view", "of", "a", "Set", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8392-L8394
12,669
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asUnmodifiable
public static <T> SortedSet<T> asUnmodifiable(SortedSet<T> self) { return Collections.unmodifiableSortedSet(self); }
java
public static <T> SortedSet<T> asUnmodifiable(SortedSet<T> self) { return Collections.unmodifiableSortedSet(self); }
[ "public", "static", "<", "T", ">", "SortedSet", "<", "T", ">", "asUnmodifiable", "(", "SortedSet", "<", "T", ">", "self", ")", "{", "return", "Collections", ".", "unmodifiableSortedSet", "(", "self", ")", ";", "}" ]
Creates an unmodifiable view of a SortedSet. @param self a SortedSet @return an unmodifiable view of the SortedSet @see java.util.Collections#unmodifiableSortedSet(java.util.SortedSet) @see #asUnmodifiable(java.util.List) @since 2.5.0
[ "Creates", "an", "unmodifiable", "view", "of", "a", "SortedSet", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8405-L8407
12,670
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asUnmodifiable
public static <T> Collection<T> asUnmodifiable(Collection<T> self) { return Collections.unmodifiableCollection(self); }
java
public static <T> Collection<T> asUnmodifiable(Collection<T> self) { return Collections.unmodifiableCollection(self); }
[ "public", "static", "<", "T", ">", "Collection", "<", "T", ">", "asUnmodifiable", "(", "Collection", "<", "T", ">", "self", ")", "{", "return", "Collections", ".", "unmodifiableCollection", "(", "self", ")", ";", "}" ]
Creates an unmodifiable view of a Collection. @param self a Collection @return an unmodifiable view of the Collection @see java.util.Collections#unmodifiableCollection(java.util.Collection) @see #asUnmodifiable(java.util.List) @since 2.5.0
[ "Creates", "an", "unmodifiable", "view", "of", "a", "Collection", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8418-L8420
12,671
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asSynchronized
public static <K,V> Map<K,V> asSynchronized(Map<K,V> self) { return Collections.synchronizedMap(self); }
java
public static <K,V> Map<K,V> asSynchronized(Map<K,V> self) { return Collections.synchronizedMap(self); }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "asSynchronized", "(", "Map", "<", "K", ",", "V", ">", "self", ")", "{", "return", "Collections", ".", "synchronizedMap", "(", "self", ")", ";", "}" ]
A convenience method for creating a synchronized Map. @param self a Map @return a synchronized Map @see java.util.Collections#synchronizedMap(java.util.Map) @since 1.0
[ "A", "convenience", "method", "for", "creating", "a", "synchronized", "Map", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8430-L8432
12,672
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asSynchronized
public static <K,V> SortedMap<K,V> asSynchronized(SortedMap<K,V> self) { return Collections.synchronizedSortedMap(self); }
java
public static <K,V> SortedMap<K,V> asSynchronized(SortedMap<K,V> self) { return Collections.synchronizedSortedMap(self); }
[ "public", "static", "<", "K", ",", "V", ">", "SortedMap", "<", "K", ",", "V", ">", "asSynchronized", "(", "SortedMap", "<", "K", ",", "V", ">", "self", ")", "{", "return", "Collections", ".", "synchronizedSortedMap", "(", "self", ")", ";", "}" ]
A convenience method for creating a synchronized SortedMap. @param self a SortedMap @return a synchronized SortedMap @see java.util.Collections#synchronizedSortedMap(java.util.SortedMap) @since 1.0
[ "A", "convenience", "method", "for", "creating", "a", "synchronized", "SortedMap", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8442-L8444
12,673
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asSynchronized
public static <T> Collection<T> asSynchronized(Collection<T> self) { return Collections.synchronizedCollection(self); }
java
public static <T> Collection<T> asSynchronized(Collection<T> self) { return Collections.synchronizedCollection(self); }
[ "public", "static", "<", "T", ">", "Collection", "<", "T", ">", "asSynchronized", "(", "Collection", "<", "T", ">", "self", ")", "{", "return", "Collections", ".", "synchronizedCollection", "(", "self", ")", ";", "}" ]
A convenience method for creating a synchronized Collection. @param self a Collection @return a synchronized Collection @see java.util.Collections#synchronizedCollection(java.util.Collection) @since 1.0
[ "A", "convenience", "method", "for", "creating", "a", "synchronized", "Collection", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8454-L8456
12,674
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asSynchronized
public static <T> List<T> asSynchronized(List<T> self) { return Collections.synchronizedList(self); }
java
public static <T> List<T> asSynchronized(List<T> self) { return Collections.synchronizedList(self); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "asSynchronized", "(", "List", "<", "T", ">", "self", ")", "{", "return", "Collections", ".", "synchronizedList", "(", "self", ")", ";", "}" ]
A convenience method for creating a synchronized List. @param self a List @return a synchronized List @see java.util.Collections#synchronizedList(java.util.List) @since 1.0
[ "A", "convenience", "method", "for", "creating", "a", "synchronized", "List", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8466-L8468
12,675
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asSynchronized
public static <T> Set<T> asSynchronized(Set<T> self) { return Collections.synchronizedSet(self); }
java
public static <T> Set<T> asSynchronized(Set<T> self) { return Collections.synchronizedSet(self); }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "asSynchronized", "(", "Set", "<", "T", ">", "self", ")", "{", "return", "Collections", ".", "synchronizedSet", "(", "self", ")", ";", "}" ]
A convenience method for creating a synchronized Set. @param self a Set @return a synchronized Set @see java.util.Collections#synchronizedSet(java.util.Set) @since 1.0
[ "A", "convenience", "method", "for", "creating", "a", "synchronized", "Set", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8478-L8480
12,676
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asSynchronized
public static <T> SortedSet<T> asSynchronized(SortedSet<T> self) { return Collections.synchronizedSortedSet(self); }
java
public static <T> SortedSet<T> asSynchronized(SortedSet<T> self) { return Collections.synchronizedSortedSet(self); }
[ "public", "static", "<", "T", ">", "SortedSet", "<", "T", ">", "asSynchronized", "(", "SortedSet", "<", "T", ">", "self", ")", "{", "return", "Collections", ".", "synchronizedSortedSet", "(", "self", ")", ";", "}" ]
A convenience method for creating a synchronized SortedSet. @param self a SortedSet @return a synchronized SortedSet @see java.util.Collections#synchronizedSortedSet(java.util.SortedSet) @since 1.0
[ "A", "convenience", "method", "for", "creating", "a", "synchronized", "SortedSet", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8490-L8492
12,677
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.sort
public static <T> T[] sort(T[] self) { Arrays.sort(self, new NumberAwareComparator<T>()); return self; }
java
public static <T> T[] sort(T[] self) { Arrays.sort(self, new NumberAwareComparator<T>()); return self; }
[ "public", "static", "<", "T", ">", "T", "[", "]", "sort", "(", "T", "[", "]", "self", ")", "{", "Arrays", ".", "sort", "(", "self", ",", "new", "NumberAwareComparator", "<", "T", ">", "(", ")", ")", ";", "return", "self", ";", "}" ]
Modifies this array so that its elements are in sorted order. The array items are assumed to be comparable. @param self the array to be sorted @return the sorted array @since 1.5.5
[ "Modifies", "this", "array", "so", "that", "its", "elements", "are", "in", "sorted", "order", ".", "The", "array", "items", "are", "assumed", "to", "be", "comparable", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9051-L9054
12,678
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.sort
public static <T> Iterator<T> sort(Iterator<T> self) { return sort((Iterable<T>) toList(self)).listIterator(); }
java
public static <T> Iterator<T> sort(Iterator<T> self) { return sort((Iterable<T>) toList(self)).listIterator(); }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "sort", "(", "Iterator", "<", "T", ">", "self", ")", "{", "return", "sort", "(", "(", "Iterable", "<", "T", ">", ")", "toList", "(", "self", ")", ")", ".", "listIterator", "(", ")", ";", "}" ]
Sorts the given iterator items into a sorted iterator. The items are assumed to be comparable. The original iterator will become exhausted of elements after completing this method call. A new iterator is produced that traverses the items in sorted order. @param self the Iterator to be sorted @return the sorted items as an Iterator @since 1.5.5
[ "Sorts", "the", "given", "iterator", "items", "into", "a", "sorted", "iterator", ".", "The", "items", "are", "assumed", "to", "be", "comparable", ".", "The", "original", "iterator", "will", "become", "exhausted", "of", "elements", "after", "completing", "this", "method", "call", ".", "A", "new", "iterator", "is", "produced", "that", "traverses", "the", "items", "in", "sorted", "order", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9091-L9093
12,679
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.sort
public static <T> Iterator<T> sort(Iterator<T> self, Comparator<? super T> comparator) { return sort((Iterable<T>) toList(self), true, comparator).listIterator(); }
java
public static <T> Iterator<T> sort(Iterator<T> self, Comparator<? super T> comparator) { return sort((Iterable<T>) toList(self), true, comparator).listIterator(); }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "sort", "(", "Iterator", "<", "T", ">", "self", ",", "Comparator", "<", "?", "super", "T", ">", "comparator", ")", "{", "return", "sort", "(", "(", "Iterable", "<", "T", ">", ")", "toList", "(", "self", ")", ",", "true", ",", "comparator", ")", ".", "listIterator", "(", ")", ";", "}" ]
Sorts the given iterator items into a sorted iterator using the comparator. The original iterator will become exhausted of elements after completing this method call. A new iterator is produced that traverses the items in sorted order. @param self the Iterator to be sorted @param comparator a Comparator used for comparing items @return the sorted items as an Iterator @since 1.5.5
[ "Sorts", "the", "given", "iterator", "items", "into", "a", "sorted", "iterator", "using", "the", "comparator", ".", "The", "original", "iterator", "will", "become", "exhausted", "of", "elements", "after", "completing", "this", "method", "call", ".", "A", "new", "iterator", "is", "produced", "that", "traverses", "the", "items", "in", "sorted", "order", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9105-L9107
12,680
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.toSorted
public static <T> Iterator<T> toSorted(Iterator<T> self, Comparator<T> comparator) { return toSorted(toList(self), comparator).listIterator(); }
java
public static <T> Iterator<T> toSorted(Iterator<T> self, Comparator<T> comparator) { return toSorted(toList(self), comparator).listIterator(); }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "toSorted", "(", "Iterator", "<", "T", ">", "self", ",", "Comparator", "<", "T", ">", "comparator", ")", "{", "return", "toSorted", "(", "toList", "(", "self", ")", ",", "comparator", ")", ".", "listIterator", "(", ")", ";", "}" ]
Sorts the given iterator items using the comparator. The original iterator will become exhausted of elements after completing this method call. A new iterator is produced that traverses the items in sorted order. @param self the Iterator to be sorted @param comparator a Comparator used for comparing items @return the sorted items as an Iterator @since 2.4.0
[ "Sorts", "the", "given", "iterator", "items", "using", "the", "comparator", ".", "The", "original", "iterator", "will", "become", "exhausted", "of", "elements", "after", "completing", "this", "method", "call", ".", "A", "new", "iterator", "is", "produced", "that", "traverses", "the", "items", "in", "sorted", "order", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9469-L9471
12,681
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.toSorted
public static <T> Set<T> toSorted(SortedSet<T> self) { return new LinkedHashSet<T>(self); }
java
public static <T> Set<T> toSorted(SortedSet<T> self) { return new LinkedHashSet<T>(self); }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "toSorted", "(", "SortedSet", "<", "T", ">", "self", ")", "{", "return", "new", "LinkedHashSet", "<", "T", ">", "(", "self", ")", ";", "}" ]
Avoids doing unnecessary work when sorting an already sorted set @param self an already sorted set @return an ordered copy of the sorted set @since 2.4.0
[ "Avoids", "doing", "unnecessary", "work", "when", "sorting", "an", "already", "sorted", "set" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9633-L9635
12,682
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.toSorted
public static <K, V> Map<K, V> toSorted(SortedMap<K, V> self) { return new LinkedHashMap<K, V>(self); }
java
public static <K, V> Map<K, V> toSorted(SortedMap<K, V> self) { return new LinkedHashMap<K, V>(self); }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "toSorted", "(", "SortedMap", "<", "K", ",", "V", ">", "self", ")", "{", "return", "new", "LinkedHashMap", "<", "K", ",", "V", ">", "(", "self", ")", ";", "}" ]
Avoids doing unnecessary work when sorting an already sorted map @param self an already sorted map @return an ordered copy of the map @since 2.4.0
[ "Avoids", "doing", "unnecessary", "work", "when", "sorting", "an", "already", "sorted", "map" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9644-L9646
12,683
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.pop
public static <T> T pop(List<T> self) { if (self.isEmpty()) { throw new NoSuchElementException("Cannot pop() an empty List"); } return self.remove(0); }
java
public static <T> T pop(List<T> self) { if (self.isEmpty()) { throw new NoSuchElementException("Cannot pop() an empty List"); } return self.remove(0); }
[ "public", "static", "<", "T", ">", "T", "pop", "(", "List", "<", "T", ">", "self", ")", "{", "if", "(", "self", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "NoSuchElementException", "(", "\"Cannot pop() an empty List\"", ")", ";", "}", "return", "self", ".", "remove", "(", "0", ")", ";", "}" ]
Removes the initial item from the List. <pre class="groovyTestCase"> def list = ["a", false, 2] assert list.pop() == 'a' assert list == [false, 2] </pre> This is similar to pop on a Stack where the first item in the list represents the top of the stack. Note: The behavior of this method changed in Groovy 2.5 to align with Java. If you need the old behavior use 'removeLast'. @param self a List @return the item removed from the List @throws NoSuchElementException if the list is empty @since 1.0
[ "Removes", "the", "initial", "item", "from", "the", "List", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9668-L9673
12,684
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.removeLast
public static <T> T removeLast(List<T> self) { if (self.isEmpty()) { throw new NoSuchElementException("Cannot removeLast() an empty List"); } return self.remove(self.size() - 1); }
java
public static <T> T removeLast(List<T> self) { if (self.isEmpty()) { throw new NoSuchElementException("Cannot removeLast() an empty List"); } return self.remove(self.size() - 1); }
[ "public", "static", "<", "T", ">", "T", "removeLast", "(", "List", "<", "T", ">", "self", ")", "{", "if", "(", "self", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "NoSuchElementException", "(", "\"Cannot removeLast() an empty List\"", ")", ";", "}", "return", "self", ".", "remove", "(", "self", ".", "size", "(", ")", "-", "1", ")", ";", "}" ]
Removes the last item from the List. <pre class="groovyTestCase"> def list = ["a", false, 2] assert list.removeLast() == 2 assert list == ["a", false] </pre> Using add() and removeLast() is similar to push and pop on a Stack where the last item in the list represents the top of the stack. @param self a List @return the item removed from the List @throws NoSuchElementException if the list is empty @since 2.5.0
[ "Removes", "the", "last", "item", "from", "the", "List", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9692-L9697
12,685
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.putAll
public static <K, V> Map<K, V> putAll(Map<K, V> self, Collection<? extends Map.Entry<? extends K, ? extends V>> entries) { for (Map.Entry<? extends K, ? extends V> entry : entries) { self.put(entry.getKey(), entry.getValue()); } return self; }
java
public static <K, V> Map<K, V> putAll(Map<K, V> self, Collection<? extends Map.Entry<? extends K, ? extends V>> entries) { for (Map.Entry<? extends K, ? extends V> entry : entries) { self.put(entry.getKey(), entry.getValue()); } return self; }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "putAll", "(", "Map", "<", "K", ",", "V", ">", "self", ",", "Collection", "<", "?", "extends", "Map", ".", "Entry", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", ">", "entries", ")", "{", "for", "(", "Map", ".", "Entry", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "entry", ":", "entries", ")", "{", "self", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "return", "self", ";", "}" ]
Provides an easy way to append multiple Map.Entry values to a Map. @param self a Map @param entries a Collection of Map.Entry items to be added to the Map. @return the same map, after the items have been added to it. @since 1.6.1
[ "Provides", "an", "easy", "way", "to", "append", "multiple", "Map", ".", "Entry", "values", "to", "a", "Map", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9707-L9712
12,686
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.push
public static <T> boolean push(List<T> self, T value) { self.add(0, value); return true; }
java
public static <T> boolean push(List<T> self, T value) { self.add(0, value); return true; }
[ "public", "static", "<", "T", ">", "boolean", "push", "(", "List", "<", "T", ">", "self", ",", "T", "value", ")", "{", "self", ".", "add", "(", "0", ",", "value", ")", ";", "return", "true", ";", "}" ]
Prepends an item to the start of the List. <pre class="groovyTestCase"> def list = [3, 4, 2] list.push("x") assert list == ['x', 3, 4, 2] </pre> This is similar to push on a Stack where the first item in the list represents the top of the stack. Note: The behavior of this method changed in Groovy 2.5 to align with Java. If you need the old behavior use 'add'. @param self a List @param value element to be prepended to this list. @return <tt>true</tt> (for legacy compatibility reasons). @since 1.5.5
[ "Prepends", "an", "item", "to", "the", "start", "of", "the", "List", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9753-L9756
12,687
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.tail
public static <T> Iterator<T> tail(Iterator<T> self) { if (!self.hasNext()) { throw new NoSuchElementException("Cannot access tail() for an empty Iterator"); } self.next(); return self; }
java
public static <T> Iterator<T> tail(Iterator<T> self) { if (!self.hasNext()) { throw new NoSuchElementException("Cannot access tail() for an empty Iterator"); } self.next(); return self; }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "tail", "(", "Iterator", "<", "T", ">", "self", ")", "{", "if", "(", "!", "self", ".", "hasNext", "(", ")", ")", "{", "throw", "new", "NoSuchElementException", "(", "\"Cannot access tail() for an empty Iterator\"", ")", ";", "}", "self", ".", "next", "(", ")", ";", "return", "self", ";", "}" ]
Returns the original iterator after throwing away the first element. @param self the original iterator @return the iterator without its first element @throws NoSuchElementException if the array is empty and you try to access the tail() @since 1.8.1
[ "Returns", "the", "original", "iterator", "after", "throwing", "away", "the", "first", "element", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L10045-L10051
12,688
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asType
@SuppressWarnings("unchecked") public static <T> T asType(Iterable iterable, Class<T> clazz) { if (Collection.class.isAssignableFrom(clazz)) { return asType((Collection) toList(iterable), clazz); } return asType((Object) iterable, clazz); }
java
@SuppressWarnings("unchecked") public static <T> T asType(Iterable iterable, Class<T> clazz) { if (Collection.class.isAssignableFrom(clazz)) { return asType((Collection) toList(iterable), clazz); } return asType((Object) iterable, clazz); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "asType", "(", "Iterable", "iterable", ",", "Class", "<", "T", ">", "clazz", ")", "{", "if", "(", "Collection", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "asType", "(", "(", "Collection", ")", "toList", "(", "iterable", ")", ",", "clazz", ")", ";", "}", "return", "asType", "(", "(", "Object", ")", "iterable", ",", "clazz", ")", ";", "}" ]
Converts the given iterable to another type. @param iterable a Iterable @param clazz the desired class @return the object resulting from this type conversion @see #asType(Collection, Class) @since 2.4.12
[ "Converts", "the", "given", "iterable", "to", "another", "type", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L11659-L11666
12,689
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asType
@SuppressWarnings("unchecked") public static <T> T asType(Closure cl, Class<T> clazz) { if (clazz.isInterface() && !(clazz.isInstance(cl))) { if (Traits.isTrait(clazz)) { Method samMethod = CachedSAMClass.getSAMMethod(clazz); if (samMethod!=null) { Map impl = Collections.singletonMap(samMethod.getName(),cl); return (T) ProxyGenerator.INSTANCE.instantiateAggregate(impl, Collections.<Class>singletonList(clazz)); } } return (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[]{clazz}, new ConvertedClosure(cl)); } try { return asType((Object) cl, clazz); } catch (GroovyCastException ce) { try { return (T) ProxyGenerator.INSTANCE.instantiateAggregateFromBaseClass(cl, clazz); } catch (GroovyRuntimeException cause) { throw new GroovyCastException("Error casting closure to " + clazz.getName() + ", Reason: " + cause.getMessage()); } } }
java
@SuppressWarnings("unchecked") public static <T> T asType(Closure cl, Class<T> clazz) { if (clazz.isInterface() && !(clazz.isInstance(cl))) { if (Traits.isTrait(clazz)) { Method samMethod = CachedSAMClass.getSAMMethod(clazz); if (samMethod!=null) { Map impl = Collections.singletonMap(samMethod.getName(),cl); return (T) ProxyGenerator.INSTANCE.instantiateAggregate(impl, Collections.<Class>singletonList(clazz)); } } return (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[]{clazz}, new ConvertedClosure(cl)); } try { return asType((Object) cl, clazz); } catch (GroovyCastException ce) { try { return (T) ProxyGenerator.INSTANCE.instantiateAggregateFromBaseClass(cl, clazz); } catch (GroovyRuntimeException cause) { throw new GroovyCastException("Error casting closure to " + clazz.getName() + ", Reason: " + cause.getMessage()); } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "asType", "(", "Closure", "cl", ",", "Class", "<", "T", ">", "clazz", ")", "{", "if", "(", "clazz", ".", "isInterface", "(", ")", "&&", "!", "(", "clazz", ".", "isInstance", "(", "cl", ")", ")", ")", "{", "if", "(", "Traits", ".", "isTrait", "(", "clazz", ")", ")", "{", "Method", "samMethod", "=", "CachedSAMClass", ".", "getSAMMethod", "(", "clazz", ")", ";", "if", "(", "samMethod", "!=", "null", ")", "{", "Map", "impl", "=", "Collections", ".", "singletonMap", "(", "samMethod", ".", "getName", "(", ")", ",", "cl", ")", ";", "return", "(", "T", ")", "ProxyGenerator", ".", "INSTANCE", ".", "instantiateAggregate", "(", "impl", ",", "Collections", ".", "<", "Class", ">", "singletonList", "(", "clazz", ")", ")", ";", "}", "}", "return", "(", "T", ")", "Proxy", ".", "newProxyInstance", "(", "clazz", ".", "getClassLoader", "(", ")", ",", "new", "Class", "[", "]", "{", "clazz", "}", ",", "new", "ConvertedClosure", "(", "cl", ")", ")", ";", "}", "try", "{", "return", "asType", "(", "(", "Object", ")", "cl", ",", "clazz", ")", ";", "}", "catch", "(", "GroovyCastException", "ce", ")", "{", "try", "{", "return", "(", "T", ")", "ProxyGenerator", ".", "INSTANCE", ".", "instantiateAggregateFromBaseClass", "(", "cl", ",", "clazz", ")", ";", "}", "catch", "(", "GroovyRuntimeException", "cause", ")", "{", "throw", "new", "GroovyCastException", "(", "\"Error casting closure to \"", "+", "clazz", ".", "getName", "(", ")", "+", "\", Reason: \"", "+", "cause", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}" ]
Coerces the closure to an implementation of the given class. The class is assumed to be an interface or class with a single method definition. The closure is used as the implementation of that single method. @param cl the implementation of the single method @param clazz the target type @return a Proxy of the given type which wraps this closure. @since 1.0
[ "Coerces", "the", "closure", "to", "an", "implementation", "of", "the", "given", "class", ".", "The", "class", "is", "assumed", "to", "be", "an", "interface", "or", "class", "with", "a", "single", "method", "definition", ".", "The", "closure", "is", "used", "as", "the", "implementation", "of", "that", "single", "method", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L11772-L11797
12,690
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asType
@SuppressWarnings("unchecked") public static <T> T asType(Map map, Class<T> clazz) { if (!(clazz.isInstance(map)) && clazz.isInterface() && !Traits.isTrait(clazz)) { return (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[]{clazz}, new ConvertedMap(map)); } try { return asType((Object) map, clazz); } catch (GroovyCastException ce) { try { return (T) ProxyGenerator.INSTANCE.instantiateAggregateFromBaseClass(map, clazz); } catch (GroovyRuntimeException cause) { throw new GroovyCastException("Error casting map to " + clazz.getName() + ", Reason: " + cause.getMessage()); } } }
java
@SuppressWarnings("unchecked") public static <T> T asType(Map map, Class<T> clazz) { if (!(clazz.isInstance(map)) && clazz.isInterface() && !Traits.isTrait(clazz)) { return (T) Proxy.newProxyInstance( clazz.getClassLoader(), new Class[]{clazz}, new ConvertedMap(map)); } try { return asType((Object) map, clazz); } catch (GroovyCastException ce) { try { return (T) ProxyGenerator.INSTANCE.instantiateAggregateFromBaseClass(map, clazz); } catch (GroovyRuntimeException cause) { throw new GroovyCastException("Error casting map to " + clazz.getName() + ", Reason: " + cause.getMessage()); } } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "asType", "(", "Map", "map", ",", "Class", "<", "T", ">", "clazz", ")", "{", "if", "(", "!", "(", "clazz", ".", "isInstance", "(", "map", ")", ")", "&&", "clazz", ".", "isInterface", "(", ")", "&&", "!", "Traits", ".", "isTrait", "(", "clazz", ")", ")", "{", "return", "(", "T", ")", "Proxy", ".", "newProxyInstance", "(", "clazz", ".", "getClassLoader", "(", ")", ",", "new", "Class", "[", "]", "{", "clazz", "}", ",", "new", "ConvertedMap", "(", "map", ")", ")", ";", "}", "try", "{", "return", "asType", "(", "(", "Object", ")", "map", ",", "clazz", ")", ";", "}", "catch", "(", "GroovyCastException", "ce", ")", "{", "try", "{", "return", "(", "T", ")", "ProxyGenerator", ".", "INSTANCE", ".", "instantiateAggregateFromBaseClass", "(", "map", ",", "clazz", ")", ";", "}", "catch", "(", "GroovyRuntimeException", "cause", ")", "{", "throw", "new", "GroovyCastException", "(", "\"Error casting map to \"", "+", "clazz", ".", "getName", "(", ")", "+", "\", Reason: \"", "+", "cause", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}" ]
Coerces this map to the given type, using the map's keys as the public method names, and values as the implementation. Typically the value would be a closure which behaves like the method implementation. @param map this map @param clazz the target type @return a Proxy of the given type, which defers calls to this map's elements. @since 1.0
[ "Coerces", "this", "map", "to", "the", "given", "type", "using", "the", "map", "s", "keys", "as", "the", "public", "method", "names", "and", "values", "as", "the", "implementation", ".", "Typically", "the", "value", "would", "be", "a", "closure", "which", "behaves", "like", "the", "method", "implementation", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L11809-L11827
12,691
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.reverse
@SuppressWarnings("unchecked") public static <T> T[] reverse(T[] self, boolean mutate) { if (!mutate) { return (T[]) toList(new ReverseListIterator<T>(Arrays.asList(self))).toArray(); } List<T> items = Arrays.asList(self); Collections.reverse(items); System.arraycopy(items.toArray(), 0, self, 0, items.size()); return self; }
java
@SuppressWarnings("unchecked") public static <T> T[] reverse(T[] self, boolean mutate) { if (!mutate) { return (T[]) toList(new ReverseListIterator<T>(Arrays.asList(self))).toArray(); } List<T> items = Arrays.asList(self); Collections.reverse(items); System.arraycopy(items.toArray(), 0, self, 0, items.size()); return self; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "[", "]", "reverse", "(", "T", "[", "]", "self", ",", "boolean", "mutate", ")", "{", "if", "(", "!", "mutate", ")", "{", "return", "(", "T", "[", "]", ")", "toList", "(", "new", "ReverseListIterator", "<", "T", ">", "(", "Arrays", ".", "asList", "(", "self", ")", ")", ")", ".", "toArray", "(", ")", ";", "}", "List", "<", "T", ">", "items", "=", "Arrays", ".", "asList", "(", "self", ")", ";", "Collections", ".", "reverse", "(", "items", ")", ";", "System", ".", "arraycopy", "(", "items", ".", "toArray", "(", ")", ",", "0", ",", "self", ",", "0", ",", "items", ".", "size", "(", ")", ")", ";", "return", "self", ";", "}" ]
Reverse the items in an array. If mutate is true, the original array is modified in place and returned. Otherwise, a new array containing the reversed items is produced. @param self an array @param mutate true if the array itself should be reversed in place and returned, false if a new array should be created @return an array containing the reversed items @since 1.8.1
[ "Reverse", "the", "items", "in", "an", "array", ".", "If", "mutate", "is", "true", "the", "original", "array", "is", "modified", "in", "place", "and", "returned", ".", "Otherwise", "a", "new", "array", "containing", "the", "reversed", "items", "is", "produced", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L11899-L11908
12,692
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.reverse
public static <T> Iterator<T> reverse(Iterator<T> self) { return new ReverseListIterator<T>(toList(self)); }
java
public static <T> Iterator<T> reverse(Iterator<T> self) { return new ReverseListIterator<T>(toList(self)); }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "reverse", "(", "Iterator", "<", "T", ">", "self", ")", "{", "return", "new", "ReverseListIterator", "<", "T", ">", "(", "toList", "(", "self", ")", ")", ";", "}" ]
Reverses the iterator. The original iterator will become exhausted of elements after determining the reversed values. A new iterator for iterating through the reversed values is returned. @param self an Iterator @return a reversed Iterator @since 1.5.5
[ "Reverses", "the", "iterator", ".", "The", "original", "iterator", "will", "become", "exhausted", "of", "elements", "after", "determining", "the", "reversed", "values", ".", "A", "new", "iterator", "for", "iterating", "through", "the", "reversed", "values", "is", "returned", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L11919-L11921
12,693
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.plus
public static <T> Set<T> plus(Set<T> left, Collection<T> right) { return (Set<T>) plus((Collection<T>) left, right); }
java
public static <T> Set<T> plus(Set<T> left, Collection<T> right) { return (Set<T>) plus((Collection<T>) left, right); }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "plus", "(", "Set", "<", "T", ">", "left", ",", "Collection", "<", "T", ">", "right", ")", "{", "return", "(", "Set", "<", "T", ">", ")", "plus", "(", "(", "Collection", "<", "T", ">", ")", "left", ",", "right", ")", ";", "}" ]
Create a Set as a union of a Set and a Collection. This operation will always create a new object for the result, while the operands remain unchanged. @param left the left Set @param right the right Collection @return the merged Set @since 2.4.0 @see #plus(Collection, Collection)
[ "Create", "a", "Set", "as", "a", "union", "of", "a", "Set", "and", "a", "Collection", ".", "This", "operation", "will", "always", "create", "a", "new", "object", "for", "the", "result", "while", "the", "operands", "remain", "unchanged", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L12105-L12107
12,694
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.plus
public static <T> List<T> plus(List<T> self, int index, Iterable<T> additions) { return plus(self, index, toList(additions)); }
java
public static <T> List<T> plus(List<T> self, int index, Iterable<T> additions) { return plus(self, index, toList(additions)); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "plus", "(", "List", "<", "T", ">", "self", ",", "int", "index", ",", "Iterable", "<", "T", ">", "additions", ")", "{", "return", "plus", "(", "self", ",", "index", ",", "toList", "(", "additions", ")", ")", ";", "}" ]
Creates a new List by inserting all of the elements in the given Iterable to the elements from this List at the specified index. @param self an original list @param additions an Iterable containing elements to be merged with the elements from the original List @param index index at which to insert the first element from the given additions Iterable @return the new list @since 1.8.7 @see #plus(List, int, List)
[ "Creates", "a", "new", "List", "by", "inserting", "all", "of", "the", "elements", "in", "the", "given", "Iterable", "to", "the", "elements", "from", "this", "List", "at", "the", "specified", "index", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L12213-L12215
12,695
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.minus
public static <T> Set<T> minus(Set<T> self, Collection<?> removeMe) { Comparator comparator = (self instanceof SortedSet) ? ((SortedSet) self).comparator() : null; final Set<T> ansSet = createSimilarSet(self); ansSet.addAll(self); if (removeMe != null) { for (T o1 : self) { for (Object o2 : removeMe) { boolean areEqual = (comparator != null) ? (comparator.compare(o1, o2) == 0) : coercedEquals(o1, o2); if (areEqual) { ansSet.remove(o1); } } } } return ansSet; }
java
public static <T> Set<T> minus(Set<T> self, Collection<?> removeMe) { Comparator comparator = (self instanceof SortedSet) ? ((SortedSet) self).comparator() : null; final Set<T> ansSet = createSimilarSet(self); ansSet.addAll(self); if (removeMe != null) { for (T o1 : self) { for (Object o2 : removeMe) { boolean areEqual = (comparator != null) ? (comparator.compare(o1, o2) == 0) : coercedEquals(o1, o2); if (areEqual) { ansSet.remove(o1); } } } } return ansSet; }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "minus", "(", "Set", "<", "T", ">", "self", ",", "Collection", "<", "?", ">", "removeMe", ")", "{", "Comparator", "comparator", "=", "(", "self", "instanceof", "SortedSet", ")", "?", "(", "(", "SortedSet", ")", "self", ")", ".", "comparator", "(", ")", ":", "null", ";", "final", "Set", "<", "T", ">", "ansSet", "=", "createSimilarSet", "(", "self", ")", ";", "ansSet", ".", "addAll", "(", "self", ")", ";", "if", "(", "removeMe", "!=", "null", ")", "{", "for", "(", "T", "o1", ":", "self", ")", "{", "for", "(", "Object", "o2", ":", "removeMe", ")", "{", "boolean", "areEqual", "=", "(", "comparator", "!=", "null", ")", "?", "(", "comparator", ".", "compare", "(", "o1", ",", "o2", ")", "==", "0", ")", ":", "coercedEquals", "(", "o1", ",", "o2", ")", ";", "if", "(", "areEqual", ")", "{", "ansSet", ".", "remove", "(", "o1", ")", ";", "}", "}", "}", "}", "return", "ansSet", ";", "}" ]
Create a Set composed of the elements of the first Set minus the elements of the given Collection. @param self a Set object @param removeMe the items to remove from the Set @return the resulting Set @since 1.5.0
[ "Create", "a", "Set", "composed", "of", "the", "elements", "of", "the", "first", "Set", "minus", "the", "elements", "of", "the", "given", "Collection", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L12897-L12912
12,696
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.minus
public static <T> Set<T> minus(Set<T> self, Iterable<?> removeMe) { return minus(self, asCollection(removeMe)); }
java
public static <T> Set<T> minus(Set<T> self, Iterable<?> removeMe) { return minus(self, asCollection(removeMe)); }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "minus", "(", "Set", "<", "T", ">", "self", ",", "Iterable", "<", "?", ">", "removeMe", ")", "{", "return", "minus", "(", "self", ",", "asCollection", "(", "removeMe", ")", ")", ";", "}" ]
Create a Set composed of the elements of the first Set minus the elements from the given Iterable. @param self a Set object @param removeMe the items to remove from the Set @return the resulting Set @since 1.8.7
[ "Create", "a", "Set", "composed", "of", "the", "elements", "of", "the", "first", "Set", "minus", "the", "elements", "from", "the", "given", "Iterable", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L12923-L12925
12,697
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.minus
public static <T> Set<T> minus(Set<T> self, Object removeMe) { Comparator comparator = (self instanceof SortedSet) ? ((SortedSet) self).comparator() : null; final Set<T> ansSet = createSimilarSet(self); for (T t : self) { boolean areEqual = (comparator != null)? (comparator.compare(t, removeMe) == 0) : coercedEquals(t, removeMe); if (!areEqual) ansSet.add(t); } return ansSet; }
java
public static <T> Set<T> minus(Set<T> self, Object removeMe) { Comparator comparator = (self instanceof SortedSet) ? ((SortedSet) self).comparator() : null; final Set<T> ansSet = createSimilarSet(self); for (T t : self) { boolean areEqual = (comparator != null)? (comparator.compare(t, removeMe) == 0) : coercedEquals(t, removeMe); if (!areEqual) ansSet.add(t); } return ansSet; }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "minus", "(", "Set", "<", "T", ">", "self", ",", "Object", "removeMe", ")", "{", "Comparator", "comparator", "=", "(", "self", "instanceof", "SortedSet", ")", "?", "(", "(", "SortedSet", ")", "self", ")", ".", "comparator", "(", ")", ":", "null", ";", "final", "Set", "<", "T", ">", "ansSet", "=", "createSimilarSet", "(", "self", ")", ";", "for", "(", "T", "t", ":", "self", ")", "{", "boolean", "areEqual", "=", "(", "comparator", "!=", "null", ")", "?", "(", "comparator", ".", "compare", "(", "t", ",", "removeMe", ")", "==", "0", ")", ":", "coercedEquals", "(", "t", ",", "removeMe", ")", ";", "if", "(", "!", "areEqual", ")", "ansSet", ".", "add", "(", "t", ")", ";", "}", "return", "ansSet", ";", "}" ]
Create a Set composed of the elements of the first Set minus the given element. @param self a Set object @param removeMe the element to remove from the Set @return the resulting Set @since 1.5.0
[ "Create", "a", "Set", "composed", "of", "the", "elements", "of", "the", "first", "Set", "minus", "the", "given", "element", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L12935-L12943
12,698
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.minus
public static <T> SortedSet<T> minus(SortedSet<T> self, Collection<?> removeMe) { return (SortedSet<T>) minus((Set<T>) self, removeMe); }
java
public static <T> SortedSet<T> minus(SortedSet<T> self, Collection<?> removeMe) { return (SortedSet<T>) minus((Set<T>) self, removeMe); }
[ "public", "static", "<", "T", ">", "SortedSet", "<", "T", ">", "minus", "(", "SortedSet", "<", "T", ">", "self", ",", "Collection", "<", "?", ">", "removeMe", ")", "{", "return", "(", "SortedSet", "<", "T", ">", ")", "minus", "(", "(", "Set", "<", "T", ">", ")", "self", ",", "removeMe", ")", ";", "}" ]
Create a SortedSet composed of the elements of the first SortedSet minus the elements of the given Collection. @param self a SortedSet object @param removeMe the items to remove from the SortedSet @return the resulting SortedSet @since 2.4.0
[ "Create", "a", "SortedSet", "composed", "of", "the", "elements", "of", "the", "first", "SortedSet", "minus", "the", "elements", "of", "the", "given", "Collection", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L12954-L12956
12,699
apache/groovy
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.minus
public static <T> SortedSet<T> minus(SortedSet<T> self, Iterable<?> removeMe) { return (SortedSet<T>) minus((Set<T>) self, removeMe); }
java
public static <T> SortedSet<T> minus(SortedSet<T> self, Iterable<?> removeMe) { return (SortedSet<T>) minus((Set<T>) self, removeMe); }
[ "public", "static", "<", "T", ">", "SortedSet", "<", "T", ">", "minus", "(", "SortedSet", "<", "T", ">", "self", ",", "Iterable", "<", "?", ">", "removeMe", ")", "{", "return", "(", "SortedSet", "<", "T", ">", ")", "minus", "(", "(", "Set", "<", "T", ">", ")", "self", ",", "removeMe", ")", ";", "}" ]
Create a SortedSet composed of the elements of the first SortedSet minus the elements of the given Iterable. @param self a SortedSet object @param removeMe the items to remove from the SortedSet @return the resulting SortedSet @since 2.4.0
[ "Create", "a", "SortedSet", "composed", "of", "the", "elements", "of", "the", "first", "SortedSet", "minus", "the", "elements", "of", "the", "given", "Iterable", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L12967-L12969