package com.atlassian.bitbucket.internal.importer.github;

import com.atlassian.bitbucket.internal.importer.ExternalRepository;
import com.atlassian.bitbucket.rest.RestMapEntity;
import com.atlassian.bitbucket.rest.annotation.JsonSurrogate;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;

import static com.atlassian.bitbucket.internal.importer.ImporterConstants.GIT_SCM_ID;

/**
 * GitHub repository details
 * <p>
 * Note that this class uses javax.validation annotations to allow input to be validated before being processed
 */
@JsonSerialize
@JsonSurrogate(ExternalRepository.class)
public class GitHubRepository extends RestMapEntity implements ExternalRepository {

    public static final String CLONE_URL = "clone_url";
    public static final String DESCRIPTION = "description";
    public static final String NAME = "name";

    @Nonnull
    @NotNull
    @Override
    public String getCloneUrl() {
        return getStringProperty(CLONE_URL);
    }

    @Nullable
    @Override
    public String getDescription() {
        return getStringProperty(DESCRIPTION);
    }

    @Nonnull
    @NotNull
    @Override
    public String getName() {
        return getStringProperty(NAME);
    }

    @Nonnull
    @NotNull
    @Override
    public String getScmId() {
        return GIT_SCM_ID;
    }
}
