001/*
002 * Copyright (c) 2004-2020, Oracle and/or its affiliates.
003 *
004 * Licensed under the 2-clause BSD license.
005 *
006 * Redistribution and use in source and binary forms, with or without
007 * modification, are permitted provided that the following conditions are met:
008 *
009 * 1. Redistributions of source code must retain the above copyright notice,
010 *    this list of conditions and the following disclaimer.
011 *
012 * 2. Redistributions in binary form must reproduce the above copyright notice,
013 *    this list of conditions and the following disclaimer in the documentation
014 *    and/or other materials provided with the distribution.
015 *
016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
017 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
019 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
020 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
021 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
022 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
023 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
024 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
025 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
026 * POSSIBILITY OF SUCH DAMAGE.
027 */
028
029package com.oracle.labs.mlrg.olcut.config.json;
030
031import com.fasterxml.jackson.core.Version;
032import com.fasterxml.jackson.databind.module.SimpleModule;
033import com.oracle.labs.mlrg.olcut.provenance.io.MarshalledProvenance;
034
035/**
036 * The {@link MarshalledProvenance} serialization module.
037 */
038public class JsonProvenanceModule extends SimpleModule {
039    static final String MARSHALLED_CLASS = "marshalled-class";
040    static final String LIST = "list";
041    static final String MAP = "map";
042    static final String KEY = "key";
043    static final String VALUE = "value";
044    static final String PROVENANCE_CLASS = "provenance-class";
045    static final String ADDITIONAL = "additional";
046    static final String IS_REFERENCE = "is-reference";
047    static final String OBJECT_NAME = "object-name";
048    static final String OBJECT_CLASS_NAME = "object-class-name";
049
050    private static final String NAME = "JsonProvenanceModule";
051
052    public JsonProvenanceModule() {
053        super(NAME, new Version(5, 0, 0, null, "com.oracle.labs.mlrg.olcut", "olcut-config-json"));
054        addSerializer(MarshalledProvenance.class, new JsonProvenanceSerializer(MarshalledProvenance.class));
055        addDeserializer(MarshalledProvenance.class, new JsonProvenanceDeserializer(MarshalledProvenance.class));
056    }
057}