Skip to content

Commit

Permalink
[Refactor] Revisit access modification keywords.
Browse files Browse the repository at this point in the history
Make some parts of the non-public API less visible and
final.
  • Loading branch information
meistermeier committed Jan 6, 2023
1 parent 88de36b commit ed387b0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ public Converters() {
this.internalTypeConverters.add(new EntityConverter(this));
}

/**
* Convert given value into target type.
*
* @param mapAccessor input value
* @param type target type
* @param <T> resulting target type
* @return converted value or throws {@link ConversionException} if no suitable converter can be found
*/
public <T> T convert(MapAccessor mapAccessor, Class<T> type) {
if (mapAccessor instanceof Value value) {
for (ValueConverter valueConverter : internalValueConverters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
* @author Gerrit Meier
*/
class DriverValueConverter implements ValueConverter {
final class DriverValueConverter implements ValueConverter {

private static final TypeSystem typeSystem = TypeSystem.getDefault();
private static final List<Type> SUPPORTED_SOURCE_VALUES_TYPES = List.of(typeSystem.LIST(), typeSystem.NULL());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @author Gerrit Meier
*/
public class EntityConverter implements TypeConverter<MapAccessor> {
final class EntityConverter implements TypeConverter<MapAccessor> {

private final TypeSystem typeSystem = TypeSystem.getDefault();
private final ObjectInstantiator objectInstantiator = new ObjectInstantiator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.meistermeier.neo4j.toolbelt.conversion;

import com.meistermeier.neo4j.toolbelt.conversion.Converters;
import org.neo4j.driver.Value;
import org.neo4j.driver.types.MapAccessor;

Expand Down Expand Up @@ -75,10 +74,10 @@ <T> Function<MapAccessor, T> createInstance(Class<T> entityClass, Converters con
};
}

@SuppressWarnings("unchecked")
/**
* Find the constructor with the most matching parameter count.
*/
@SuppressWarnings("unchecked")
private <T> Constructor<T> determineConstructor(Class<T> clazz, Map<String, Object> propertyValue) {
Constructor<T>[] constructors = (Constructor<T>[]) clazz.getDeclaredConstructors();
Constructor<T> instantiatingConstructorCandidate = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @author Gerrit Meier
*/
public class Mapper {
public final class Mapper {

/**
* A prepared {@link Mapper} instance.
Expand Down Expand Up @@ -67,7 +67,7 @@ public <T> Function<Record, Iterable<T>> createCollectionMapperFor(Class<T> type
return record -> mapAll(record, type);
}

<T> T mapOne(MapAccessor mapAccessor, Class<T> type) {
private <T> T mapOne(MapAccessor mapAccessor, Class<T> type) {
return converters.convert(mapAccessor, type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Neo4jDriverModule extends SimpleModule {
addSerializer(LocalTime.class, new Neo4jTypeSerializer<>());
}

private class Neo4jTypeSerializer<T> extends JsonSerializer<T> {
private static class Neo4jTypeSerializer<T> extends JsonSerializer<T> {

@Override
public void serialize(T value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
Expand Down

0 comments on commit ed387b0

Please sign in to comment.