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
(defn wrap-blank-middleware | |
"Blank middleware demonstrating common structure." | |
[handler] | |
(fn [request] | |
; Do some magic with the request | |
(let [response (handler request)] | |
; Do some magic with the response | |
; and return the response. | |
response))) |
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.google.common.collect.ImmutableList; | |
interface Powerful {} | |
class Jedi implements Powerful {} | |
class Sith implements Powerful {} | |
public class ImmutableListInvariance { | |
public static void main(String[] args) { | |
ImmutableList<Jedi> jedi = ImmutableList.of(new Jedi()); | |
// ImmutableList<Powerful> powerfuls = jedi; // Error |
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
trait Powerful | |
class Jedi extends Powerful | |
class Sith extends Powerful | |
object ListCovariance { | |
def main(args: Array[String]): Unit = { | |
val jedi: List[Jedi] = List(new Jedi) | |
val powerfuls: List[Powerful] = jedi | |
val morePowerfuls = new Sith :: powerfuls | |
} |
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.LinkedList; | |
import java.util.List; | |
interface Powerful {} | |
class Jedi implements Powerful {} | |
class Sith implements Powerful {} | |
public class ListInvariance { | |
public static void main(String[] args) { | |
List<Jedi> jedi = new LinkedList<>(); |
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
trait Powerful | |
class Jedi extends Powerful | |
class Sith extends Powerful | |
object ArrayInvariance { | |
def main(args: Array[String]): Unit = { | |
val jedi: Array[Jedi] = Array(new Jedi) | |
val powerfuls: Array[Powerful] = jedi // Error | |
powerfuls(0) = new Sith | |
val hybrid: Jedi = jedi(0) |
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 Powerful {} | |
class Jedi implements Powerful {} | |
class Sith implements Powerful {} | |
public class ArrayCovariance { | |
public static void main(String[] args) { | |
Jedi[] jedi = new Jedi[] { new Jedi() }; | |
Powerful[] powerfuls = jedi; | |
powerfuls[0] = new Sith(); | |
Jedi hybrid = jedi[0]; |
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
{ | |
"sourceFolder": "", | |
"modelPackage": "cz.swsamuraj.rest.contractfirst.ws.model", | |
"apiPackage": "cz.swsamuraj.rest.contractfirst.ws.api", | |
"interfaceOnly": true | |
} |
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
plugins { | |
id 'org.hidetake.swagger.generator' version '2.4.2' | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'io.swagger:swagger-annotations:1.5.10' |
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
swagger: "2.0" | |
info: | |
version: "0.1.0" | |
title: "The Ultimate Question." | |
paths: | |
/question: | |
get: | |
summary: "Asks the ultimate question" |
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
(ns blog-ring.core | |
(:require [ring.adapter.jetty :as jetty] | |
[ring.util.response :refer [response]] | |
[ring.middleware.params :refer [wrap-params]] | |
[ring.middleware.keyword-params :refer [wrap-keyword-params]])) | |
(defn handler [request] | |
(response | |
(str "<h1>One Ring rules them all!</h1>" | |
"<ul><li>Query string: " |