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
return Optional.ofNullable(buildResult()) | |
.map(String::toUpperCase) | |
.orElse("n/a"); |
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
val value = doSomething() ?: "default 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
String value = Optional.ofNullable(doSomething()) | |
.orElse("default 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
public interface Collector<T, A, R> { | |
// Supplier that creates a new mutable result container. | |
Supplier<A> supplier(); | |
// Function that folds a value into the result container. | |
BiConsumer<A, T> accumulator(); | |
// Merges two partial results. | |
BinaryOperator<A> combiner(); |
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 Joinector implements Collector<CharSequence, StringJoiner, String> { | |
private final CharSequence delimiter; | |
public Joinector(CharSequence delimiter) { | |
this.delimiter = delimiter; | |
} | |
@Override | |
public Supplier<StringJoiner> supplier() { |
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 static Collector<CharSequence, StringJoiner, String> joinector(CharSequence delimiter) { | |
return Collector.of(() -> new StringJoiner(delimiter), // supplier | |
StringJoiner::add, // accumulator | |
StringJoiner::merge, // combiner | |
StringJoiner::toString); // finisher | |
} |
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
html { | |
--primary-color: #7B60F5; | |
--secondary-color: #F59560; | |
--font: sans-serif; | |
} |
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
html { | |
--default-margin: 1rem; | |
} | |
.my-class { | |
margin: var(--default-margin); | |
} |
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
.my-class { | |
--size-default: 16px; | |
--size-large: calc(2 * var(--size-default)); | |
--size-small: calc(var(--size-default) - 4px); | |
} |
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
:root { | |
--global-scope: 1rem; | |
} | |
.local-scope { | |
--local-scope: 0.2rem; | |
} | |
.local-scope .nested { | |
/* Can access global, and scope of .local-scope */ |