0e0ebf00c594018eaa0bd2f85784c77b800cb61c
[groupbasedpolicy.git] / groupbasedpolicy / src / main / java / org / opendaylight / groupbasedpolicy / resolver / validator / validators / ActionInstanceValidator.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.groupbasedpolicy.resolver.validator.validators;
10
11 import org.opendaylight.groupbasedpolicy.resolver.validator.AbstractValidator;
12 import org.opendaylight.groupbasedpolicy.resolver.validator.SimpleResult;
13
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.subject.feature.instances.ActionInstance;
15
16 /**
17  * Validator for {@link ActionInstance}
18  */
19 public class ActionInstanceValidator extends AbstractValidator<ActionInstance> {
20
21     @Override
22     protected SimpleResult validateSelf(ActionInstance objectToValidate) {
23         org.opendaylight.groupbasedpolicy.resolver.ActionInstanceValidator action = getPolicyResolver().getActionInstanceValidator(objectToValidate.getActionDefinitionId());
24         if (action == null) {
25             return new SimpleResult(false, "Action not registered in PolicyResolver.");
26         }
27
28         boolean isValid = action.isValid(objectToValidate);
29
30         return new SimpleResult(isValid, "Validation result of " + action.getClass().getName() + " class.");
31     }
32
33     @Override
34     public Class<ActionInstance> getType() {
35         return ActionInstance.class;
36     }
37
38 }