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