Module is.codion.framework.domain
Interface ColumnCondition<T>
- Type Parameters:
T- the attribute type
- All Superinterfaces:
Condition
A condition based on a single
Column.
ColumnConditions provide type-safe filtering for column values using various operators such as equality, comparison, pattern matching, and range operations. String conditions support case-sensitive and case-insensitive variants.
Column conditions are typically created through the ColumnConditions interface, which all Column instances implement:
// Equality conditions
List<Entity> teenSpirit = connection.select(
Track.NAME.equalTo("Smells Like Teen Spirit"));
List<Entity> noCompany = connection.select(
Customer.COMPANY.equalTo(null)); // Becomes "IS NULL"
// String pattern matching
List<Entity> theArtists = connection.select(
Artist.NAME.like("The %"));
List<Entity> liveAlbums = connection.select(
Album.TITLE.likeIgnoreCase("%live%"));
// Comparison conditions
List<Entity> expensiveTracks = connection.select(
Track.UNITPRICE.greaterThan(BigDecimal.valueOf(0.99)));
List<Entity> recentTracks = connection.select(
Track.INSERT_TIME.greaterThanOrEqualTo(
LocalDateTime.now().minusDays(30)));
// Range conditions
List<Entity> mediumPricedTracks = connection.select(
Track.UNITPRICE.between(
BigDecimal.valueOf(0.50),
BigDecimal.valueOf(1.50)));
// Collection-based conditions
List<String> artists = List.of("AC/DC", "Metallica", "Iron Maiden");
List<Entity> metalTracks = connection.select(
Track.ARTIST_NAME.inIgnoreCase(artists));
List<Long> excludedIds = List.of(1L, 5L, 10L);
List<Entity> filteredArtists = connection.select(
Artist.ID.notIn(excludedIds));
// Null checks
List<Entity> tracksWithComposer = connection.select(
Track.COMPOSER.isNotNull());
List<Entity> tracksWithoutComposer = connection.select(
Track.COMPOSER.isNull());
// Case-insensitive operations
List<Entity> zeppelinTracks = connection.select(
Track.ARTIST_NAME.equalToIgnoreCase("led zeppelin"));
// Complex combinations with logical operators
List<Entity> tracks = connection.select(and(
Track.UNITPRICE.greaterThan(BigDecimal.valueOf(0.99)),
Track.ARTIST_NAME.inIgnoreCase("AC/DC", "Metallica"),
Track.MILLISECONDS.lessThan(300_000))); // Less than 5 minutes
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface is.codion.framework.domain.entity.condition.Condition
Condition.All, Condition.Combination -
Method Summary
Methods inherited from interface is.codion.framework.domain.entity.condition.Condition
columns, entityType, string, values
-
Method Details
-
column
- Returns:
- the attribute
-
operator
Operator operator()- Returns:
- the condition operator
-
wildcard
boolean wildcard()- Returns:
- true in case of wildcard comparison, meaning EQUAL should be treated as LIKE
-
caseSensitive
boolean caseSensitive()- Returns:
- true if this condition is case-sensitive, only applies to String based conditions
-