001
014
015 package com.liferay.portlet;
016
017 import com.liferay.portal.kernel.util.StringBundler;
018 import com.liferay.portal.kernel.util.StringPool;
019
020 import java.io.Serializable;
021
022
025 public class Preference implements Cloneable, Serializable {
026
027 public Preference(String name, String value) {
028 this(name, new String[] {value});
029 }
030
031 public Preference(String name, String value, boolean readOnly) {
032 this(name, new String[] {value}, readOnly);
033 }
034
035 public Preference(String name, String[] values) {
036 this(name, values, false);
037 }
038
039 public Preference(String name, String[] values, boolean readOnly) {
040 _name = name;
041 _values = values;
042 _readOnly = readOnly;
043 }
044
045 @Override
046 public Object clone() {
047 return new Preference(_name, _values, _readOnly);
048 }
049
050 public String getName() {
051 return _name;
052 }
053
054 public boolean getReadOnly() {
055 return _readOnly;
056 }
057
058 public String[] getValues() {
059 return _values;
060 }
061
062 public boolean isReadOnly() {
063 return _readOnly;
064 }
065
066 public void setValues(String[] values) {
067 _values = values;
068 }
069
070 @Override
071 public String toString() {
072 StringBundler sb = new StringBundler(6 + (_values.length * 2 - 1));
073
074 sb.append("{name=");
075 sb.append(getName());
076 sb.append(", readOnly=");
077 sb.append(_readOnly);
078 sb.append(", values=[");
079
080 for (int i = 0; i < _values.length; i++) {
081 sb.append(_values[i]);
082
083 if (i < (_values.length - 1)) {
084 sb.append(StringPool.COMMA);
085 }
086 }
087
088 sb.append("]}");
089
090 return sb.toString();
091 }
092
093 private String _name;
094 private boolean _readOnly;
095 private String[] _values;
096
097 }