/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.spine3.server.storage.datastore.tenant;

import com.google.common.base.Converter;
import org.spine3.annotations.SPI;
import org.spine3.users.TenantId;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * // TODO:2017-04-18:dmytro.dashenkov: Javadoc.
 *
 * @author Dmytro Dashenkov
 */
@SPI
public abstract class NamespaceToTenantIdConverter extends Converter<String, TenantId> {

    @Override
    protected TenantId doForward(String s) {
        checkNotNull(s);
        return toTenantId(s);
    }

    @Override
    protected String doBackward(TenantId tenantId) {
        checkNotNull(tenantId);
        return toString(tenantId);
    }

    protected abstract String toString(TenantId tenantId);
    protected abstract TenantId toTenantId(String namespace);
}

@@ -1251,52 +1251,401 @@
 %0A * 
-// TODO:2017-04-18:dmytro.dashenkov: Javadoc
+A %7B@link Converter%7D for %7B@link TenantId%7D and the string Datastore namespace.%0A *%0A * %3Cp%3EDefine this converter in case if there is a need to override%0A * the %7B@linkplain Namespace default convertion behavior%7D.%0A *%0A * %3Cp%3EThe implementation of the convertion must be commutative, meaning that the restored%0A * %7B@link TenantId%7D values should be %7B@linkplain TenantId#equals(Object) equal%7D to the initial
 .%0A *
@@ -1673,16 +1673,34 @@
 shenkov%0A
+ * @see Namespace%0A
  */%0A@SPI
@@ -1818,16 +1818,22 @@
 otected 
+final 
 TenantId
@@ -1945,16 +1945,22 @@
 otected 
+final 
 String d
@@ -2072,62 +2072,281 @@
     
-protected abstract String toString(TenantId tenantId);
+/**%0A     * Converts the given %7B@link TenantId%7D into a string representing a Datastore namespace.%0A     */%0A    protected abstract String toString(TenantId tenantId);%0A%0A    /**%0A     * Converts the given string representing a Datastore namespace into a %7B@link TenantId%7D.%0A     */
 %0A   

Add yet more Javadoc.