defoutside='This is outside'defdoSomething={println'do something'}defclosure={definside='This is inside'doSomething()printlnoutsideprintlninside}closure()doSomething()printlnoutsideprintlninside
// this is partial codesprotectedObjectdoInvokeMethod(StringmethodName,Objectname,Objectargs){Objectnode=null;Closureclosure=null;// creating node and attach it to variable node.// getting closure from arg and attach it to variable closure.if(closure!=null){// stack operationsetClosureDelegate(closure,node);closure.call();// stack operation}// node create completion and return it}protectedvoidsetClosureDelegate(Closureclosure,Objectnode){closure.setDelegate(this);}
// this is partial codespublicstatic<T>Tconfigure(ClosureconfigureClosure,Tdelegate,booleanconfigureableAware){returnconfigure(configureClosure,delegate,Closure.DELEGATE_FIRST,configureableAware);}privatestatic<T>Tconfigure(ClosureconfigureClosure,Tdelegate,intresolveStrategy,booleanconfigureableAware){ClosureBackedAction<T>action=newClosureBackedAction<T>(configureClosure,resolveStrategy,configureableAware);action.execute(delegate);returndelegate;}
// this is partial codespublicClosureBackedAction(Closureclosure,intresolveStrategy,booleanconfigureableAware){this.closure=closure;this.configureableAware=configureableAware;this.resolveStrategy=resolveStrategy;}publicvoidexecute(Tdelegate){// check closure is not null// checking cinfgureableAware is falseClosurecopy=(Closure)closure.clone();copy.setResolveStrategy(resolveStrategy);copy.setDelegate(delegate);if(copy.getMaximumNumberOfParameters()==0){copy.call();}else{copy.call(delegate);}}
publicabstractclassAbstractProjectextendsAbstractPluginAwareimplementsProjectInternal,DynamicObjectAware{// some codespublicvoidrepositories(ClosureconfigureClosure){ConfigureUtil.configure(configureClosure,getRepositories());}publicvoiddependencies(ClosureconfigureClosure){ConfigureUtil.configure(configureClosure,getDependencies());}// some codespublicTasktask(Stringtask){returntaskContainer.create(task);}publicTasktask(Objecttask){returntaskContainer.create(task.toString());}// some codes}
packageorg.mikeneck.multithreads;importorg.junit.*;importorg.junit.experimental.runners.Enclosed;importorg.junit.rules.TestName;importorg.junit.runner.RunWith;importjava.io.IOException;importjava.util.ArrayList;importjava.util.Arrays;importjava.util.List;importjava.util.concurrent.*;importstaticorg.hamcrest.Matchers.is;importstaticorg.junit.Assert.assertThat;/** * @author mike */@RunWith(Enclosed.class)publicclassSimpleSocketTest{publicstaticclassSingleClient{privatestaticfinalExecutorServiceSERVICE=Executors.newFixedThreadPool(1);privatestaticfinalintPORT=12521;privatestaticfinalStringLOCALHOST="localhost";privateSimpleClientclient;@RulepublicTestNametestName=newTestName();@BeforeClasspublicstaticvoidstart()throwsIOException{SERVICE.execute(newSimpleServer(PORT));}@Beforepublicvoidsetup()throwsIOException{client=newSimpleClient(LOCALHOST,PORT);}@AfterpublicvoidtearDown()throwsException{System.out.println(testName.getMethodName()+" is closing");client.close();}@AfterClasspublicstaticvoidend()throwsIOException{newSimpleClient(LOCALHOST,PORT).open().bye();}@TestpublicvoidsocketProcessing()throwsIOException{client.open();Stringmessage=client.sendMessage("Hello");System.out.println("Message from Server ["+message+"]");assertThat(message,is("Hello"));System.out.println("Assertion ends.");}}}
Returns the sorted list formed by merging all the sub-lists of ListOfLists. All sub-lists must be sorted prior to evaluating this function. When two elements compare equal, the element from the sub-list with the lowest position in ListOfLists is picked before the other element.
Returns the sorted list formed by merging List1 and List2. Both List1 and List2 must be sorted prior to evaluating this function. When two elements compare equal, the element from List1 is picked before the element from List2.
Returns the sorted list formed by merging List1 and List2. Both List1 and List2 must be sorted according to the ordering functionFun prior to evaluating this function. Fun(A, B) should return true if A compares less than or equal to B in the ordering, false otherwise. When two elements compare equal, the element from List1 is picked before the element from List2.
Returns the sorted list formed by merging List1, List2 and List3. All of List1, List2 and List3 must be sorted prior to evaluating this function. When two elements compare equal, the element from List1, if there is such an element, is picked before the other element, otherwise the element from List2 is picked before the element from List3.
The module_info/0 function in each module returns a list of {Key,Value} tuples with information about the module. Currently, the list contain tuples with the following Keys: attributes, compile, exports, and imports. The order and number of tuples may change without prior notice.
warning
The {imports,Value} tuple may be removed in a future release because Value is always an empty list. Do not write code that depends on it being present.
Partitions List into two lists, where the first list contains all elements for which Pred(Elem) returns true, and the second list contains all elements for which Pred(Elem) returns false.