Class QueryProperty
SearchType, and how to read
and write it.
Instances come from QueryModel. The name is the Juneau bean property name, after @BeanProp
and the configured PropertyNamer, so it is the name serializers emit. Reads use the getter (or record
accessor), else the field. Writes use the setter, else a non-final field.
Example:
QueryProperty
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanRead()Returnstrue if the property has a getter or a field and isn't write-only.booleancanWrite()Returnstrue if the property has a setter or a non-final field.getName()Returns the property (column) name.Returns the search type inferred fromgetType().Class<?>getType()Returns the declared read type: the getter's return type, else the field type, else the setter's parameter type.Class<?>Returns the typewrite(Object, Object)accepts: the setter's parameter type, elsegetType().Reads the property from a bean.static SearchTypesearchTypeOf(Class<?> t) Infers a column'sSearchTypefrom a property's declared type.toString()voidWrites the property on a bean.
-
Method Details
-
searchTypeOf
Infers a column'sSearchTypefrom a property's declared type.Booleans are
SearchType.BOOLEAN; characters areSearchType.TEXT; primitives andNumbers areSearchType.NUMERIC; enums areSearchType.ENUM; dates, calendars and temporals areSearchType.TIMESTAMP; everything else isSearchType.TEXT.Example:
QueryProperty.
searchTypeOf (int .class );// NUMERIC QueryProperty.searchTypeOf (Instant.class );// TIMESTAMP QueryProperty.searchTypeOf (String.class );// TEXT - Parameters:
t- The property type. Must not benull .- Returns:
- The inferred type (never
null ).
-
getName
Returns the property (column) name.- Returns:
- The name. Never
null .
-
getType
Returns the declared read type: the getter's return type, else the field type, else the setter's parameter type.- Returns:
- The type. Never
null .
-
getWriteType
Returns the typewrite(Object, Object)accepts: the setter's parameter type, elsegetType().- Returns:
- The type. Never
null .
-
getSearchType
Returns the search type inferred fromgetType().- Returns:
- The search type. Never
null .
-
canRead
Returnstrue if the property has a getter or a field and isn't write-only.- Returns:
true ifread(Object)is supported.
-
canWrite
Returnstrue if the property has a setter or a non-final field.@BeanProp(ro)is deliberately ignored: in Juneau it means "parsers must not set this property", and loading a database row is not parsing.- Returns:
true ifwrite(Object, Object)is supported.
-
read
Reads the property from a bean.- Parameters:
bean- The bean. Must not benull .- Returns:
- The value. Can be
null . - Throws:
BeanQueryExecutionException- If the getter throws or the value can't be read. The cause is the getter's own exception.IllegalArgumentException- Ifbean isnull .IllegalStateException- If the property is not readable.
-
write
Writes the property on a bean. Anull for a primitive property is ignored, so the bean keeps its default.- Parameters:
bean- The bean. Must not benull .value- The value, assignable togetWriteType(). Can benull .- Throws:
BeanQueryExecutionException- If the setter throws or the value can't be written. The cause is the setter's own exception.IllegalArgumentException- Ifbean isnull .IllegalStateException- If the property is not writable.
-
toString
-