-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from eclipse/isolate-mongodb
[BUG] MongoDB conversions applied also to other databases
- Loading branch information
Showing
12 changed files
with
128 additions
and
32 deletions.
There are no files selected for viewing
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
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
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
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
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
48 changes: 48 additions & 0 deletions
48
...n/java/org/eclipse/jnosql/databases/mongodb/communication/MongoDBValueWriteDecorator.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
* | ||
* Contributors: | ||
* | ||
* Otavio Santana | ||
*/ | ||
package org.eclipse.jnosql.databases.mongodb.communication; | ||
|
||
import org.eclipse.jnosql.communication.ValueWriter; | ||
import org.eclipse.jnosql.communication.ValueWriterDecorator; | ||
|
||
import java.util.UUID; | ||
|
||
final class MongoDBValueWriteDecorator<T, S> implements ValueWriter<T, S> { | ||
|
||
@SuppressWarnings("rawtypes") | ||
static final ValueWriter MONGO_DB_VALUE_WRITER = new MongoDBValueWriteDecorator(); | ||
|
||
@SuppressWarnings("rawtypes") | ||
private static final ValueWriter DEFAULT = ValueWriterDecorator.getInstance(); | ||
|
||
private static final UUIDValueWriter UUID_VALUE_WRITER = new UUIDValueWriter(); | ||
|
||
|
||
@Override | ||
public boolean test(Class<?> type) { | ||
return UUID_VALUE_WRITER.test(type) || DEFAULT.test(type); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public S write(T type) { | ||
if(type != null && UUID_VALUE_WRITER.test(type.getClass())) { | ||
return (S) UUID_VALUE_WRITER.write((UUID) type); | ||
} else { | ||
return (S) DEFAULT.write(type); | ||
} | ||
} | ||
|
||
} |
1 change: 0 additions & 1 deletion
1
...mongodb/src/main/resources/META-INF/services/org.eclipse.jnosql.communication.ValueReader
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
org.eclipse.jnosql.databases.mongodb.communication.BinaryValueReader | ||
org.eclipse.jnosql.databases.mongodb.communication.UUIDValueReader |
1 change: 0 additions & 1 deletion
1
...mongodb/src/main/resources/META-INF/services/org.eclipse.jnosql.communication.ValueWriter
This file was deleted.
Oops, something went wrong.
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
26 changes: 26 additions & 0 deletions
26
...l-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/integration/MongoDBBook.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
* | ||
* Contributors: | ||
* | ||
* Otavio Santana | ||
* Alessandro Moscatelli | ||
*/ | ||
package org.eclipse.jnosql.databases.mongodb.integration; | ||
|
||
import jakarta.nosql.Column; | ||
import jakarta.nosql.Entity; | ||
import jakarta.nosql.Id; | ||
|
||
import java.util.UUID; | ||
|
||
@Entity | ||
public record MongoDBBook(@Id UUID id, @Column String title, @Column String author) { | ||
} |
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
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