]> git.argeo.org Git - gpl/argeo-slc.git/blob - core/execution/RefSpecAttribute.java
Prepare next development cycle
[gpl/argeo-slc.git] / core / execution / RefSpecAttribute.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 package org.argeo.slc.core.execution;
18
19 import java.util.List;
20
21 /** A spec attribute whose value is a reference to a full fledged object. */
22 public class RefSpecAttribute extends AbstractSpecAttribute implements
23 Cloneable {
24 private static final long serialVersionUID = -3427797452955753574L;
25 private transient Class<?> targetClass = String.class;
26 /** Read only. */
27 private String targetClassName;
28 private transient Object value = null;
29
30 /** List to be chosen from */
31 private List<RefValueChoice> choices = null;
32
33 public Object getValue() {
34 return value;
35 }
36
37 public void setValue(Object value) {
38 this.value = value;
39 }
40
41 /** Default is {@link String} */
42 public Class<?> getTargetClass() {
43 return targetClass;
44 }
45
46 public void setTargetClass(Class<?> targetClass) {
47 this.targetClass = targetClass;
48 this.targetClassName = targetClass.getName();
49 }
50
51 public String getTargetClassName() {
52 return targetClassName;
53 }
54
55 /** @return can be null */
56 public List<RefValueChoice> getChoices() {
57 return choices;
58 }
59
60 public void setChoices(List<RefValueChoice> choices) {
61 this.choices = choices;
62 }
63
64 @Override
65 protected Object clone() throws CloneNotSupportedException {
66 RefSpecAttribute rsa = new RefSpecAttribute();
67 rsa.setTargetClass(targetClass);
68 rsa.setChoices(choices);
69 return rsa;
70 }
71
72 @Override
73 public String toString() {
74 return "Ref spec attribute [" + targetClass + "]"
75 + (value != null ? "=" + value : "");
76 }
77
78 }