All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.liuanxin.api.model.DocumentCopyright Maven / Gradle / Ivy

The newest version!
package com.github.liuanxin.api.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.github.liuanxin.api.constant.ApiConst;
import com.github.liuanxin.api.util.HttpUtil;
import com.github.liuanxin.api.util.Tools;

import java.util.*;

public class DocumentCopyright {

    private String title;
    private String team;
    private String version;
    private String copyright;

    private int groupCount = 0;
    private int apiCount = 0;


    /** when true will not return data */
    @JsonIgnore
    private boolean online = false;

    /** url|method or url */
    @JsonIgnore
    private Set ignoreUrlSet;

    /** if method set, ignore global */
    @JsonIgnore
    private List globalResponse;

    /** global token, generate in every api's param */
    @JsonIgnore
    private List globalTokens;

    /** return whether the sample contains a comment(method not has @ApiMethod, use this) */
    @JsonIgnore
    private boolean commentInReturnExample = true;

    /**
     * return Field Description Whether to record the parent attribute when listed separately,
     * regardless of this value when commentInReturnExample is true.
     *
     * forget this. It's a bad ide
     */
    @JsonIgnore
    private boolean returnRecordLevel = false;

    /** whether to combine multiple projects as expected */
    @JsonIgnore
    private boolean projectMerge = false;
    /** use it when want to collect other project */
    @JsonIgnore
    private Map projectMap;


    public DocumentCopyright() {
    }

    public DocumentCopyright(String title, String team, String version, String copyright) {
        this.title = title;
        this.team = team;
        this.version = version;
        this.copyright = copyright;
    }


    public String getTitle() {
        return title;
    }
    public DocumentCopyright setTitle(String title) {
        this.title = title;
        return this;
    }

    public String getTeam() {
        return team;
    }
    public DocumentCopyright setTeam(String team) {
        this.team = team;
        return this;
    }

    public String getVersion() {
        return version;
    }
    public DocumentCopyright setVersion(String version) {
        this.version = version;
        return this;
    }

    public String getCopyright() {
        return copyright;
    }
    public DocumentCopyright setCopyright(String copyright) {
        this.copyright = copyright;
        return this;
    }

    public int getGroupCount() {
        return groupCount;
    }
    public DocumentCopyright setGroupCount(int groupCount) {
        this.groupCount = groupCount;
        return this;
    }

    public int getApiCount() {
        return apiCount;
    }
    public DocumentCopyright setApiCount(int apiCount) {
        this.apiCount = apiCount;
        return this;
    }

    public boolean isOnline() {
        return online;
    }
    public DocumentCopyright setOnline(boolean online) {
        this.online = online;
        return this;
    }

    public Set getIgnoreUrlSet() {
        return ignoreUrlSet;
    }
    public DocumentCopyright setIgnoreUrlSet(Set ignoreUrlSet) {
        this.ignoreUrlSet = ignoreUrlSet;
        return this;
    }

    public List getGlobalResponse() {
        return globalResponse;
    }
    public DocumentCopyright setGlobalResponse(List globalResponse) {
        this.globalResponse = globalResponse;
        return this;
    }

    public List getGlobalTokens() {
        return globalTokens;
    }
    public DocumentCopyright setGlobalTokens(List globalTokens) {
        this.globalTokens = globalTokens;
        return this;
    }

    public boolean isCommentInReturnExample() {
        return commentInReturnExample;
    }
    public DocumentCopyright setCommentInReturnExample(boolean commentInReturnExample) {
        this.commentInReturnExample = commentInReturnExample;
        return this;
    }

    public boolean isReturnRecordLevel() {
        return returnRecordLevel;
    }
    public DocumentCopyright setReturnRecordLevel(boolean returnRecordLevel) {
        this.returnRecordLevel = returnRecordLevel;
        return this;
    }

    public boolean isProjectMerge() {
        return projectMerge;
    }
    public DocumentCopyright setProjectMerge(boolean projectMerge) {
        this.projectMerge = projectMerge;
        return this;
    }

    public Map getProjectMap() {
        return projectMap;
    }
    public DocumentCopyright setProjectMap(Map projectMap) {
        this.projectMap = projectMap;
        return this;
    }

    public String getProjectInfo(String p) {
        if (isProjectMerge()) {
            return ApiConst.EMPTY;
        }

        Map projectMap = getProjectMap();
        if (Tools.isEmpty(projectMap)) {
            return ApiConst.EMPTY;
        }

        boolean flag = false;
        List> returnList = new ArrayList<>();
        for (Map.Entry entry : projectMap.entrySet()) {
            String key = entry.getKey();
            String url = entry.getValue();
            if (Tools.isNotEmpty(key) && Tools.isNotEmpty(url)) {
                String[] split = key.split(ApiConst.HORIZON);
                String name, value;
                if (split.length > 1) {
                    name = split[0];
                    value = split[1];
                } else {
                    name = value = key;
                }

                returnList.add(Arrays.asList(name, value, HttpUtil.getUrl(url)));
                if (Tools.isNotEmpty(p) && name.equalsIgnoreCase(p) || value.equals(p)) {
                    flag = true;
                }
            }
        }
        return Tools.isEmpty(p) || flag ? Tools.toJson(returnList) : ApiConst.EMPTY;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy