Class InMemoryBeanQueryContext<T>

java.lang.Object
org.apache.juneau.commons.beanquery.BeanQueryContext<T>
org.apache.juneau.commons.beanquery.InMemoryBeanQueryContext<T>
Type Parameters:
T - The row (bean) type.

public final class InMemoryBeanQueryContext<T> extends BeanQueryContext<T>
The in-memory BeanQueryContext: runs BeanQuerys against an in-JVM collection of beans or maps.

create(Class) declares one column per readable Juneau bean property: getters (getX(), or isX() for booleans), public fields, and record components, named and filtered by the same rules serializers use (@BeanIgnore, @BeanProp, the property namer). The value type is inferred from the property type. Use create(Class, BeanConfigContext) or create(BeanMeta) to apply a specific bean configuration. Nothing else is queryable: class, toString and other methods are not columns. Narrow the list with exclude or columns, add derived columns with column plus accessor, and scope every session with a server-only guard. create() is for Map rows: declare each column, and it is read by key.

The context holds no rows. Open a session over a specific collection with getSession(Collection) or createSession().

Example:

InMemoryBeanQueryContext<Person> context = InMemoryBeanQueryContext .create(Person.class) .exclude("ssn") .column("initial", SearchType.TEXT) .accessor("initial", p -> p.getName().substring(0, 1)) .guard(Person::isActive) .build(); try (InMemoryBeanQuerySession<Person> session = context.getSession(people)) { Page<Person> page = session.find(BeanQuery.create().setSearch("age=$gt(21)").setSort("name")); } // The bean rules of a specific serializer configuration. InMemoryBeanQueryContext<Person> dashed = InMemoryBeanQueryContext .create(Person.class, BeanConfigContext.create().propertyNamer(PropertyNamerDLC.INSTANCE).build()) .build(); // Map rows: declare the columns. InMemoryBeanQueryContext<Map<String,Object>> maps = InMemoryBeanQueryContext .<Map<String,Object>>create() .column("name", SearchType.TEXT) .column("age", SearchType.NUMERIC) .build();

Since:
10.0.0