001package com.github.tommyettinger.kryo.jdkgdxds;
002
003import com.esotericsoftware.kryo.Kryo;
004import com.github.tommyettinger.ds.Junction;
005import com.github.tommyettinger.ds.ObjectList;
006
007/**
008 * Not actually a Serializer, this just has code to register the needed classes for Junction to be serializable.
009 */
010public class JunctionSupport {
011    /**
012     * Given a Kryo instance to register classes on, this registers (in order):
013     * <ol>
014     *     <li>{@link ObjectList}</li>
015     *     <li>{@link Junction}</li>
016     *     <li>{@link Junction.Any}</li>
017     *     <li>{@link Junction.All}</li>
018     *     <li>{@link Junction.One}</li>
019     *     <li>{@link Junction.Not}</li>
020     *     <li>{@link Junction.Leaf}</li>
021     * </ol>
022     * This means if you call this on a server, it also must be called at the same point in registration order as you
023     * call it on the client-side.
024     * @param kryo a non-null Kryo instance
025     */
026    public static void registerJunction(Kryo kryo) {
027        kryo.register(ObjectList.class, new ObjectListSerializer());
028        kryo.register(Junction.class);
029        kryo.register(Junction.Any.class);
030        kryo.register(Junction.All.class);
031        kryo.register(Junction.One.class);
032        kryo.register(Junction.Not.class);
033        kryo.register(Junction.Leaf.class);
034
035    }
036}