/* © SRSoftware 2025 */
package de.srsoftware.umbrella.user.model;

public class Password implements CharSequence{

	private final String pass;

	private Password(String val){
		this.pass = val;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof String s) return s.equals(pass);
		if (!(obj instanceof Password other)) return false;
		return pass != null && pass.equals(other.pass);
	}

	@Override
	public int length() {
		return pass.length();
	}

	@Override
	public char charAt(int i) {
		return pass.charAt(i);
	}

	public static Password of(String val){
		return new Password(val);
	}

	@Override
	public CharSequence subSequence(int start, int end) {
		return pass.subSequence(start,end);
	}

	@Override
	public String toString() {
		return pass;
	}
}
