package com.atlassian.bitbucket.internal.mirroring.upstream.dao;

import com.atlassian.bitbucket.internal.mirroring.upstream.InternalMirrorServer;

import javax.annotation.Nonnull;
import java.util.Date;

/**
 * Implementation class for {@link AoMirrorServer} to implement the {@link #isEnabled()} and {@link #setEnabled(boolean)}
 * methods
 */
public class DelegatingMirrorServer implements InternalMirrorServer {

    private final AoMirrorServer delegate;

    public DelegatingMirrorServer(AoMirrorServer delegate) {
        this.delegate = delegate;
    }

    @Nonnull
    @Override
    public String getAddonKey() {
        return delegate.getAddonKey();
    }

    @Nonnull
    @Override
    public String getBaseUrl() {
        return delegate.getBaseUrl();
    }

    @Nonnull
    @Override
    public String getId() {
        return delegate.getId();
    }

    @Nonnull
    @Override
    public Date getLastSeenDate() {
        return delegate.getLastSeenDate();
    }

    @Nonnull
    @Override
    public String getName() {
        return delegate.getName();
    }

    @Nonnull
    @Override
    public String getProductType() {
        return delegate.getProductType();
    }

    @Nonnull
    @Override
    public String getProductVersion() {
        return delegate.getProductVersion();
    }

    @Override
    public boolean isEnabled() {
        return "ENABLED".equalsIgnoreCase(delegate.getInternalState());
    }

    @Override
    public void setEnabled(boolean value) {
        delegate.setInternalState(value ? "ENABLED" : "DISABLED");
    }
}

