package com.eactive.eai.custom.alarm.key;

import lombok.ToString;

@ToString
public final class DynamicAlarmKey implements AlarmKey {

	private final String code;

	public DynamicAlarmKey(String code) {
		if (code == null || code.isEmpty()) {
			throw new IllegalArgumentException("AlarmKey code must not be empty");
		}
		this.code = code;
	}

	@Override
	public String code() {
		return code;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof AlarmKey)) return false;
		return code.equals(((AlarmKey) o).code());
	}

	@Override
	public int hashCode() {
		return code.hashCode();
	}
}