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 utils | |
import akka.NotUsed | |
import akka.stream.FlowShape | |
import akka.stream.scaladsl.{Flow, GraphDSL, Merge, Partition} | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global |
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 akka.actor.ActorSystem | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.server.{Directives, Route} | |
import akka.stream.ActorMaterializer | |
import scala.concurrent.ExecutionContext | |
abstract class AkkaHttpApp(host: String = "localhost", port: Int = 8080) extends App with Directives { | |
implicit val sys: ActorSystem = ActorSystem() | |
implicit val mat: ActorMaterializer = ActorMaterializer() |
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.UUID | |
import akka.Done | |
import akka.actor.{Actor, ActorSystem, Props} | |
import akka.http.scaladsl.Http | |
import akka.http.scaladsl.server.Directives | |
import akka.stream.{ActorMaterializer, DelayOverflowStrategy} | |
import akka.stream.alpakka.sqs.scaladsl.{SqsAckSink, SqsSource} | |
import com.amazonaws.AmazonWebServiceRequest | |
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration |
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.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.concurrent.*; | |
import java.util.stream.Collectors; | |
class FutureWrapper<T> { | |
Future<T> future; | |
CompletableFuture<T> completableFuture; |
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.time.LocalDateTime; | |
import java.util.Scanner; | |
/** | |
* int/Integer i = 2000 + 2556 = 45.56; | |
* short/Short sh = 20; | |
* long/Long l = 20; | |
* boolean/Boolean = true/false; | |
* String = "texto" | |
* char/Char = 'c' |
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.springframework.data.repository.PagingAndSortingRepository; | |
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | |
import javax.persistence.Entity; | |
import javax.persistence.Table; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.boot.SpringApplication; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.Id; | |
@Entity |
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
abstract class Person | |
case class Worker(id: Long, name: String, company: String) extends Person | |
case class Student(id: Long, name: String, university: String) extends Person | |
object App { | |
def handle(p: Person) = { | |
p match { | |
case Worker(id, name, company) => println(s"this is a worker from $company") | |
case Student(id, name, university) => println(s"this is a student from $university") |
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
interface DatabaseAccess { | |
void save(Object entity); | |
} | |
class MySQL implements DatabaseAccess{ | |
@Override | |
void save(Object entity) { | |
//saving obj into MySQL | |
} | |
} |
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.validation.java; | |
import java.util.Collection; | |
import java.util.Collections; | |
import java.util.Set; | |
import java.util.stream.Collectors; | |
import java.util.stream.Stream; | |
/** | |
* @author Gabriel Francisco <[email protected]> |
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 object Validations { | |
trait Validator[F[_], T] { | |
def validate(field: F[T]): Boolean | |
} | |
trait NotEmpty[F[_], T] extends Validator[F, T] | |
trait NotBlank[F[_], T] extends Validator[F, T] | |
trait Contains[F[_], T] extends Validator[F, T] |