Skip to content

Commit adaf213

Browse files
entity extensions api #387
1 parent 6cc6700 commit adaf213

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2018-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.ktorm.entity
18+
19+
import org.ktorm.schema.ColumnBinding
20+
21+
/**
22+
* Entity extension APIs.
23+
*
24+
* Note these APIs are designed to be used by Ktorm's 3rd party extensions, applications should not use them directly.
25+
*
26+
* @since 3.5.0
27+
*/
28+
public class EntityExtensionsApi {
29+
30+
/**
31+
* Check if the specific column value exists in this entity.
32+
*
33+
* Please keep in mind that null is also a valid column value, so if a column value was set to null, this function
34+
* returns true.
35+
*/
36+
public fun Entity<*>.hasColumnValue(binding: ColumnBinding): Boolean {
37+
return implementation.hasColumnValue(binding)
38+
}
39+
40+
/**
41+
* Get the specific column value from this entity, returning null if the value doesn't exist.
42+
*/
43+
public fun Entity<*>.getColumnValue(binding: ColumnBinding): Any? {
44+
return implementation.getColumnValue(binding)
45+
}
46+
47+
/**
48+
* Set the specific column's value into this entity.
49+
*/
50+
public fun Entity<*>.setColumnValue(binding: ColumnBinding, value: Any?) {
51+
implementation.setColumnValue(binding, value)
52+
}
53+
}

0 commit comments

Comments
 (0)