|
| 1 | +/* |
| 2 | + * Copyright 2020 ObjectBox Ltd. All rights reserved. |
| 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 | +@file:Suppress("unused") // Public API. |
| 18 | + |
| 19 | +package io.objectbox.kotlin |
| 20 | + |
| 21 | +import io.objectbox.Property |
| 22 | +import io.objectbox.query.PropertyQueryCondition |
| 23 | +import java.util.* |
| 24 | + |
| 25 | + |
| 26 | +// Boolean |
| 27 | +/** Creates an "equal ('=')" condition for this property. */ |
| 28 | +infix fun <T> Property<T>.equal(value: Boolean): PropertyQueryCondition<T> { |
| 29 | + return equal(value) |
| 30 | +} |
| 31 | + |
| 32 | +/** Creates a "not equal ('<>')" condition for this property. */ |
| 33 | +infix fun <T> Property<T>.notEqual(value: Boolean): PropertyQueryCondition<T> { |
| 34 | + return notEqual(value) |
| 35 | +} |
| 36 | + |
| 37 | +// IntArray |
| 38 | +/** Creates an "IN (..., ..., ...)" condition for this property. */ |
| 39 | +infix fun <T> Property<T>.oneOf(value: IntArray): PropertyQueryCondition<T> { |
| 40 | + return oneOf(value) |
| 41 | +} |
| 42 | + |
| 43 | +/** Creates a "NOT IN (..., ..., ...)" condition for this property. */ |
| 44 | +infix fun <T> Property<T>.notOneOf(value: IntArray): PropertyQueryCondition<T> { |
| 45 | + return notOneOf(value) |
| 46 | +} |
| 47 | + |
| 48 | +// Long |
| 49 | +/** Creates an "equal ('=')" condition for this property. */ |
| 50 | +infix fun <T> Property<T>.equal(value: Long): PropertyQueryCondition<T> { |
| 51 | + return equal(value) |
| 52 | +} |
| 53 | + |
| 54 | +/** Creates a "not equal ('<>')" condition for this property. */ |
| 55 | +infix fun <T> Property<T>.notEqual(value: Long): PropertyQueryCondition<T> { |
| 56 | + return notEqual(value) |
| 57 | +} |
| 58 | + |
| 59 | +/** Creates a "greater than ('>')" condition for this property. */ |
| 60 | +infix fun <T> Property<T>.greater(value: Long): PropertyQueryCondition<T> { |
| 61 | + return greater(value) |
| 62 | +} |
| 63 | + |
| 64 | +/** Creates a "less than ('<')" condition for this property. */ |
| 65 | +infix fun <T> Property<T>.less(value: Long): PropertyQueryCondition<T> { |
| 66 | + return less(value) |
| 67 | +} |
| 68 | + |
| 69 | +// LongArray |
| 70 | +/** Creates an "IN (..., ..., ...)" condition for this property. */ |
| 71 | +infix fun <T> Property<T>.oneOf(value: LongArray): PropertyQueryCondition<T> { |
| 72 | + return oneOf(value) |
| 73 | +} |
| 74 | + |
| 75 | +/** Creates a "NOT IN (..., ..., ...)" condition for this property. */ |
| 76 | +infix fun <T> Property<T>.notOneOf(value: LongArray): PropertyQueryCondition<T> { |
| 77 | + return notOneOf(value) |
| 78 | +} |
| 79 | + |
| 80 | +// Double |
| 81 | +/** Creates a "greater than ('>')" condition for this property. */ |
| 82 | +infix fun <T> Property<T>.greater(value: Double): PropertyQueryCondition<T> { |
| 83 | + return greater(value) |
| 84 | +} |
| 85 | + |
| 86 | +/** Creates a "less than ('<')" condition for this property. */ |
| 87 | +infix fun <T> Property<T>.less(value: Double): PropertyQueryCondition<T> { |
| 88 | + return less(value) |
| 89 | +} |
| 90 | + |
| 91 | +// Date |
| 92 | +/** Creates an "equal ('=')" condition for this property. */ |
| 93 | +infix fun <T> Property<T>.equal(value: Date): PropertyQueryCondition<T> { |
| 94 | + return equal(value) |
| 95 | +} |
| 96 | + |
| 97 | +/** Creates a "not equal ('<>')" condition for this property. */ |
| 98 | +infix fun <T> Property<T>.notEqual(value: Date): PropertyQueryCondition<T> { |
| 99 | + return notEqual(value) |
| 100 | +} |
| 101 | + |
| 102 | +/** Creates a "greater than ('>')" condition for this property. */ |
| 103 | +infix fun <T> Property<T>.greater(value: Date): PropertyQueryCondition<T> { |
| 104 | + return greater(value) |
| 105 | +} |
| 106 | + |
| 107 | +/** Creates a "less than ('<')" condition for this property. */ |
| 108 | +infix fun <T> Property<T>.less(value: Date): PropertyQueryCondition<T> { |
| 109 | + return less(value) |
| 110 | +} |
| 111 | + |
| 112 | +// String |
| 113 | +/** Creates an "equal ('=')" condition for this property. */ |
| 114 | +infix fun <T> Property<T>.equal(value: String): PropertyQueryCondition<T> { |
| 115 | + return equal(value) |
| 116 | +} |
| 117 | + |
| 118 | +/** Creates a "not equal ('<>')" condition for this property. */ |
| 119 | +infix fun <T> Property<T>.notEqual(value: String): PropertyQueryCondition<T> { |
| 120 | + return notEqual(value) |
| 121 | +} |
| 122 | + |
| 123 | +/** Creates a "greater than ('>')" condition for this property. */ |
| 124 | +infix fun <T> Property<T>.greater(value: String): PropertyQueryCondition<T> { |
| 125 | + return greater(value) |
| 126 | +} |
| 127 | + |
| 128 | +/** Creates a "less than ('<')" condition for this property. */ |
| 129 | +infix fun <T> Property<T>.less(value: String): PropertyQueryCondition<T> { |
| 130 | + return less(value) |
| 131 | +} |
| 132 | + |
| 133 | +infix fun <T> Property<T>.contains(value: String): PropertyQueryCondition<T> { |
| 134 | + return contains(value) |
| 135 | +} |
| 136 | + |
| 137 | +infix fun <T> Property<T>.startsWith(value: String): PropertyQueryCondition<T> { |
| 138 | + return startsWith(value) |
| 139 | +} |
| 140 | + |
| 141 | +infix fun <T> Property<T>.endsWith(value: String): PropertyQueryCondition<T> { |
| 142 | + return endsWith(value) |
| 143 | +} |
| 144 | + |
| 145 | +// Array<String> |
| 146 | +/** Creates an "IN (..., ..., ...)" condition for this property. */ |
| 147 | +infix fun <T> Property<T>.oneOf(value: Array<String>): PropertyQueryCondition<T> { |
| 148 | + return oneOf(value) |
| 149 | +} |
| 150 | + |
| 151 | +// ByteArray |
| 152 | +/** Creates an "equal ('=')" condition for this property. */ |
| 153 | +infix fun <T> Property<T>.equal(value: ByteArray): PropertyQueryCondition<T> { |
| 154 | + return equal(value) |
| 155 | +} |
| 156 | + |
| 157 | +/** Creates a "greater than ('>')" condition for this property. */ |
| 158 | +infix fun <T> Property<T>.greater(value: ByteArray): PropertyQueryCondition<T> { |
| 159 | + return greater(value) |
| 160 | +} |
| 161 | + |
| 162 | +/** Creates a "less than ('<')" condition for this property. */ |
| 163 | +infix fun <T> Property<T>.less(value: ByteArray): PropertyQueryCondition<T> { |
| 164 | + return less(value) |
| 165 | +} |
0 commit comments