Skip to content

Instantly share code, notes, and snippets.

View juliofalbo's full-sized avatar
Looking for new technologies

Júlio Falbo juliofalbo

Looking for new technologies
View GitHub Profile
@juliofalbo
juliofalbo / BidirectionalBinaryTree.java
Last active December 12, 2018 12:14
Bidirectional Binary Tree
package br.com.uol.ps.so.api;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* @author Julio Falbo
@juliofalbo
juliofalbo / BTreePrinter.java
Created December 14, 2018 11:23
Bidirectional Binary Tree - Algorithm Test
package com.tradeshift.juliofalbo.challenge.tradeshift.test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class BTreePrinter {
public static <T extends Comparable<?>> void printNode(Node root) {
int maxLevel = BTreePrinter.maxLevel(root);
@juliofalbo
juliofalbo / CustomBeanUtils.java
Last active October 7, 2019 10:53
Custom Bean Utils
import java.beans.FeatureDescriptor;
import java.util.Objects;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
@juliofalbo
juliofalbo / RabbitMQConfig.java
Last active May 8, 2019 19:38
RabbitMQ Custom Autoconfig
package com.julio.poc.aync.config;
import static java.util.stream.Collectors.groupingBy;
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_SINGLETON;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
interface SomeInterfaceJava8 {
Integer customCalc(int a, int b);
default Integer calc(int a, int b) {
return (a + b);
}
}
class SomeImplementationJava8 implements SomeInterfaceJava8 {
@Override
public Integer customCalc(int a, int b) {
@juliofalbo
juliofalbo / DefaultMethodMultipleInheritance.java
Created October 11, 2019 19:32
DefaultMethodMultipleInheritance.java
interface OneInterface {
default void defaultMethod(){
System.out.println("One");
}
}
interface TwoInterface {
default void defaultMethod(){
System.out.println("Two");
}
public class FunctionalProgramming {
public static void main(String[] args) {
calc((a, b) -> a + b);
}
public static void calc(FunctionInterface functionInterface) {
Integer result = functionInterface.add(2, 2);
System.out.println(result);
}
public class StaticMethods {
public static void main(String[] args) {
InterfaceWithStaticMethod impl1 = (text) -> System.out.println("Custom Message " + text);
impl1.printWithCustomMessage("Text");
InterfaceWithStaticMethod.print("Text");
}
}
interface InterfaceWithStaticMethod {
void printWithCustomMessage(String text);
interface ConcatStringInterface {
String concat(String param1, String param2);
}
class ConcatStringImpl implements ConcatStringInterface {
public String concat(String param1, String param2) {
return param1 + param2;
}
}
@juliofalbo
juliofalbo / FI.java
Created November 4, 2019 20:39
Functional Interface
@FunctionalInterface
public interface FunctionalI {
void abstractMethod();
default String defaultMethod() {
return "defaultMethod";
}
static String staticMethod() {
return "staticMethod";