diff --git a/README.md b/README.md
index 6521172b..ff5813e7 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ repositories {
}
dependencies {
- implementation group: 'org.radarbase', name: 'radar-commons', version: '0.12.3'
+ implementation group: 'org.radarbase', name: 'radar-commons', version: '0.13.0'
}
```
@@ -69,7 +69,7 @@ repositories {
}
dependencies {
- implementation group: 'org.radarbase', name: 'radar-commons-server', version: '0.12.3'
+ implementation group: 'org.radarbase', name: 'radar-commons-server', version: '0.13.0'
}
```
@@ -83,7 +83,7 @@ repositories {
}
dependencies {
- testImplementation group: 'org.radarbase', name: 'radar-commons-testing', version: '0.12.3'
+ testImplementation group: 'org.radarbase', name: 'radar-commons-testing', version: '0.13.0'
}
```
@@ -96,7 +96,7 @@ repositories {
}
dependencies {
- runtimeOnly group: 'org.radarbase', name: 'radar-commons-unsafe', version: '0.12.3'
+ runtimeOnly group: 'org.radarbase', name: 'radar-commons-unsafe', version: '0.13.0'
}
```
@@ -121,7 +121,7 @@ configurations.all {
}
dependencies {
- compile group: 'org.radarbase', name: 'radar-commons', version: '0.12.4-SNAPSHOT'
+ compile group: 'org.radarbase', name: 'radar-commons', version: '0.13.1-SNAPSHOT'
}
```
diff --git a/build.gradle b/build.gradle
index 05c480b0..58b8a60b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -29,7 +29,7 @@ subprojects {
// Configuration //
//---------------------------------------------------------------------------//
- version = '0.12.3'
+ version = '0.13.0'
group = 'org.radarbase'
ext.githubRepoName = 'RADAR-base/radar-commons'
diff --git a/radar-commons-unsafe/src/main/java/io/confluent/kafka/serializers/AbstractKafkaAvroDeserializer.java b/radar-commons-unsafe/src/main/java/io/confluent/kafka/serializers/AbstractKafkaAvroDeserializer.java
index 6f847a60..4a74187c 100644
--- a/radar-commons-unsafe/src/main/java/io/confluent/kafka/serializers/AbstractKafkaAvroDeserializer.java
+++ b/radar-commons-unsafe/src/main/java/io/confluent/kafka/serializers/AbstractKafkaAvroDeserializer.java
@@ -188,7 +188,7 @@ protected DatumReader> getDatumReader(Schema writerSchema, Schema readerSchema
}
/**
- * Normalizes the reader schema, puts the resolved schema into the cache.
+ * Normalizes the reader schema, puts the resolved schema into the cache.
*
* if the reader schema is provided, use the provided one
* if the reader schema is cached for the writer schema full name, use the cached value
diff --git a/radar-commons/src/main/java/org/radarbase/producer/rest/AvroDataMapperFactory.java b/radar-commons/src/main/java/org/radarbase/producer/rest/AvroDataMapperFactory.java
index e7a84623..51b68772 100644
--- a/radar-commons/src/main/java/org/radarbase/producer/rest/AvroDataMapperFactory.java
+++ b/radar-commons/src/main/java/org/radarbase/producer/rest/AvroDataMapperFactory.java
@@ -3,7 +3,6 @@
import static org.apache.avro.JsonProperties.NULL_VALUE;
import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -103,19 +102,9 @@ public AvroDataMapper createMapper(Schema from, Schema to, final Object defaultV
} catch (SchemaValidationException ex) {
if (defaultVal != null) {
if (defaultVal == NULL_VALUE) {
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- return null;
- }
- };
+ return obj -> null;
} else {
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- return defaultVal;
- }
- };
+ return obj -> defaultVal;
}
} else {
throw ex;
@@ -142,12 +131,7 @@ private static AvroDataMapper mapEnum(Schema from, final Schema to, Object defau
"Cannot map enum from non-string or enum type"));
}
if (containsAll) {
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- return new GenericData.EnumSymbol(to, obj.toString());
- }
- };
+ return obj -> new GenericData.EnumSymbol(to, obj.toString());
} else {
String defaultString = (String) defaultVal;
if (defaultString == null && to.hasEnumSymbol("UNKNOWN")) {
@@ -157,27 +141,19 @@ public Object convertAvro(Object obj) {
throw new SchemaValidationException(to, from, new IllegalArgumentException(
"Cannot map enum symbols without default value"));
} else {
- final GenericEnumSymbol symbol = new GenericData.EnumSymbol(to, defaultString);
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- String value = obj.toString();
- if (to.hasEnumSymbol(value)) {
- return new GenericData.EnumSymbol(to, value);
- } else {
- return symbol;
- }
+ GenericEnumSymbol> symbol = new GenericData.EnumSymbol(to, defaultString);
+ return obj -> {
+ String value = obj.toString();
+ if (to.hasEnumSymbol(value)) {
+ return new GenericData.EnumSymbol(to, value);
+ } else {
+ return symbol;
}
};
}
}
} else if (from.getType() == Schema.Type.ENUM && to.getType() == Schema.Type.STRING) {
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- return obj.toString();
- }
- };
+ return Object::toString;
} else {
throw new SchemaValidationException(to, from, new IllegalArgumentException(
"Cannot map unknown type with enum."));
@@ -244,40 +220,15 @@ public Number stringToNumber(String obj) {
} else {
switch (to.getType()) {
case INT:
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- return ((Number) obj).intValue();
- }
- };
+ return obj -> ((Number) obj).intValue();
case LONG:
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- return ((Number) obj).longValue();
- }
- };
+ return obj -> ((Number) obj).longValue();
case DOUBLE:
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- return Double.valueOf(obj.toString());
- }
- };
+ return obj -> Double.valueOf(obj.toString());
case FLOAT:
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- return ((Number) obj).floatValue();
- }
- };
+ return obj -> ((Number) obj).floatValue();
case STRING:
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- return obj.toString();
- }
- };
+ return Object::toString;
default:
throw new SchemaValidationException(to, from, new IllegalArgumentException(
"Cannot map numeric type with non-numeric type"));
@@ -318,14 +269,11 @@ private AvroDataMapper mapUnion(Schema from, Schema to, Object defaultVal)
if (defaultVal != null) {
final Object actualDefault = getDefaultValue(defaultVal, to);
final AvroDataMapper subMapper = createMapper(resolvedFrom, to, defaultVal);
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- if (obj == null) {
- return actualDefault;
- } else {
- return subMapper.convertAvro(obj);
- }
+ return obj -> {
+ if (obj == null) {
+ return actualDefault;
+ } else {
+ return subMapper.convertAvro(obj);
}
};
} else {
@@ -335,14 +283,11 @@ public Object convertAvro(Object obj) {
} else {
Schema toNonNull = nonNullUnionSchema(to);
final AvroDataMapper unionMapper = createMapper(resolvedFrom, toNonNull, defaultVal);
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- if (obj == null) {
- return null;
- } else {
- return unionMapper.convertAvro(obj);
- }
+ return obj -> {
+ if (obj == null) {
+ return null;
+ } else {
+ return unionMapper.convertAvro(obj);
}
};
}
@@ -357,16 +302,13 @@ private AvroDataMapper mapArray(Schema from, Schema to)
}
final AvroDataMapper subMapper = createMapper(from.getElementType(), to.getElementType(),
null);
- return new AvroDataMapper() {
- @Override
- public Object convertAvro(Object obj) {
- List array = (List) obj;
- List