thomasmueller commented on code in PR #1612:
URL: https://github.com/apache/jackrabbit-oak/pull/1612#discussion_r1701411719


##########
oak-store-spi/src/main/java/org/apache/jackrabbit/oak/json/JsonDeserializer.java:
##########
@@ -39,49 +39,67 @@
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
-import static org.apache.jackrabbit.guava.common.collect.ImmutableSet.of;
-import static java.util.Collections.emptyList;
 import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
 import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
 import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
 import static 
org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
 import static 
org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty;
 
 public class JsonDeserializer {
-    public static final String OAK_CHILD_ORDER = ":childOrder";
-    private final BlobDeserializer blobHandler;
-    private final NodeBuilder builder;
-    private final DeserializationSupport deserializationSupport;
+    /**
+     * Provides support for inferring types for some common property name and 
types
+     */
+    private static final Set<String> NAME_PROPS = Set.of(JCR_PRIMARYTYPE, 
JCR_MIXINTYPES);
+    private static final String ORDERABLE_TYPE = NT_UNSTRUCTURED;
+    private static final String OAK_CHILD_ORDER = ":childOrder";
 
-    private JsonDeserializer(BlobDeserializer blobHandler, NodeBuilder 
builder, DeserializationSupport support) {
-        this.blobHandler = blobHandler;
-        this.builder = builder;
-        this.deserializationSupport = support;
+    private static Type<?> inferPropertyType(String propertyName, String 
jsonString) {
+        if (NAME_PROPS.contains(propertyName) && hasSingleColon(jsonString)) {
+            return Type.NAME;
+        }
+        return Type.UNDEFINED;
     }
 
-    public JsonDeserializer(BlobDeserializer blobHandler) {
-        this(blobHandler, EMPTY_NODE.builder(), 
DeserializationSupport.INSTANCE);
+    private static boolean hasOrderableChildren(NodeBuilder builder) {
+        PropertyState primaryType = builder.getProperty(JCR_PRIMARYTYPE);
+        return primaryType != null && 
ORDERABLE_TYPE.equals(primaryType.getValue(Type.NAME));
+    }
+
+    private static boolean hasSingleColon(String jsonString) {
+        // In case the primaryType was encoded then it would be like

Review Comment:
   What about using two indexOf operations instead? E.g. one to get the first 
colon, another to get the last, and then check if they are equal. I think that 
would be simpler and faster. Ah I see it's just code that is moved around...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to