-
Notifications
You must be signed in to change notification settings - Fork 215
/
EnforcementFactoryFactory.java
73 lines (67 loc) · 3.16 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
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.connectivity.service;
import java.util.Arrays;
import java.util.List;
import org.eclipse.ditto.base.model.entity.id.EntityId;
import org.eclipse.ditto.base.model.signals.Signal;
import org.eclipse.ditto.connectivity.model.Enforcement;
import org.eclipse.ditto.connectivity.model.EnforcementFilterFactory;
import org.eclipse.ditto.connectivity.service.placeholders.ConnectivityPlaceholders;
import org.eclipse.ditto.placeholders.Placeholder;
/**
* Factory class that creates instances of {@link EnforcementFilterFactory}s.
*/
public final class EnforcementFactoryFactory {
/**
* Creates new instance of {@link EnforcementFilterFactory} which can be used to create new {@link
* org.eclipse.ditto.connectivity.model.EnforcementFilter}s.
*
* @param enforcement the enforcement options containing the filter templates
* @param inputFilter the input placeholder used to resolve the input value
* @param filterPlaceholderResolver the filter placeholder used to resolve filter values
* @param <I> the type from which the input values are resolved
* @return the new {@link EnforcementFactoryFactory}
*/
private static <I> EnforcementFilterFactory<I, Signal<?>> newEnforcementFilterFactory(
final Enforcement enforcement,
final Placeholder<I> inputFilter, final List<Placeholder<EntityId>> filterPlaceholderResolver) {
return new SignalEnforcementFilterFactory<>(enforcement, inputFilter, filterPlaceholderResolver);
}
/**
* Creates new instance of {@link EnforcementFilterFactory} that is preconfigured with the following placeholders
* for the filters:
* <ul>
* <li>{@link org.eclipse.ditto.edge.service.placeholders.ThingPlaceholder}</li>
* <li>{@link org.eclipse.ditto.edge.service.placeholders.PolicyPlaceholder}</li>
* <li>{@link org.eclipse.ditto.edge.service.placeholders.EntityIdPlaceholder}</li>
* </ul>
*
* @param <I> 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 the input
*/
public static <I> EnforcementFilterFactory<I, Signal<?>> newEnforcementFilterFactory(
final Enforcement enforcement,
final Placeholder<I> inputFilter) {
return newEnforcementFilterFactory(enforcement, inputFilter, Arrays.asList(
ConnectivityPlaceholders.newThingPlaceholder(),
ConnectivityPlaceholders.newPolicyPlaceholder(),
ConnectivityPlaceholders.newEntityPlaceholder()
));
}
private EnforcementFactoryFactory() {
throw new AssertionError();
}
}