/
EnforcementFactoryFactory.java
60 lines (53 loc) · 2.49 KB
/
EnforcementFactoryFactory.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Copyright (c) 2017-2018 Bosch Software Innovations GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/index.php
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.services.models.connectivity.placeholder;
import org.eclipse.ditto.model.connectivity.Enforcement;
/**
* Factory class that creates instances of {@link EnforcementFilterFactory}s.
*/
public class EnforcementFactoryFactory {
/**
* Creates new instance of {@link EnforcementFilterFactory} which can be used to create new
* {@link EnforcementFilter}s.
*
* @param enforcement the enforcement options containing the filter templates
* @param inputFilter the input filter that is applied to resolve input value
* @param matcherFilter the matcher filter that is applied to resolve matcher values
* @param <I> the type from which the input values are resolved
* @param <M> the type from which the matcher values are resolved
* @return the new {@link EnforcementFactoryFactory}
*/
public static <I, M> EnforcementFilterFactory<I, M> newEnforcementFactory(final Enforcement enforcement,
final Placeholder<I> inputFilter, final Placeholder<M> matcherFilter) {
return new ImmutableEnforcementFilterFactory<>(enforcement, inputFilter, matcherFilter);
}
/**
* Creates new instance of {@link EnforcementFilterFactory} that is preconfigured with a {@link ThingPlaceholder}
* filter for matcher values.
*
* @param <O> the type from which the input values are resolved
* @param enforcement the enforcement options
* @param inputFilter the input filter that is applied to resolve input value
* @return the new {@link EnforcementFactoryFactory} used to match Thing IDs
*/
public static <O> EnforcementFilterFactory<O, String> newThingIdEnforcementFactory(final Enforcement enforcement,
final Placeholder<O> inputFilter) {
return new ImmutableEnforcementFilterFactory<>(enforcement, inputFilter, ImmutableThingPlaceholder.INSTANCE);
}
/**
* Simple factory that returns a factory for noop filter.
*
* @return the new {@link EnforcementFactoryFactory}
*/
public static EnforcementFilterFactory<Object, String> newNullEnforcementFactory() {
return inputValue -> null;
}
}