This file contains hidden or 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 MnemonicsCoder(words: List[String]) { | |
| private val mnemonics = Map('2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL", | |
| '6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ") | |
| /** Invert the mnemonics map to give a map from chars 'A' ... 'Z' to '2' ... '9' */ | |
| private val charCode: Map[Char, Char] = | |
| for ((digit, str) <- mnemonics; letter <- str) yield (letter -> digit) | |
| /** Maps a word to the digit string it can represent */ |
This file contains hidden or 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 org.drools.java8; | |
| import java.util.*; | |
| public class Java8Example { | |
| Rule rule1 = new Rule() | |
| .when( (Person person) -> person.getAge() >= 18 ) | |
| .and( (Person person, Pet pet) -> pet.getOwner() == person ) | |
| .then( (Person person, Pet pet) -> System.out.println("Person" + person + "is the owner of" + pet) ); |
This file contains hidden or 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.util.*; | |
| import java.util.function.*; | |
| import static java.util.Optional.*; | |
| public abstract class Try<T> { | |
| private Try() { } | |
| public static <T> Try<T> success(T value) { |
This file contains hidden or 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 org.junit.*; | |
| import static junit.framework.Assert.assertEquals; | |
| import static org.javaz.Try.attempt; | |
| public class TryTest { | |
| public String first(boolean throwEx) throws Exception { | |
| if (throwEx) throw new RuntimeException("Cannot read first"); | |
| return "6"; |
This file contains hidden or 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.util.Arrays; | |
| import java.util.Random; | |
| import java.util.concurrent.*; | |
| import java.util.function.Function; | |
| import java.util.stream.DoubleStream; | |
| public class Variance { | |
| private static final Random rand = new Random(); |
This file contains hidden or 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 org.drools.example.osgi; | |
| import org.kie.api.KieServices; | |
| import org.kie.api.builder.KieScanner; | |
| import org.kie.api.builder.ReleaseId; | |
| import org.kie.api.runtime.KieContainer; | |
| import org.kie.api.runtime.KieSession; | |
| import org.osgi.framework.BundleActivator; | |
| import org.osgi.framework.BundleContext; |
This file contains hidden or 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 org.drools.core.phreak; | |
| import org.drools.core.common.InternalWorkingMemory; | |
| import org.drools.core.common.Memory; | |
| import org.drools.core.common.MemoryFactory; | |
| import org.drools.core.common.NetworkNode; | |
| import org.drools.core.common.SynchronizedLeftTupleSets; | |
| import org.drools.core.reteoo.AccumulateNode; | |
| import org.drools.core.reteoo.AccumulateNode.AccumulateMemory; | |
| import org.drools.core.reteoo.AlphaNode; |
This file contains hidden or 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
| private List<ObjectSinkNode> getSortedSinks() { | |
| List<ObjectSinkNode> sinks = new ArrayList<ObjectSinkNode>(); | |
| if ( this.hashableSinks != null ) { | |
| for ( ObjectSinkNode sink = this.hashableSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode() ) { | |
| sinks.add(sink); | |
| } | |
| } | |
| if ( this.otherSinks != null ) { | |
| for ( ObjectSinkNode sink = this.otherSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode() ) { | |
| sinks.add(sink); |
This file contains hidden or 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 com.sun.tools.attach.AttachNotSupportedException; | |
| import com.sun.tools.attach.VirtualMachine; | |
| import sun.tools.attach.HotSpotVirtualMachine; | |
| import java.io.BufferedReader; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.io.InputStreamReader; | |
| import java.lang.management.ManagementFactory; | |
| import java.lang.management.RuntimeMXBean; |
This file contains hidden or 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
| parser grammar DRL6Expressions; | |
| options { | |
| language = Java; | |
| tokenVocab = DRL6Lexer; | |
| superClass=DRLExpressions; | |
| } | |
| @header { | |
| package org.drools.compiler.lang; |
OlderNewer