I defined custom annotation(DataAttribute) like the below. And I have to call checkMaxLength() many times, over 10,000 times. (also toolType, reportTitle and validLength also)
What I'd like to ask is..
I think a) is right(or general) usage of custom annotation. but If I call checkMaxLength over 10,000 times(, and maxLength is always 4000), It's not good for performance compared with b).
What do you think of case b)?? Is this right way to use custom data annotation?
a)
@DataAttribute(toolType = DataTooltype.CustomDateTime, reportTitle = "DateTime", maxLength = 4000, validLength = 4000, pollutedLength = 100)
public class DateTimeData {
public boolean checkMaxLength(int length) {
if (DataAnnotationUtil.maxLength(this) < length)
return false;
return true;
}
}
b)
@DataAttribute(toolType = DataTooltype.CustomDateTime, reportTitle = "DateTime", maxLength = 4000, validLength = 4000, pollutedLength = 100)
public class DateTimeData {
public int maxLength;
public Email() {
this.maxLength = DataAnnotationUtil.maxLength(this);
}
public boolean checkMaxLength(int length) {
if (this.maxLength < length)
return false;
return true;
}
}