File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
jnosql-mongodb/src/main/java/org/eclipse/jnosql/databases/mongodb/communication Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2024 Contributors to the Eclipse Foundation
3+ * All rights reserved. This program and the accompanying materials
4+ * are made available under the terms of the Eclipse Public License v1.0
5+ * and Apache License v2.0 which accompanies this distribution.
6+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+ * and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+ *
9+ * You may elect to redistribute this code under either of these licenses.
10+ *
11+ * Contributors:
12+ *
13+ * Otavio Santana
14+ */
15+ package org .eclipse .jnosql .databases .mongodb .communication ;
16+
17+ import org .eclipse .jnosql .communication .ValueWriter ;
18+ import org .eclipse .jnosql .communication .ValueWriterDecorator ;
19+
20+ import java .util .UUID ;
21+
22+ final class MongoDBValueWriteDecorator <T , S > implements ValueWriter <T , S > {
23+
24+ @ SuppressWarnings ("rawtypes" )
25+ private static final ValueWriter DEFAULT = ValueWriterDecorator .getInstance ();
26+
27+ private static final UUIDValueWriter UUID_VALUE_WRITER = new UUIDValueWriter ();
28+
29+
30+ @ Override
31+ public boolean test (Class <?> type ) {
32+ return UUID_VALUE_WRITER .test (type ) || DEFAULT .test (type );
33+ }
34+
35+ @ SuppressWarnings ("unchecked" )
36+ @ Override
37+ public S write (T type ) {
38+ if (type != null && UUID_VALUE_WRITER .test (type .getClass ())) {
39+ return (S ) UUID_VALUE_WRITER .write ((UUID ) type );
40+ } else {
41+ return (S ) DEFAULT .write (type );
42+ }
43+ }
44+
45+ }
You can’t perform that action at this time.
0 commit comments