2 * In Samsung Ukraine R&D Center (SRK under a contract between)
3 * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
4 * Copyright (C) 2017 Samsung Electronics Co., Ltd. All rights reserved.
6 package com.samsung.dsm.rule.parser;
8 import java.util.Arrays;
10 import org.apache.commons.lang3.builder.EqualsBuilder;
11 import org.apache.commons.lang3.builder.HashCodeBuilder;
13 import com.google.common.base.Objects;
16 * The type Rule config.
18 * @author <A HREF="mailto:y.zozulia@samsung.com">Yevhen Zozulia</A>
20 * @file RuleConfig.java
21 * @brief The type Rule config.
22 * @date Created : 10/6/2017
23 * @date Modified : 11/2/2017
24 * @copyright In Samsung Ukraine R&D Center (SRK under a contract between)
25 * @par LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
26 * @par Copyright : (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
28 public class RuleConfig {
33 * Instantiates a new Rule config.
35 * @param rules the rules
37 RuleConfig(Rule[] rules) {
38 this.rules = Arrays.copyOf(rules, rules.length);
44 * @return the rule [ ]
46 public Rule[] getRules() {
53 public static class Rule {
55 private String message;
58 private String fields;
60 private String reportType;
61 private String ruleType;
62 private String priority;
65 private Policy[] policies;
72 public String getMessage() {
79 * @param message the message
81 public void setMessage(String message) {
82 this.message = message;
90 public String getTitle() {
97 * @param title the title
99 public void setTitle(String title) {
108 public String getCode() {
115 * @param code the code
117 public void setCode(String code) {
126 public String getFields() {
133 * @param fields the fields
135 public void setFields(String fields) {
136 this.fields = fields;
144 public String getFind() {
151 * @param find the find
153 public void setFind(String find) {
160 * @return the report type
162 public String getReportType() {
169 * @param reportType the report type
171 public void setReportType(String reportType) {
172 this.reportType = reportType;
178 * @return the rule type
180 public String getRuleType() {
187 * @param ruleType the rule type
189 public void setRuleType(String ruleType) {
190 this.ruleType = ruleType;
196 * @return the priority
198 public String getPriority() {
205 * @param priority the priority
207 public void setPriority(String priority) {
208 this.priority = priority;
216 public String getLook() {
223 * @param look the look
225 public void setLook(String look) {
234 public String getUsed() {
241 * @param used the used
243 public void setUsed(String used) {
248 * Get policies policy [ ].
250 * @return the policy [ ]
252 public Policy[] getPolicies() {
259 * @param policies the policies
261 public void setPolicies(Policy[] policies) {
262 this.policies = Arrays.copyOf(policies, policies.length);
265 // CHECKSTYLE_OFF:Magic Number
267 public int hashCode() {
268 return new HashCodeBuilder(1, 31).append(code).append(fields).append(find).append(look).append(message)
269 .append(priority).append(reportType).append(ruleType).append(title).append(used).append(policies)
272 // CHECKSTYLE_ON:Magic Number
275 public boolean equals(Object obj) {
282 if (getClass() != obj.getClass()) {
285 Rule rule = (Rule) obj;
287 return new EqualsBuilder().append(code, rule.code).append(fields, rule.fields).append(find, rule.find)
288 .append(look, rule.look).append(message, rule.message).append(priority, rule.priority)
289 .append(reportType, rule.reportType).append(ruleType, rule.ruleType).append(title, rule.title)
290 .append(used, rule.used).append(policies, rule.policies).isEquals();
295 public String toString() {
296 return "Rule [message=" + message + ", title=" + title + ", code=" + code + ", fields=" + fields + ", find="
297 + find + ", reportType=" + reportType + ", ruleType=" + ruleType + ", priority=" + priority + ", look="
298 + look + ", used=" + used + "]";
304 public static class Policy {
308 private String[] items;
311 * Instantiates a new Policy.
313 * @param name the name
314 * @param state the state
315 * @param items the items
317 public Policy(String name, int state, String[] items) {
320 this.items = Arrays.copyOf(items, items.length);
328 public String getName() {
337 public int getState() {
342 * Get items string [ ].
344 * @return the string [ ]
346 public String[] getItems() {
353 * @param name the name
355 public void setName(String name) {
362 * @param state the state
364 public void setState(int state) {
371 * @param items the items
373 public void setItems(String[] items) {
374 this.items = Arrays.copyOf(items, items.length);
378 public boolean equals(Object o) {
382 if (!(o instanceof Policy)) {
385 Policy policy = (Policy) o;
387 return new EqualsBuilder().append(state, policy.state).append(name, policy.name)
388 .append(items, policy.items).isEquals();
391 // CHECKSTYLE_OFF:Magic Number
393 public int hashCode() {
394 return new HashCodeBuilder(17, 37).append(name).append(state).append(items).toHashCode();
396 // CHECKSTYLE_ON:Magic Number
399 public String toString() {
400 return Objects.toStringHelper(this).add("name", name).add("state", state).add("items", "skipped...")