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 IncorrectCoupling { | |
public static class Points{ | |
private String productId; | |
private Long totalPoints; | |
private PointsMappingExternalSystem pointsMappingExternalSystem; | |
private PointsMultiplierExternalSystem pointsMultiplierExternalSystem; | |
public Double calculateTotalPoints(){ | |
return pointsMappingExternalSystem.getPointsMappingFromExternalSystem().stream().map(PointsMapping::getPoints).reduce(0d, Double::sum) |
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 void exampleMinimizingIfElse() { | |
final List<String> someExampleArray = new ArrayList<>(); | |
Optional.ofNullable(someExampleArray).orElse(Collections.emptyList()).forEach(this::doSomethingWithIt); | |
ObjectUtils.defaultIfNull(someExampleArray, Collections.<String>emptyList()).forEach(this::doSomethingWithIt); | |
returnEmptyArrayIfNecessary(someExampleArray).forEach(this::doSomethingWithIt); | |
} |
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 void buildThumbnailWithUrl() { | |
final List<Thumbnail> rawThumbnailList = getThumbnailListFromSomeWhere(); | |
final String appropriateCdn = getTheRightCdnBasedOnRegion(); | |
final String defaultCdn = getDefaultCdn(); | |
final List<Thumbnail> thumbnailListWithCdn = rawThumbnailList.stream().map(eachThumbnail -> { | |
final String cdnChose = eachThumbnail.isHasLarge() ? defaultCdn : appropriateCdn; | |
eachThumbnail.setThumbnailUri(cdnChose + eachThumbnail.getThumbnailUri()); | |
return eachThumbnail; | |
}).collect(Collectors.toList()); |
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<SomeDataFull> methodWithNoAbstraction() { | |
// get data from DB for instance | |
final List<SomeData> listOfDataFromDb = getDataFromDb(); // a.1 | |
final List<String> someDataRetrievedIds = listOfDataFromDb.stream().map(SomeData::getId).collect(Collectors.toList()); //a.2 | |
final Map<String, Boolean> someDataIdMapping = getVerificationFromExternalSystem(someDataRetrievedIds) | |
.stream().collect(Collectors.toMap(SomeDataVerification::getId, SomeDataVerification::isOk)); | |
final List<SomeData> verifiedSomeData = listOfDataFromDb.stream().filter(eachData -> someDataIdMapping.getOrDefault(eachData.getId(), false)) //a.3 | |
.collect(Collectors.toList()); |
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
spring: | |
kafka: | |
bootstrap-servers: localhost:9092 | |
properties: | |
schema.registry.url: http://localhost:8081 | |
producer: | |
key-serializer: org.apache.kafka.common.serialization.StringSerializer | |
value-serializer: io.confluent.kafka.serializers.KafkaAvroSerializer | |
properties: | |
value.subject.name.strategy: io.confluent.kafka.serializers.subject.RecordNameStrategy # so that the name of the subject will be derived from record name ie, org.maziz.something |
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
{ | |
"namespace": "org.maz.schema", | |
"type": "record", | |
"name": "SplitSampleData", | |
"fields": [ | |
{ | |
"name": "SplitSampleData", | |
"type": { | |
"avro.java.string": "String", | |
"type": "string" |
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
{ | |
"namespace": "org.maz.schema", | |
"name": "SplitEnumerationSample", | |
"type": "enum", | |
"symbols": [ | |
"SAMPLE1", | |
"SAMPLE2", | |
"SAMPLE3" | |
], | |
"default": "SAMPLE1" |
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
{ | |
"namespace": "org.maz.schema", | |
"type": "record", | |
"name": "FlatSampleData", | |
"fields": [ | |
{ | |
"name": "FlatSampleData", | |
"type": { | |
"avro.java.string": "String", | |
"type": "string" |
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
<plugin> | |
<groupId>io.confluent</groupId> | |
<artifactId>kafka-schema-registry-maven-plugin</artifactId> | |
<version>${confluent.platform.version}</version> | |
<executions> | |
<execution> | |
<phase>initialize</phase> | |
<goals> | |
<goal>download</goal> | |
</goals> |
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
<plugin> | |
<groupId>io.confluent</groupId> | |
<artifactId>kafka-schema-registry-maven-plugin</artifactId> | |
<version>${confluent.platform.version}</version> | |
<executions> | |
<execution> | |
<phase>initialize</phase> | |
<goals> | |
<goal>register</goal> | |
</goals> |
NewerOlder