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
//This method is accepting documentId as argument and checks whether the document exists | |
boolean isExists = couchbaseTemplate.exists("E3"); |
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 List<Employee> getEmployeeUsingCustomQuery(String name) { | |
//creating query on the basis of empName | |
String statement = "select empName, empId, META().id AS _ID, META().cas AS _CAS from Bucket1 where empName=$empName"; | |
JsonObject placeHolder = JsonObject.create().put("empName", name); | |
N1qlQuery n1qlQuery = N1qlQuery.parameterized(statement, placeHolder); | |
//findbyN1QL method query the N!QL service and mapped to the Employee class. | |
return couchbaseTemplate.findByN1QL(n1qlQuery, Employee.class); | |
} |
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 Mono<UserDetails> callToExternalService() { | |
return WebClient | |
.builder() | |
.baseUrl("https://jsonplaceholder.typicode.com") | |
.build() | |
.get() | |
.uri("posts/1") | |
.exchange() | |
.flatMap(clientResponse -> clientResponse.bodyToMono(UserDetails.class)); |
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 Mono<UserDetails> callToExternalService() { | |
return client | |
.get() | |
.uri("posts/1") | |
.retrieve() | |
.bodyToMono(UserDetails.class); | |
} |
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
WebClient client = WebClient.builder() | |
.baseUrl("https://jsonplaceholder.typicode.com") | |
.build(); |
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
//create() Method accepts the String value as parameter. Here, we are initializing with the baseUrl. | |
WebClient webClient = WebClient.create("https://jsonplaceholder.typicode.com") |
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
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-webflux</artifactId> | |
</dependency> |
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 Person { | |
String id; | |
@FutureAndWithinSevenDays | |
String dateValue; | |
String 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
import javax.validation.ConstraintValidator; | |
import javax.validation.ConstraintValidatorContext; | |
import java.time.LocalDate; | |
import java.time.format.DateTimeFormatter; | |
import java.time.temporal.ChronoUnit; | |
public class FutureAndWithinSevenDaysValidator implements ConstraintValidator<FutureAndWithinSevenDays, String> { | |
@Override | |
public final boolean isValid(final String value, |
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 javax.validation.Constraint; | |
import javax.validation.Payload; | |
import java.lang.annotation.Documented; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
@Target({ElementType.METHOD, ElementType.FIELD}) | |
@Retention(RetentionPolicy.RUNTIME) |