package com.kfzs.duanduan.data.graph.provider.user;

// @formatter:off
import android.net.Uri;
import android.provider.BaseColumns;

import com.kfzs.duanduan.data.graph.provider.KFZSGraphProvider;
import com.kfzs.duanduan.data.graph.provider.base.AbstractSelection;
import com.kfzs.duanduan.data.graph.provider.user.UserColumns;

/**
 * A user info which is part of a team.
 */
@SuppressWarnings("unused")
public class UserColumns implements BaseColumns {
    public static final String TABLE_NAME = "user";
    public static final Uri CONTENT_URI = Uri.parse(KFZSGraphProvider.CONTENT_URI_BASE + "/" + TABLE_NAME);

    /**
     * Primary key.
     */
    public static final String _ID = BaseColumns._ID;

    /**
     * uid at user of this user.
     */
    public static final String UID = "uid";

    /**
     * user_name of this user.
     */
    public static final String USER_NAME = "user_name";

    /**
     * update time of this user.
     */
    public static final String UPDATE_TIME = "update_time";

    /**
     * phone of this user.
     */
    public static final String PHONE = "phone";

    /**
     * nickname of this user.
     */
    public static final String NICKNAME = "nickname";

    /**
     * user_icon of this user.
     */
    public static final String USER_ICON = "user_icon";

    /**
     * avatar of this user.
     */
    public static final String AVATAR = "avatar";

    /**
     * open_id of this user.
     */
    public static final String OPEN_ID = "open_id";

    /**
     * mail of this user.
     */
    public static final String MAIL = "mail";

    /**
     * refresh_token of this user.
     */
    public static final String REFRESH_TOKEN = "refresh_token";


    public static final String DEFAULT_ORDER = TABLE_NAME + "." + USER_NAME + AbstractSelection.DESC;

    public static final String[] ALL_COLUMNS = new String[] {
            _ID,
            UID,
            USER_NAME,
            UPDATE_TIME,
            PHONE,
            NICKNAME,
            USER_ICON,
            AVATAR,
            OPEN_ID,
            MAIL,
            REFRESH_TOKEN
    };

    public static boolean hasColumns(String[] projection) {
        if (projection == null) return true;
        for (String c : projection) {
            if (c.equals(UID) || c.contains("." + UID)) return true;
            if (c.equals(USER_NAME) || c.contains("." + USER_NAME)) return true;
            if (c.equals(UPDATE_TIME) || c.contains("." + UPDATE_TIME)) return true;
            if (c.equals(PHONE) || c.contains("." + PHONE)) return true;
            if (c.equals(NICKNAME) || c.contains("." + NICKNAME)) return true;
            if (c.equals(USER_ICON) || c.contains("." + USER_ICON)) return true;
            if (c.equals(AVATAR) || c.contains("." + AVATAR)) return true;
            if (c.equals(OPEN_ID) || c.contains("." + OPEN_ID)) return true;
            if (c.equals(MAIL) || c.contains("." + MAIL)) return true;
            if (c.equals(REFRESH_TOKEN) || c.contains("." + REFRESH_TOKEN)) return true;
        }
        return false;
    }

}
