ConverterNameDV.java
/*
* SPDX-FileCopyrightText: 2026 kaumei.io
* SPDX-License-Identifier: Apache-2.0
*/
package io.kaumei.jdbc.anno.model;
import io.kaumei.jdbc.anno.ctx.AnnoElementValueMap;
public record ConverterNameDV(String value) {
private static final ConverterNameDV UNNAMED = new ConverterNameDV("");
public static ConverterNameDV unnamed() {
return UNNAMED;
}
public static ConverterNameDV of(AnnoElementValueMap map) {
return new ConverterNameDV(map.getString("value", ""));
}
public static ConverterNameDV of(String value) {
return new ConverterNameDV(value);
}
// ------------------------------------------------------------------------
public ConverterNameDV {
if (value == null) {
throw new IllegalArgumentException();
}
}
public boolean isBlankName() {
return hasName() && value.isBlank();
}
public boolean hasName() {
return !value.isEmpty();
}
public String value() {
if (value.isEmpty()) {
throw new IllegalStateException();
}
return this.value;
}
@Override
public String toString() {
return this.value;
}
}