This file contains 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
syntax on | |
set ruler " Show the line and column numbers of the cursor. | |
set formatoptions+=o " Continue comment marker in new lines. | |
set textwidth=0 " Hard-wrap long lines as you type them. | |
set modeline " Enable modeline. | |
set esckeys " Cursor keys in insert mode. | |
set linespace=0 " Set line-spacing to minimum. | |
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J) | |
" More natural splits | |
set splitbelow " Horizontal split below current. |
This file contains 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
@Service | |
@Path("/") | |
public class MatrixResource { | |
@GET | |
@Path("/status/ping") | |
@Produces("text/plain") | |
public String ping(@MatrixParam("name") String name) { | |
return String.format("matrix variable name=%s", name); | |
} | |
} |
This file contains 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
@Service | |
@Path("/") | |
public class MatrixResource { | |
@GET | |
@Path("/{status}/ping") | |
@Produces("text/plain") | |
public String ping(@PathParam("status") PathSegment status) { | |
MultivaluedMap<String, String> matrixParameters = status.getMatrixParameters(); | |
String nameMatrixFromStatus = matrixParameters.getFirst("name"); | |
return String.format("matrix variable name=%s", nameMatrixFromStatus); |
This file contains 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
@RestController | |
public class MatrixResource { | |
@RequestMapping(value="/{status}/ping", method=RequestMethod.GET) | |
public String pong( | |
@PathVariable("status") String status, | |
@MatrixVariable(name="name", pathVar="status", required=false) String name) { | |
return String.format("matrix variable name=%s", name); | |
} | |
} |
This file contains 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
(defprotocol Command | |
(perform [this metric city param] | |
"Executes the command logic.")) |
This file contains 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
(deftype command-runner [] ;; ➊ | |
Command | |
(perform [this metric city day] ;; ➋ | |
(try | |
(run metric city day) ;; ➌ | |
(catch Exception e | |
(handle-error e))))) |
This file contains 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
;; Multimethod definition showing that the run | |
;; might have multiple informations. The identity | |
;; function is used as dispatcher function to | |
;; determine which implementation of run is to be | |
;; called | |
(defmulti run identity) | |
;; The run method implementation for temp. | |
(defmethod run "temp" | |
[city day] | |
(get-temp city day)) |
This file contains 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
public class Cat { | |
private AnimalSound sound; | |
public Cat(AnimalSound animalSound) { | |
this.sound = animalSound; | |
} | |
public void sing() { | |
soundEffect(sound); | |
} | |
} |
This file contains 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
Cat cat1 = new Cat(AnimalSoundLib.MEOW); | |
cat1.sing(); // meooww | |
Cat cat2 = new Cat(AnimalSoundLib.MEOOO); | |
cat2.sing(); // meoooo | |
// more cats |
This file contains 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
public class Lion extends Cat { | |
public Lion(AnimalSound animalSound) { | |
super(animalSound); | |
} | |
public void hunt() {} | |
// and other lion related methods. | |
} |