Skip to content

Instantly share code, notes, and snippets.

View mariofusco's full-sized avatar

Mario Fusco mariofusco

View GitHub Profile
1. “null is used in java to represent uninitialized fields”
I thought this is what constructors are for, isn’t it?
So either you can initialize a field in the constructor or it has a meaning in your domain to
leave that field empty and in this 2nd case it should be represented with an Optional.
2. “It is not possible to write a method that takes either an X or an Optional”
These methods clearly have 2 different semantics and then it is correct that they are 2
totally separated method. In the first case you pass a value of type X that for sure is
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.drools</groupId>
<artifactId>droolsjbpm-integration</artifactId>
<version>6.3.0-SNAPSHOT</version>
package mf.java8ws.examples.example15;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import java.util.stream.IntStream;
import static java.util.stream.Collectors.toList;
public class Main {
package org.drools.compiler.integrationtests;
import org.junit.Test;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieSession;
import org.kie.internal.utils.KieHelper;
import java.util.List;
public class NpeOnQueryTest {
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
/*
* Copyright 2005 JBoss Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import java.util.function.Predicate;
public class TypeInference {
public static void main( String[] args ) {
// compile
Pattern<String> p1 = pattern(String.class, expr(s -> s.length() > 3, id("expr1")));
// don't compile
Pattern<String> p2 = pattern(String.class, expr(s -> s.length() > 3).id("expr1"));
"ForkJoinPool.commonPool-worker-1@10167" daemon prio=5 tid=0x21 nid=NA waiting for monitor entry
java.lang.Thread.State: BLOCKED
blocks ForkJoinPool.commonPool-worker-3@10169
waiting for ForkJoinPool.commonPool-worker-3@10169 to release lock on <0x2880> (a org.drools.core.common.ProjectClassLoader$DefaultInternalTypesClassLoader)
at java.lang.ClassLoader.checkCerts(ClassLoader.java:887)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:668)
at java.lang.ClassLoader.defineClass(ClassLoader.java:761)
at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
at org.drools.core.common.ProjectClassLoader$DefaultInternalTypesClassLoader.defineClass(ProjectClassLoader.java:424)
at org.drools.core.common.ProjectClassLoader.defineType(ProjectClassLoader.java:209)
Exception in thread "main" java.lang.RuntimeException: Unable to get KieModule, Errors Existed: Error Messages:
Message [id=1, level=ERROR, path=src/main/java/com/wellsfargo/rules/RS7488_2_27__RF6366_339_50359134/Rules00e9ba29706046e390d6585be51d81f0RuleMethods1.java, line=49, column=1
text=code too large]
Message [id=2, level=ERROR, path=src/main/java/com/wellsfargo/rules/RS7488_2_27__RF6366_339_50359134/Rules00e9ba29706046e390d6585be51d81f0RuleMethods1.java, line=0, column=0
text=Java source of src/main/java/com/wellsfargo/rules/RS7488_2_27__RF6366_339_50359134/Rules00e9ba29706046e390d6585be51d81f0RuleMethods1.java in error:
package com.wellsfargo.rules.RS7488_2_27__RF6366_339_50359134;
import java.util.*;
import org.drools.model.*;
import org.drools.modelcompiler.dsl.pattern.D;