blob: ffc1ab7483825a13a0a5a314c0d12a992d94673b (
plain) (
blame)
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
|
/*******************************************************************************
* Copyright (c) 2013 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.template.engine;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* @author Ryan D. Brooks
*/
public final class CompositeRule<T> extends AppendableRule<T> {
private final List<AppendableRule<T>> rules = new ArrayList<>();
public CompositeRule(String ruleName) {
super(ruleName);
}
@Override
public void applyTo(Appendable appendable) throws IOException {
for (AppendableRule<T> rule : rules) {
rule.applyTo(appendable);
}
}
@Override
public void applyTo(Appendable appendable, T data) throws IOException {
for (AppendableRule<T> rule : rules) {
rule.applyTo(appendable, data);
}
}
public void addRule(AppendableRule<T> rule) {
rules.add(rule);
}
public boolean ruleExists(String ruleName) {
for (AppendableRule<T> rule : rules) {
if (rule.getName().equals(ruleName)) {
return true;
}
}
return false;
}
}
|