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

io.github.dengchen2020.ip.service.IpService Maven / Gradle / Ivy

There is a newer version: 0.0.30
Show newest version
package io.github.dengchen2020.ip.service;

import io.github.dengchen2020.ip.model.IpInfo;

/**
 * ip地址查询
 * @author dengchen
 * @since 2023/5/5
 */
public interface IpService {

    /**
     * 获取ip信息
     */
    IpInfo getInfo(String ip);

    /**
     * 查询不到时的默认返回信息
     */
    default IpInfo defaultInfo(){return new IpInfo("");}

    /**
     * 防止数组越界,安全访问指定索引的数据
     * @param ipInfo 原始ip信息
     * @param i 索引
     * @return 值
     */
    default String getValue(String[] ipInfo, Integer i) {
        if (ipInfo.length >= i + 1) {
            return ipInfo[i];
        }
        return "";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy