001: /*****************************************************************************
002: * Java Plug-in Framework (JPF)
003: * Copyright (C) 2006-2007 Dmitry Olshansky
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *****************************************************************************/package org.java.plugin.tools.mocks;
019:
020: import java.util.Collection;
021: import java.util.Collections;
022: import java.util.LinkedList;
023: import org.java.plugin.registry.ExtensionPoint;
024: import org.java.plugin.registry.ParameterMultiplicity;
025: import org.java.plugin.registry.ParameterType;
026: import org.java.plugin.registry.ExtensionPoint.ParameterDefinition;
027:
028: /**
029: * @version $Id$
030: */
031: public class MockParameterDefinition extends
032: MockPluginElement<ParameterDefinition> implements
033: ParameterDefinition {
034: private String customData;
035: private ExtensionPoint declaringExtensionPoint;
036: private String defaultValue;
037: private ParameterMultiplicity multiplicity;
038: private ParameterType type;
039: private ParameterDefinition super Definition;
040: private LinkedList<ParameterDefinition> subDefinitions = new LinkedList<ParameterDefinition>();
041:
042: /**
043: * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getCustomData()
044: */
045: public String getCustomData() {
046: return customData;
047: }
048:
049: /**
050: * @param value the custom data to set
051: * @return this instance
052: */
053: public MockParameterDefinition setCustomData(final String value) {
054: customData = value;
055: return this ;
056: }
057:
058: /**
059: * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getDeclaringExtensionPoint()
060: */
061: public ExtensionPoint getDeclaringExtensionPoint() {
062: return declaringExtensionPoint;
063: }
064:
065: /**
066: * @param value the declaring extension point to set
067: * @return this instance
068: */
069: public MockParameterDefinition setDeclaringExtensionPoint(
070: final ExtensionPoint value) {
071: declaringExtensionPoint = value;
072: return this ;
073: }
074:
075: /**
076: * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getDefaultValue()
077: */
078: public String getDefaultValue() {
079: return defaultValue;
080: }
081:
082: /**
083: * @param value the default value to set
084: * @return this instance
085: */
086: public MockParameterDefinition setDefaultValue(final String value) {
087: defaultValue = value;
088: return this ;
089: }
090:
091: /**
092: * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getMultiplicity()
093: */
094: public ParameterMultiplicity getMultiplicity() {
095: return multiplicity;
096: }
097:
098: /**
099: * @param value the multiplicity to set
100: * @return this instance
101: */
102: public MockParameterDefinition setMultiplicity(
103: final ParameterMultiplicity value) {
104: multiplicity = value;
105: return this ;
106: }
107:
108: /**
109: * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getSubDefinition(java.lang.String)
110: */
111: public ParameterDefinition getSubDefinition(String id) {
112: for (ParameterDefinition paramDef : subDefinitions) {
113: if (paramDef.getId().equals(id)) {
114: return paramDef;
115: }
116: }
117: throw new IllegalArgumentException(
118: "unknown parameter definition ID " + id); //$NON-NLS-1$
119: }
120:
121: /**
122: * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getSubDefinitions()
123: */
124: public Collection<ParameterDefinition> getSubDefinitions() {
125: return Collections.unmodifiableCollection(subDefinitions);
126: }
127:
128: /**
129: * @param parameterDefinition sub-parameter definition to add
130: * @return this instance
131: */
132: public MockParameterDefinition addSubDefinition(
133: final ParameterDefinition parameterDefinition) {
134: subDefinitions.add(parameterDefinition);
135: return this ;
136: }
137:
138: /**
139: * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getSuperDefinition()
140: */
141: public ParameterDefinition getSuperDefinition() {
142: return super Definition;
143: }
144:
145: /**
146: * @param value the super definition to set
147: * @return this instance
148: */
149: public MockParameterDefinition setSuperDefinition(
150: final ParameterDefinition value) {
151: super Definition = value;
152: return this ;
153: }
154:
155: /**
156: * @see org.java.plugin.registry.ExtensionPoint.ParameterDefinition#getType()
157: */
158: public ParameterType getType() {
159: return type;
160: }
161:
162: /**
163: * @param value the type to set
164: * @return this instance
165: */
166: public MockParameterDefinition setType(final ParameterType value) {
167: type = value;
168: return this;
169: }
170: }
|