-
Notifications
You must be signed in to change notification settings - Fork 7
/
StringListPropertyTransformer.java
43 lines (36 loc) · 1.17 KB
/
StringListPropertyTransformer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/
package sirius.biz.mongo;
import sirius.db.mixing.properties.StringListProperty;
import sirius.kernel.di.std.Register;
import sirius.kernel.di.transformers.Transformer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
/**
* Invokes the provided method to tokenize words for the items in a {@link StringListProperty}.
*/
@Register
public class StringListPropertyTransformer implements Transformer<StringListProperty, PrefixSearchableContentComputer> {
@Override
public Class<StringListProperty> getSourceClass() {
return StringListProperty.class;
}
@Override
public Class<PrefixSearchableContentComputer> getTargetClass() {
return PrefixSearchableContentComputer.class;
}
@Nullable
@Override
@SuppressWarnings("unchecked")
public PrefixSearchableContentComputer make(@Nonnull StringListProperty source) {
return (entity, consumer) -> {
((List<String>) source.getValue(entity)).forEach(consumer);
};
}
}