Record Class ColumnConstraint
java.lang.Object
java.lang.Record
io.bloviate.db.ColumnConstraint
- Record Components:
allowedValues- the permitted values (their text form), or null for a range constraintmin- the lower bound, or null if unbounded belowminInclusive- whetherminis inclusivemax- the upper bound, or null if unbounded abovemaxInclusive- whethermaxis inclusive
public record ColumnConstraint(List<String> allowedValues, BigDecimal min, boolean minInclusive, BigDecimal max, boolean maxInclusive)
extends Record
A value constraint captured for a column — the machine-readable part of a
CHECK constraint
or an ENUM/domain's allowed values — so the fill engine can generate values that satisfy it
instead of values a constraint would reject (issue #479).
A constraint is one of two shapes: a set of allowed values (from
col IN (...), = ANY (ARRAY[...]), or an enum's labels) or a numeric
range (from BETWEEN / >= / <= / > / <). Forms the
reader can't interpret are not represented here — the engine warns and falls back to its type
default for those.
- Since:
- 2.14.0
-
Constructor Summary
ConstructorsConstructorDescriptionColumnConstraint(List<String> allowedValues, BigDecimal min, boolean minInclusive, BigDecimal max, boolean maxInclusive) Creates an instance of aColumnConstraintrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theallowedValuesrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanTrue if this is a set-of-allowed-values constraint.booleanTrue if this is a numeric range with both bounds (the form the engine can honor).final inthashCode()Returns a hash code value for this object.max()Returns the value of themaxrecord component.booleanReturns the value of themaxInclusiverecord component.min()Returns the value of theminrecord component.booleanReturns the value of theminInclusiverecord component.static ColumnConstraintofRange(BigDecimal min, BigDecimal max) A closed numeric range[min, max](both inclusive).static ColumnConstraintA set-of-allowed-values constraint (categorical / enum /IN).final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ColumnConstraint
public ColumnConstraint(List<String> allowedValues, BigDecimal min, boolean minInclusive, BigDecimal max, boolean maxInclusive) Creates an instance of aColumnConstraintrecord class.- Parameters:
allowedValues- the value for theallowedValuesrecord componentmin- the value for theminrecord componentminInclusive- the value for theminInclusiverecord componentmax- the value for themaxrecord componentmaxInclusive- the value for themaxInclusiverecord component
-
-
Method Details
-
ofValues
A set-of-allowed-values constraint (categorical / enum /IN).- Parameters:
allowedValues- the permitted values (their text form); defensively copied- Returns:
- a constraint that admits only
allowedValues
-
ofRange
A closed numeric range[min, max](both inclusive).- Parameters:
min- the inclusive lower boundmax- the inclusive upper bound- Returns:
- a constraint that admits values in
[min, max]
-
hasAllowedValues
public boolean hasAllowedValues()True if this is a set-of-allowed-values constraint.- Returns:
- whether allowed values are present
-
hasBoundedRange
public boolean hasBoundedRange()True if this is a numeric range with both bounds (the form the engine can honor).- Returns:
- whether both
minandmaxare present
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
allowedValues
Returns the value of theallowedValuesrecord component.- Returns:
- the value of the
allowedValuesrecord component
-
min
-
minInclusive
public boolean minInclusive()Returns the value of theminInclusiverecord component.- Returns:
- the value of the
minInclusiverecord component
-
max
-
maxInclusive
public boolean maxInclusive()Returns the value of themaxInclusiverecord component.- Returns:
- the value of the
maxInclusiverecord component
-