private final String regEx;
private final String description;
private final String reference;
-
private final String errorAppTag;
private final String errorMessage;
public PatternConstraintEffectiveImpl(final String regex, final Optional<String> description,
final Optional<String> reference) {
+ this(regex, description.orNull(), reference.orNull(), "invalid-regular-expression", String.format(
+ "String %s is not valid regular expression.", regex));
+ }
+ public PatternConstraintEffectiveImpl(final String regex, final String description, final String reference,
+ final String errorAppTag, final String errorMessage) {
super();
-
this.regEx = Preconditions.checkNotNull(regex, "regex must not be null.");
- this.description = description.orNull();
- this.reference = reference.orNull();
-
- errorAppTag = "invalid-regular-expression";
- errorMessage = String.format("String %s is not valid regular expression.", regex);
+ this.description = description;
+ this.reference = reference;
+ this.errorAppTag = errorAppTag != null ? errorAppTag : "invalid-regular-expression";
+ this.errorMessage = errorMessage != null ? errorMessage : String.format(
+ "String %s is not valid regular expression.", regex);
}
@Override
return false;
}
final PatternConstraintEffectiveImpl other = (PatternConstraintEffectiveImpl) obj;
- if (description == null) {
- if (other.description != null) {
- return false;
- }
- } else if (!description.equals(other.description)) {
+ if (!Objects.equals(description, other.description)) {
return false;
}
- if (errorAppTag == null) {
- if (other.errorAppTag != null) {
- return false;
- }
- } else if (!errorAppTag.equals(other.errorAppTag)) {
+ if (!Objects.equals(errorAppTag, other.errorAppTag)) {
return false;
}
- if (errorMessage == null) {
- if (other.errorMessage != null) {
- return false;
- }
- } else if (!errorMessage.equals(other.errorMessage)) {
+ if (!Objects.equals(errorMessage, other.errorMessage)) {
return false;
}
- if (reference == null) {
- if (other.reference != null) {
- return false;
- }
- } else if (!reference.equals(other.reference)) {
+ if (!Objects.equals(reference, other.reference)) {
return false;
}
- if (regEx == null) {
- if (other.regEx != null) {
- return false;
- }
- } else if (!regEx.equals(other.regEx)) {
+ if (!Objects.equals(regEx, other.regEx)) {
return false;
}
return true;