From 545079100aa2d89585f0d2a3cd38a402d324b3a2 Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Tue, 24 Sep 2024 17:46:19 +0100 Subject: [PATCH] style: fix at checkstyle Signed-off-by: Otavio Santana --- .../arangodb/communication/ArangoDBBuilders.java | 3 +-- .../arangodb/communication/ArangoDBUtil.java | 13 +++++-------- .../DefaultArangoDBDocumentManager.java | 15 +++++++-------- .../arangodb/communication/QueryAQLConverter.java | 2 +- .../arangodb/mapping/ArangoDBExtension.java | 2 +- .../driver/DefaultJsonbSupplier.java | 13 ++++++++----- .../attachment/ByteArrayEntityAttachment.java | 4 +++- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBBuilders.java b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBBuilders.java index 1ce3a87d9..4397fb595 100644 --- a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBBuilders.java +++ b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBBuilders.java @@ -19,7 +19,6 @@ import org.eclipse.jnosql.communication.Configurations; import org.eclipse.jnosql.communication.Settings; -import java.util.Arrays; import java.util.List; import static java.util.Arrays.asList; @@ -62,7 +61,7 @@ static void load(Settings settings, ArangoDBBuilder arangoDB) { settings.get(ArangoDBConfigurations.PROTOCOL).map(Object::toString).map(Protocol::valueOf) .ifPresent(arangoDB::protocol); - settings.prefixSupplier(Arrays.asList(ArangoDBConfigurations.HOST, Configurations.HOST)) + settings.prefixSupplier(asList(ArangoDBConfigurations.HOST, Configurations.HOST)) .stream() .map(Object::toString) .map(ArangoDBHost::new) diff --git a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBUtil.java b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBUtil.java index 3da5eaa34..b4f4caa1d 100644 --- a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBUtil.java +++ b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBUtil.java @@ -19,7 +19,6 @@ import com.arangodb.entity.BaseDocument; import com.arangodb.entity.CollectionEntity; import org.eclipse.jnosql.communication.Value; - import org.eclipse.jnosql.communication.ValueUtil; import org.eclipse.jnosql.communication.semistructured.CommunicationEntity; import org.eclipse.jnosql.communication.semistructured.Element; @@ -33,8 +32,6 @@ import java.util.function.Function; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; import static java.util.Collections.singletonMap; import static java.util.stream.Collectors.toList; @@ -85,7 +82,7 @@ static CommunicationEntity toEntity(BaseDocument document) { Map properties = document.getProperties(); List documents = properties.keySet().stream() .map(k -> toDocument(k, properties)) - .collect(Collectors.toList()); + .collect(toList()); documents.add(Element.of(KEY, document.getKey())); documents.add(Element.of(ID, document.getId())); @@ -110,7 +107,7 @@ private static Element toDocument(String key, Map properties) { if (value instanceof Map map) { return Element.of(key, map.keySet() .stream().map(k -> toDocument(k.toString(), map)) - .collect(Collectors.toList())); + .collect(toList())); } if (isADocumentIterable(value)) { List> documents = new ArrayList<>(); @@ -141,7 +138,7 @@ private static Object convert(Value value) { return getMap(val); } if (isSudDocumentList(val)) { - return StreamSupport.stream(Iterable.class.cast(val).spliterator(), false) + return stream(Iterable.class.cast(val).spliterator(), false) .map(ArangoDBUtil::getMap).collect(toList()); } return val; @@ -158,12 +155,12 @@ private static Object getMap(Object val) { } private static boolean isSudDocumentList(Object value) { - return value instanceof Iterable && StreamSupport.stream(Iterable.class.cast(value).spliterator(), false). + return value instanceof Iterable && stream(Iterable.class.cast(value).spliterator(), false). allMatch(d -> d instanceof Iterable && isSudDocument(d)); } private static boolean isSudDocument(Object value) { - return value instanceof Iterable && StreamSupport.stream(Iterable.class.cast(value).spliterator(), false). + return value instanceof Iterable && stream(Iterable.class.cast(value).spliterator(), false). allMatch(Element.class::isInstance); } diff --git a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/DefaultArangoDBDocumentManager.java b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/DefaultArangoDBDocumentManager.java index 88d1d1104..6bad571bb 100644 --- a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/DefaultArangoDBDocumentManager.java +++ b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/DefaultArangoDBDocumentManager.java @@ -26,7 +26,6 @@ import java.time.Duration; import java.util.Map; -import java.util.Objects; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -61,7 +60,7 @@ public String name() { @Override public CommunicationEntity insert(CommunicationEntity entity) { - Objects.requireNonNull(entity, "entity is required"); + requireNonNull(entity, "entity is required"); String collectionName = entity.name(); checkCollection(collectionName); BaseDocument baseDocument = ArangoDBUtil.getBaseDocument(entity); @@ -73,7 +72,7 @@ public CommunicationEntity insert(CommunicationEntity entity) { @Override public CommunicationEntity update(CommunicationEntity entity) { - Objects.requireNonNull(entity, "entity is required"); + requireNonNull(entity, "entity is required"); String collectionName = entity.name(); checkCollection(collectionName); String id = entity.find(ID, String.class) @@ -90,7 +89,7 @@ public CommunicationEntity update(CommunicationEntity entity) { @Override public Iterable update(Iterable entities) { - Objects.requireNonNull(entities, "entities is required"); + requireNonNull(entities, "entities is required"); return StreamSupport.stream(entities.spliterator(), false) .map(this::update) .collect(Collectors.toList()); @@ -135,7 +134,7 @@ public Stream select(SelectQuery query) throws NullPointerE @Override public long count(String documentCollection) { - Objects.requireNonNull(documentCollection, "document collection is required"); + requireNonNull(documentCollection, "document collection is required"); String aql = "RETURN LENGTH(" + documentCollection + ")"; ArangoCursor query = arangoDB.db(database).query(aql, Object.class, emptyMap(), null); return StreamSupport.stream(query.spliterator(), false).findFirst().map(Number.class::cast) @@ -188,7 +187,7 @@ public CommunicationEntity insert(CommunicationEntity entity, Duration ttl) { @Override public Iterable insert(Iterable entities) { - Objects.requireNonNull(entities, "entities is required"); + requireNonNull(entities, "entities is required"); return StreamSupport.stream(entities.spliterator(), false) .map(this::insert) .collect(Collectors.toList()); @@ -196,8 +195,8 @@ public Iterable insert(Iterable entiti @Override public Iterable insert(Iterable entities, Duration ttl) { - Objects.requireNonNull(entities, "entities is required"); - Objects.requireNonNull(ttl, "ttl is required"); + requireNonNull(entities, "entities is required"); + requireNonNull(ttl, "ttl is required"); return StreamSupport.stream(entities.spliterator(), false) .map(e -> this.insert(e, ttl)) .collect(Collectors.toList()); diff --git a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/QueryAQLConverter.java b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/QueryAQLConverter.java index 505e5c1d1..9b2fdc7b9 100644 --- a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/QueryAQLConverter.java +++ b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/QueryAQLConverter.java @@ -157,7 +157,7 @@ private static void definesCondition(CriteriaCondition condition, if (isFirstCondition(aql, counter)) { aql.append(AND); } - definesCondition(dc, aql, params, entity, ++counter); + definesCondition(dc, aql, params, entity, counter +1); } return; case OR: diff --git a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/mapping/ArangoDBExtension.java b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/mapping/ArangoDBExtension.java index d3369d449..8162a2be3 100644 --- a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/mapping/ArangoDBExtension.java +++ b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/mapping/ArangoDBExtension.java @@ -33,7 +33,7 @@ void onAfterBeanDiscovery(@Observes final AfterBeanDiscovery afterBeanDiscovery) LOGGER.info("Starting the onAfterBeanDiscovery with elements number: " + crudTypes.size()); - crudTypes.forEach(type -> afterBeanDiscovery.addBean(new ArangoDBRepositoryBean(type))); + crudTypes.forEach(type -> afterBeanDiscovery.addBean(new ArangoDBRepositoryBean<>(type))); LOGGER.info("Finished the onAfterBeanDiscovery"); } diff --git a/jnosql-database-commons/src/main/java/org/eclipse/jnosql/communication/driver/DefaultJsonbSupplier.java b/jnosql-database-commons/src/main/java/org/eclipse/jnosql/communication/driver/DefaultJsonbSupplier.java index d843374fc..7b16c7b6c 100644 --- a/jnosql-database-commons/src/main/java/org/eclipse/jnosql/communication/driver/DefaultJsonbSupplier.java +++ b/jnosql-database-commons/src/main/java/org/eclipse/jnosql/communication/driver/DefaultJsonbSupplier.java @@ -26,13 +26,16 @@ enum DefaultJsonbSupplier implements JsonbSupplier { INSTANCE; - { - JsonbConfig config = new JsonbConfig().withPropertyVisibilityStrategy(new PrivateVisibilityStrategy()); - this.json = JsonbBuilder.newBuilder().withConfig(config).build(); - } - private final Jsonb json; + DefaultJsonbSupplier() { + JsonbConfig config = new JsonbConfig() + .withPropertyVisibilityStrategy(new PrivateVisibilityStrategy()); + this.json = JsonbBuilder.newBuilder() + .withConfig(config) + .build(); + } + @Override public Jsonb get() { return json; diff --git a/jnosql-database-commons/src/main/java/org/eclipse/jnosql/communication/driver/attachment/ByteArrayEntityAttachment.java b/jnosql-database-commons/src/main/java/org/eclipse/jnosql/communication/driver/attachment/ByteArrayEntityAttachment.java index 19d29bda1..074d47e68 100644 --- a/jnosql-database-commons/src/main/java/org/eclipse/jnosql/communication/driver/attachment/ByteArrayEntityAttachment.java +++ b/jnosql-database-commons/src/main/java/org/eclipse/jnosql/communication/driver/attachment/ByteArrayEntityAttachment.java @@ -17,6 +17,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Arrays; /** * Default representation of {@link EntityAttachment} for in-memory data. @@ -33,7 +34,8 @@ public ByteArrayEntityAttachment(String name, String contentType, long lastModif this.name = name; this.contentType = contentType; this.lastModified = lastModified; - this.data = data; + this.data = data != null ? Arrays.copyOf(data, data.length) : new byte[0]; + } @Override