Record Class Filter
java.lang.Object
java.lang.Record
io.leandev.appfuse.search.Filter
- Record Components:
node- 篩選器的內部節點表示
查詢篩選器,用於建構結構化的查詢條件。
此類別提供流暢的 API 來建構複雜的查詢條件,支援:
- 比較運算:等於、不等於、大於、小於、介於等
- 邏輯運算:AND、OR 組合條件
- 空值處理:IS NULL、IS NOT NULL
- 集合運算:IN、NOT IN、HAS
使用範例:
// 簡單條件
Filter filter = Filter.eq("status", "ACTIVE");
// 組合條件
Filter filter = Filter.eq("status", "ACTIVE")
.and(Filter.ge("amount", 100))
.or(Filter.isNull("category"));
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription將多個篩選器以 AND 邏輯組合到此篩選器。and(String selector, ComparisonOperator operator, Object expectation) 將指定條件以 AND 邏輯組合到此篩選器。將篩選器列表以 AND 邏輯組合到此篩選器。static Filter建立區間條件的篩選器。static Filter建立區間條件的篩選器。children()取得邏輯節點的子篩選器列表。static Filterempty()建立空的篩選器。static Filter建立等於條件的篩選器。final booleanIndicates whether some other object is "equal to" this one.取得比較節點的期望值。static Filter建立大於或等於條件的篩選器。static Filter建立大於條件的篩選器。static Filter建立 HAS 條件的篩選器,檢查集合欄位是否包含指定值。final inthashCode()Returns a hash code value for this object.static Filter建立 IN 條件的篩選器,檢查欄位值是否在指定集合中。static Filter建立 IS 條件的篩選器,用於精確比對(包含 null 值)。booleanisEmpty()檢查此篩選器是否為空。static Filter建立 IS NOT 條件的篩選器,用於精確排除比對(包含 null 值)。boolean檢查此篩選器是否不為空。static Filter建立 IS NOT NULL 條件的篩選器,檢查欄位值是否不為 null。static Filter建立 IS NULL 條件的篩選器,檢查欄位值是否為 null。static Filter建立小於或等於條件的篩選器。static Filterlike(String selector, CharSequence expectation) 建立模糊比對條件的篩選器(不允許 null 值匹配)。static Filterlike(String selector, CharSequence expectation, boolean nullable) 建立模糊比對條件的篩選器。static Filter建立小於條件的篩選器。map(Function<ComparisonNode, Node> fn) 對篩選器中的所有比較節點套用轉換函式。static Filter建立不等於條件的篩選器。node()Returns the value of thenoderecord component.static Filter建立 NOT IN 條件的篩選器,檢查欄位值是否不在指定集合中。static Filterof(String selector, ComparisonOperator operator, Object expectation) 使用指定的選擇器、運算子和期望值建立篩選器。operator()取得節點的運算子。將多個篩選器以 OR 邏輯組合到此篩選器。or(String selector, ComparisonOperator operator, Object expectation) 將指定條件以 OR 邏輯組合到此篩選器。將篩選器列表以 OR 邏輯組合到此篩選器。selector()取得比較節點的欄位選擇器。static FilterstartsWith(String selector, CharSequence expectation) 建立前綴比對條件的篩選器。final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Filter
使用指定的選擇器、運算子和期望值建立篩選器。- Parameters:
selector- 欄位選擇器operator- 比較運算子expectation- 期望值
-
Filter
public Filter()建立空的篩選器。 -
Filter
-
-
Method Details
-
empty
-
of
使用指定的選擇器、運算子和期望值建立篩選器。
對於非 IS/IS_NOT 運算子,若期望值為 null、空字串或空集合,會回傳空篩選器。
- Parameters:
selector- 欄位選擇器operator- 比較運算子expectation- 期望值- Returns:
- 篩選器實例;若期望值無效則回傳空篩選器
-
eq
-
neq
-
like
建立模糊比對條件的篩選器。
會將期望值包裝為
*expectation*格式進行模糊比對。- Parameters:
selector- 欄位選擇器expectation- 期望值nullable- 是否允許 null 值匹配- Returns:
- 模糊比對條件的篩選器
-
like
建立模糊比對條件的篩選器(不允許 null 值匹配)。- Parameters:
selector- 欄位選擇器expectation- 期望值- Returns:
- 模糊比對條件的篩選器
-
startsWith
建立前綴比對條件的篩選器。
會將期望值包裝為
expectation*格式進行前綴比對。- Parameters:
selector- 欄位選擇器expectation- 期望值- Returns:
- 前綴比對條件的篩選器
-
ge
-
gt
-
lt
-
le
-
in
-
notIn
-
has
-
between
-
between
-
is
-
isNot
-
isNull
-
isNotNull
-
isEmpty
public boolean isEmpty()檢查此篩選器是否為空。- Returns:
- 若為空篩選器則回傳 true
-
isNotEmpty
public boolean isNotEmpty()檢查此篩選器是否不為空。- Returns:
- 若不為空篩選器則回傳 true
-
and
-
and
-
and
將指定條件以 AND 邏輯組合到此篩選器。- Parameters:
selector- 欄位選擇器operator- 比較運算子expectation- 期望值- Returns:
- 組合後的新篩選器
-
or
-
or
-
or
將指定條件以 OR 邏輯組合到此篩選器。- Parameters:
selector- 欄位選擇器operator- 比較運算子expectation- 期望值- Returns:
- 組合後的新篩選器
-
map
對篩選器中的所有比較節點套用轉換函式。- Parameters:
fn- 轉換函式,接收比較節點並回傳新節點- Returns:
- 轉換後的新篩選器
-
selector
-
expectation
-
operator
-
children
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
node
-