]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.api/src/org/argeo/slc/primitive/PrimitiveSpecAttribute.java
Upgrade all classpaths to Java 11
[gpl/argeo-slc.git] / org.argeo.slc.api / src / org / argeo / slc / primitive / PrimitiveSpecAttribute.java
1 package org.argeo.slc.primitive;
2
3 import org.argeo.slc.SlcException;
4 import org.argeo.slc.execution.AbstractSpecAttribute;
5
6 /**
7 * A spec attribute wrapping a primitive value.
8 *
9 * @see PrimitiveAccessor
10 */
11 public class PrimitiveSpecAttribute extends AbstractSpecAttribute implements
12 PrimitiveAccessor {
13 private static final long serialVersionUID = -566676381839825483L;
14 private String type = "string";
15 private Object value = null;
16
17 public PrimitiveSpecAttribute() {
18 }
19
20 public PrimitiveSpecAttribute(String type, Object value) {
21 this.type = type;
22 this.value = value;
23 }
24
25 public Object getValue() {
26 return value;
27 }
28
29 public void setValue(Object value) {
30 this.value = value;
31 }
32
33 public String getType() {
34 return type;
35 }
36
37 public void setType(String type) {
38 // check whether type is recognized.
39 if (PrimitiveUtils.typeAsClass(type) == null)
40 throw new SlcException("Unrecognized type " + type);
41 this.type = type;
42
43 }
44
45 @Override
46 public String toString() {
47 return "Primitive spec attribute [" + type + "]"
48 + (value != null ? "=" + value : "");
49 }
50
51 }