Record Class MaskPattern
java.lang.Object
java.lang.Record
cloud.opencode.base.string.desensitize.strategy.MaskPattern
Mask Pattern - Record defining masking pattern configuration.
掩码模式 - 定义掩码模式配置的记录。
Features | 主要功能:
- Configurable start/end keep lengths - 可配置首尾保留长度
- Configurable mask character - 可配置掩码字符
- Predefined patterns (MOBILE, ID_CARD, etc.) - 预定义模式
Usage Examples | 使用示例:
MaskPattern pattern = new MaskPattern(3, 4, '*');
MaskPattern mobile = MaskPattern.MOBILE; // keep first 3, last 4
Security | 安全性:
- Thread-safe: Yes (record is immutable) - 线程安全: 是(记录不可变)
- Since:
- JDK 25, opencode-base-string V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MaskPatternstatic final MaskPatternstatic final MaskPatternstatic final MaskPatternstatic final MaskPattern -
Constructor Summary
ConstructorsConstructorDescriptionMaskPattern(int startKeep, int endKeep, char maskChar) Creates an instance of aMaskPatternrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintendKeep()Returns the value of theendKeeprecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.charmaskChar()Returns the value of themaskCharrecord component.intReturns the value of thestartKeeprecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT
-
MOBILE
-
ID_CARD
-
EMAIL
-
BANK_CARD
-
-
Constructor Details
-
MaskPattern
public MaskPattern(int startKeep, int endKeep, char maskChar) Creates an instance of aMaskPatternrecord class.- Parameters:
startKeep- the value for thestartKeeprecord componentendKeep- the value for theendKeeprecord componentmaskChar- the value for themaskCharrecord component
-
-
Method Details
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
startKeep
public int startKeep()Returns the value of thestartKeeprecord component.- Returns:
- the value of the
startKeeprecord component
-
endKeep
public int endKeep()Returns the value of theendKeeprecord component.- Returns:
- the value of the
endKeeprecord component
-
maskChar
public char maskChar()Returns the value of themaskCharrecord component.- Returns:
- the value of the
maskCharrecord component
-