##New stuff in Java 1.7
Method or Field: java.applet.Applet.isValidateRoot
Method or Field: java.awt.Component.revalidate
Method or Field: java.awt.Container.isValidateRoot
Method or Field: java.awt.event.InvocationEvent.isDispatched
##New stuff in Java 1.7
Method or Field: java.applet.Applet.isValidateRoot
Method or Field: java.awt.Component.revalidate
Method or Field: java.awt.Container.isValidateRoot
Method or Field: java.awt.event.InvocationEvent.isDispatched
| // Requires Groovy 2.3 and Java 8 | |
| import java.time.* | |
| // Add a next() method | |
| LocalDate.metaClass.next = { delegate.plusDays( 1 ) } | |
| // Then print the next two weeks worth of dates | |
| (LocalDate.now()..LocalDate.now().plusWeeks( 2 )).each { | |
| println it |
| import java.util.Random; | |
| import java.util.concurrent.ConcurrentHashMap; | |
| import java.util.concurrent.atomic.LongAdder; | |
| import java.util.stream.IntStream; | |
| public class LongAdderTest { | |
| ConcurrentHashMap<Integer,LongAdder> frequencyMap = new ConcurrentHashMap<>() ; | |
| Random rnd = new Random() ; | |
| void run() { |
| package test; | |
| import java.math.BigInteger; | |
| import java.util.function.Function; | |
| public class YCombinatorFactorial<T> { | |
| private interface Improver<T> { | |
| Function<T,T> apply( Improver<T> f ) ; | |
| } |
| package sample; | |
| import javafx.animation.AnimationTimer; | |
| import javafx.fxml.FXML; | |
| import javafx.fxml.Initializable; | |
| import javafx.scene.control.Label; | |
| import javafx.scene.paint.Color; | |
| import rx.Observable; | |
| import rx.subscriptions.Subscriptions; |
| import groovy.transform.* | |
| import groovyx.gpars.actor.* | |
| import groovyx.gpars.group.* | |
| @Immutable class Calculate {} | |
| @Immutable class Work { int start, nrOfElements } | |
| @Immutable class Result { double value } | |
| @Immutable class PiApproximation { double pi ; long duration } | |
| double calculatePiFor( int start, int nrOfElements ) { |
| @Grab( 'com.typesafe.akka:akka-actor_2.10:2.3.2' ) | |
| @Grab( 'com.typesafe:config:1.2.0' ) | |
| import groovy.transform.Immutable | |
| import akka.actor.ActorRef | |
| import akka.actor.ActorSystem | |
| import akka.actor.Props | |
| import akka.actor.UntypedActor | |
| import akka.actor.UntypedActorFactory | |
| import akka.routing.RoundRobinRouter | |
| import scala.concurrent.duration.Duration |
| // Bad example of @ForceOverride... enjoy! (?) | |
| import groovy.transform.* | |
| class BasicIntQueue extends LinkedList<Integer> { | |
| Integer get() { | |
| this.poll() | |
| } | |
| void put( Integer x ) { |
Based on the Ruby version here, blogged about here by @otobrglez
| @Grab( 'com.netflix.rxjava:rxjava-groovy:0.17.1' ) | |
| import rx.* | |
| import rx.schedulers.* | |
| import java.util.concurrent.TimeUnit | |
| // Emit the date every second | |
| def date = Observable.create { observer -> | |
| Schedulers.newThread().schedulePeriodically( { inner -> | |
| observer.onNext( new Date() ) | |
| }, 0, 1000, TimeUnit.MILLISECONDS ) |