Skip to content

Instantly share code, notes, and snippets.

View agustarc's full-sized avatar
🎯
Focusing

Leopold agustarc

🎯
Focusing
View GitHub Profile
@Module
public class SampleModule {
private static final int CONNECT_TIMEOUT = 15;
private static final int WRITE_TIMEOUT = 15;
private static final int READ_TIMEOUT = 15;
private static final String baseUrl; // your base url;
@Provides
@Singleton
Cache provideOkHttpCache(Application application) {
@Module
public class SampleModule {
private static final int CONNECT_TIMEOUT = 15;
private static final int WRITE_TIMEOUT = 15;
private static final int READ_TIMEOUT = 15;
private static final String baseUrl; // your base url;
@Provides
@Singleton
Cache provideOkHttpCache(Application application) {
Cart cart = response.getCart();
if (cart != null) {
Product product = cart.getProduct();
if (product != null) {
System.out.println(product.getName());
}
}
Optional.ofNullable(response.getCart()).ifPresent(c -> {
Optional.ofNullable(c.getProduct()).ifPresent(p -> System.out.println(p.getName()));
});
Optional<Cart> optional = Optional.ofNullable(response.getCart()).orElse(new Cart());
Optional<Cart> optional = Optional.ofNullable(response.getCart()).orElseThrow(IllegalStateException::new);
for (Product product : products) {
if (product.getId() == productId) {
return product;
}
}
Stream.of(products).filter(p -> p.getId() == productId).findFirst();
Stream.of(products).filter(p -> p.getId() == productId).forEach(Product::printPrice);
public int sum(int a, int b) {
return a + b;
}
fun sum(a: Int, b: Int): Int {
return a + b
}