001/*
002 * PlotSquared, a land and world management plugin for Minecraft.
003 * Copyright (C) IntellectualSites <https://intellectualsites.com>
004 * Copyright (C) IntellectualSites team and contributors
005 *
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
018 */
019package com.plotsquared.core.configuration.serialization;
020
021import java.util.Map;
022
023/**
024 * Represents an object that may be serialized.
025 * <p>These objects MUST implement one of the following, in addition to
026 * the methods as defined by this interface:
027 * <ul>
028 * <li>A static method "deserialize" that accepts a single {@link Map}&lt;
029 * {@link String}, {@link Object}&gt; and returns the class.</li>
030 * <li>A static method "valueOf" that accepts a single {@link Map}&lt;{@link
031 * String}, {@link Object}&gt; and returns the class.</li>
032 * <li>A constructor that accepts a single {@link Map}&lt;{@link String},
033 * {@link Object}&gt;.</li>
034 * </ul>
035 * In addition to implementing this interface, you must register the class
036 * with {@link ConfigurationSerialization#registerClass(Class)}.
037 *
038 * @see DelegateDeserialization
039 * @see SerializableAs
040 */
041public interface ConfigurationSerializable {
042
043    /**
044     * Creates a Map representation of this class.
045     *
046     * <p>This class must provide a method to restore this class, as defined in
047     * the {@link ConfigurationSerializable} interface javadoc.
048     *
049     * @return Map containing the current state of this class
050     */
051    Map<String, Object> serialize();
052
053}