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

com.taotao.boot.sensitive.wordother.api.IWordMap Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2020-2030, Shuigedeng ([email protected] & https://blog.taotaocloud.top/).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.taotao.boot.sensitive.wordother.api;

import com.taotao.boot.sensitive.wordother.constant.enums.ValidModeEnum;
import com.taotao.boot.sensitive.wordother.support.check.ISensitiveCheck;

import java.util.Collection;
import java.util.List;

/** 敏感词 map */
public interface IWordMap extends ISensitiveCheck {

    /**
     * 初始化敏感词 map
     *
     * @param collection 集合信息
     */
    void initWordMap(Collection collection);

    /**
     * 是否包含敏感词
     *
     * @param string 字符串
     * @param context 上下文
     * @return 是否包含
     * @see ValidModeEnum#FAIL_FAST 建议使用快速返回模式
     */
    boolean contains(final String string, final IWordContext context);

    /**
     * 返回所有对应的敏感词
     *
     * @param string 原始字符串
     * @param context 上下文
     * @return 结果
     * @see ValidModeEnum#FAIL_OVER 建议使用全部检测返回模式
     */
    List findAll(final String string, final IWordContext context);

    /**
     * 返回第一个对应的敏感词
     *
     * @param string 原始字符串
     * @param context 上下文
     * @return 结果
     */
    IWordResult findFirst(final String string, final IWordContext context);

    /**
     * 替换所有敏感词内容
     *
     * 

ps: 这里可以添加优化。 * * @param target 目标字符串 * @param replace 替换策略 * @param context 上下文 * @return 替换后结果 */ String replace(final String target, final ISensitiveWordReplace replace, final IWordContext context); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy