This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package my.mbb.incr2; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.net.URISyntaxException; | |
import java.net.URL; | |
import com.adobe.fdf.FDFDoc; | |
import com.adobe.fdf.exceptions.FDFException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//val cannot be change | |
val two = 1 + 1 | |
//functions are object | |
object Timer { | |
def oncePerSecond(callback: () => Unit) { | |
while (true) { callback(); Thread sleep 1000 } | |
} | |
def timeFlies() { | |
println("time flies like an arrow...") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import org.apache.camel.Exchange; | |
import org.apache.camel.builder.RouteBuilder; | |
import org.apache.camel.test.junit4.CamelTestSupport; | |
import org.junit.Test; | |
public class FirstTest extends CamelTestSupport { | |
@Override | |
protected RouteBuilder createRouteBuilder() throws Exception { | |
return new RouteBuilder() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import org.apache.camel.Exchange; | |
import org.apache.camel.test.junit4.CamelSpringTestSupport; | |
import org.junit.Test; | |
import org.springframework.context.support.AbstractXmlApplicationContext; | |
import org.springframework.context.support.ClassPathXmlApplicationContext; | |
public class SpringFirstTest extends CamelSpringTestSupport { | |
protected AbstractXmlApplicationContext createApplicationContext() { | |
return new ClassPathXmlApplicationContext("CONTEXT-INF/firststep.xml"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd | |
http://camel.apache.org/schema/spring | |
http://camel.apache.org/schema/spring/camel-spring.xsd"> | |
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> | |
<route> | |
<from uri="file://target/inbox" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
String name | |
int age | |
} | |
//no accessors method | |
Person person = new Person() | |
person.name = "goku" | |
println "helloo ${person.name}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list = [] | |
assert list.isEmpty() | |
list.add("ayam") | |
list.add "babun" //optional parentheses, except if it doesnt have any argument | |
list << "cicak" //operator overloading | |
assert list.size == 3 | |
println list | |
def tambah = list.&add //method pointer in action | |
tambah "dugong" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
def name //duck typing | |
def age | |
def getName() { //override default getter | |
"will not be printed" | |
"my name is ${name}" //return is optional, last statement is taken | |
} | |
} | |
person = new Person(name:"goku") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
def name | |
def spouse | |
def age | |
} | |
candidate1 = new Person(name:"bill", spouse: new Person(name:"lengloy")) | |
candidate1.spouse.spouse = candidate1 | |
assert candidate1.spouse.spouse != null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def teamMembers1 = ["p1", "p2", "p3"] //by default arrayList | |
teamMembers1 << "p4" | |
assert teamMembers1.size() == 4 | |
teamMembers2 = ["b1", "b2"] as Set //setting the type | |
teamMembers2 << "b1" | |
assert teamMembers2.size() == 2 | |
emptyList = [] //empty list | |
assert emptyList.size() == 0 |
OlderNewer