View PatternMatching.java
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
switch(i) { | |
case null -> System.out.println("It's a null!"); | |
case Integer s && s < 10 -> System.out.println("It's a number smaller than 10"); | |
case String s && s.length() < 20 -> System.out.println("Short string"); | |
case String s -> System.out.println("Long String"); | |
default -> System.out.println("It's something else"); | |
} |
View Sealed.java
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
package com.example.geometry; | |
public abstract sealed class Shape | |
permits Circle, Rectangle, Square { ... } | |
public final class Circle extends Shape { ... } | |
public sealed class Rectangle extends Shape | |
permits TransparentRectangle, FilledRectangle { ... } | |
public final class TransparentRectangle extends Rectangle { ... } |
View Api.java
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
@Operation( | |
summary = "List all entries from database", | |
description = "Returns all entries that was saved to our database" | |
) | |
@ApiResponses(value = { | |
@ApiResponse(responseCode = "200", description = "Entry was added to database"), | |
@ApiResponse(responseCode = "500", description = "Something went wrong, entry was not added") | |
}) | |
@GetMapping("/api/list") |
View CustomValidatorController.java
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 CustomValidatorController { | |
@PostMapping("/zipCode") | |
@ResponseBody | |
public String zipCodeBody( | |
@RequestBody @Valid RequestWithZipCode body // #1 | |
) { | |
return "OK! Everything is valid"; | |
} | |
} |
View Dockerfile
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
FROM adoptopenjdk/openjdk14:alpine-jre | |
WORKDIR /opt | |
COPY target/spring-docker.jar application.jar | |
ENTRYPOINT ["java", "-jar", "application.jar"] |
View Pet.java
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 Pet { | |
@NotBlank | |
private String name; | |
public Pet(@NotBlank String name) { | |
this.name = name; | |
} | |
public String getName() { | |
return name; |
View TitleSearch.java
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
import java.util.*; | |
import java.util.concurrent.atomic.AtomicInteger; | |
public class TitleSearch { | |
public static void main(String[] args) { | |
final Scanner sc = new Scanner(System.in); | |
List<String> titles = new ArrayList<>(); | |
final int n = sc.nextInt(); | |
sc.nextLine(); |
View TitleSearch.java
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 TitleSearch { | |
public static void main(String[] args) { | |
final Scanner sc = new Scanner(System.in); | |
List<String> titles = new ArrayList<>(); | |
final int n = sc.nextInt(); | |
sc.nextLine(); | |
for (int i = 0; i < n; ++i) { | |
titles.add(sc.nextLine()); | |
} |
View action.php
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
<?php | |
/* | |
* Plugin Name: Sample Extension | |
* Plugin URI: http://wpblog.pl | |
* Description: Sample Extension to show wordpress plugins functionality | |
* Version: 1.0 | |
* Author: WP Blog | |
* Author URI: http://wpblog.pl | |
*/ |
View Client.java
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
Vision visionClient = new Vision.Builder(httpTransport, jsonFactory, credential) | |
.setApplicationName(APPLICATION_NAME) | |
.build(); |
NewerOlder