Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-1701

HaltedTraverserStrategy should recurse into collections for detachment.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.5
    • 3.2.6
    • process
    • None

    Description

      We need to make sure that HaltedTraverserStrategy recurses into collections. This will be elegantly handled by updated DetachedFactory and ReferenceFactory accordingly.

      For instance:

      public static <D> D detach(final Object object) {
              if (object instanceof Element) {
                  return (D) ReferenceFactory.detach((Element) object);
              } else if (object instanceof Property) {
                  return (D) ReferenceFactory.detach((Property) object);
              } else if (object instanceof Path) {
                  return (D) ReferenceFactory.detach((Path) object);
              } else if (object instanceof List) {
                  final List list = new ArrayList();
                  for (final Object item : (List) object) {
                      list.add(ReferenceFactory.detach(item));
                  }
                  return (D) list;
              } else if (object instanceof Set) {
                  final Set set = object instanceof LinkedHashSet ? new LinkedHashSet() : new HashSet();
                  for (final Object item : (Set) object) {
                      set.add(ReferenceFactory.detach(item));
                  }
                  return (D) set;
              } else if (object instanceof Map) {
                  final Map map = object instanceof LinkedHashMap ? new LinkedHashMap() : new HashMap();
                  for (final Map.Entry<Object, Object> entry : ((Map<Object, Object>) object).entrySet()) {
                      map.put(ReferenceFactory.detach(entry.getKey()), ReferenceFactory.detach(entry.getValue()));
                  }
                  return (D) map;
              } else {
                  return (D) object;
              }
          }
      

      Attachments

        Issue Links

          Activity

            People

              okram Marko A. Rodriguez
              okram Marko A. Rodriguez
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: