1. Store it as a string and then just use GremlinGroovyScriptEngine to eval() it as a script
2. Store it as bytecode serialized to GraphSON then rehydrate it back to a traversal with JavaTranslator
gremlin> bytecode = g.V().has('name','marko').asAdmin().getBytecode()
==>[[], [V(), has(name, marko)]]
gremlin> mapper = GraphSONMapper.build().create().createMapper()
==>org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper@1eaf1e62
gremlin> json = mapper.writeValueAsString(bytecode)
==>{"@type":"g:Bytecode","@value":{"step":[["V"],["has","name","marko"]]}}
gremlin> t = org.apache.tinkerpop.gremlin.jsr223.JavaTranslator.of(g).translate(mapper.readValue(json,Bytecode.class))
==>v[1]