2 * Copyright 2015 Samsung Electronics All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.oic.simulator;
19 public class ArrayProperty extends AttributeProperty {
23 private boolean mIsVariableSize;
24 private boolean mIsUnique;
25 private AttributeProperty mElementProperty;
26 private boolean mHasRange = false;
28 private ArrayProperty(int min, int max, boolean variableSize,
29 boolean unique, AttributeProperty elementProperty) {
33 mIsVariableSize = variableSize;
35 mElementProperty = elementProperty;
39 private ArrayProperty(boolean variableSize, boolean unique,
40 AttributeProperty elementProperty) {
42 mIsVariableSize = variableSize;
44 mElementProperty = elementProperty;
48 public boolean isArray() {
53 public ArrayProperty asArray() {
57 public boolean hasRange() {
61 public int minItems() {
65 public int maxItems() {
69 public boolean isVariable() {
70 return mIsVariableSize;
73 public boolean isUnique() {
77 public AttributeProperty getElementProperty() {
78 return mElementProperty;
82 public boolean validate(AttributeValue value) {
83 return new ArrayValueValidator(this).validate(value);
86 public static class Builder {
89 private boolean mIsVariableSize = false;
90 private boolean mIsUnique = false;
91 private AttributeProperty mElementProperty = null;
92 private boolean mHasRange = false;
94 public void setRange(int minItems, int maxItems) {
100 public void setVariableSize(boolean state) {
101 mIsVariableSize = state;
104 public void setUnique(boolean state) {
108 public void setElementProperty(AttributeProperty property) {
109 mElementProperty = property;
112 public ArrayProperty build() {
113 if (null == mElementProperty)
117 return new ArrayProperty(mMin, mMax, mIsVariableSize,
118 mIsUnique, mElementProperty);
119 return new ArrayProperty(mIsVariableSize, mIsUnique,