2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.ccsdk.apps.ms.neng.core.policy;
24 * Represents a sequence object in the policy, as a POJO.
26 public class PolicySequence {
28 * The type of the policy sequence.
34 private long startValue;
35 private long increment;
37 private Long maxValue;
38 private String maxValueString;
39 private Type type = Type.NUMERIC;
43 private Long lastReleaseSeqNumTried;
45 public long getStartValue() {
49 public void setStartValue(long startValue) {
50 this.startValue = startValue;
53 public long getIncrement() {
57 public void setIncrement(long increment) {
58 this.increment = increment;
61 public long getLength() {
65 public void setLength(long length) {
70 * Generate and return the maximum value for the sequence.
72 public long getMaxValue() {
73 if (this.maxValue == null) {
75 if (this.type == Type.ALPHA) {
78 if (this.maxValueString != null) {
80 this.maxValue = Long.valueOf(this.maxValueString, base);
81 } catch (Exception e) {
85 if (this.maxValue == null) {
86 long length = this.length;
90 this.maxValue = (long) Math.pow(base, length) - 1;
96 public void setMaxValue(long maxValue) {
97 this.maxValue = maxValue;
100 public String getMaxValueString() {
101 return maxValueString;
104 public void setMaxValueString(String maxValueString) {
105 this.maxValueString = maxValueString;
108 public Type getType() {
112 public void setType(Type type) {
119 public void setType(String typeStr) {
120 if ("numeric".equalsIgnoreCase(typeStr)) {
121 setType(Type.NUMERIC);
122 } else if ("alpha-numeric".equalsIgnoreCase(typeStr)) {
127 public String getScope() {
131 public void setScope(String scope) {
135 public String getValue() {
139 public void setValue(String value) {
143 public String getKey() {
147 public void setKey(String key) {
151 public Long getLastReleaseSeqNumTried() {
152 return lastReleaseSeqNumTried;
155 public void setLastReleaseSeqNumTried(Long lastReleaseSeqNumTried) {
156 this.lastReleaseSeqNumTried = lastReleaseSeqNumTried;