summaryrefslogtreecommitdiffstats
path: root/dcaedt_be/src/main/java/org/onap/sdc/dcae/rule/editor/validators/ConcatActionValidator.java
blob: 965c898ad26bb04e8a0e10607885ece9867d8d1a (plain)
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
package org.onap.sdc.dcae.rule.editor.validators;

import org.onap.sdc.dcae.composition.restmodels.ruleeditor.BaseAction;
import org.onap.sdc.dcae.errormng.ActionStatus;
import org.onap.sdc.dcae.errormng.ErrConfMgr;
import org.onap.sdc.dcae.errormng.ResponseFormat;
import org.onap.sdc.dcae.rule.editor.utils.ValidationUtils;

import java.util.List;

public class ConcatActionValidator extends ActionValidator<BaseAction> {

	private static ConcatActionValidator concatActionValidator = new ConcatActionValidator();

	public static ConcatActionValidator getInstance() {
		return concatActionValidator;
	}

	private ConcatActionValidator(){}

	@Override
	protected boolean validateFromValue(BaseAction action, List<ResponseFormat> errors) {
		if(!ValidationUtils.validateNotEmpty(action.getFromValue()) || 2 > action.getFromValues().size()) {
			errors.add(ErrConfMgr.INSTANCE.getResponseFormat(ActionStatus.MISSING_CONCAT_VALUE, null, action.getTarget()));
			return false;
		}
		return true;
	}
}