1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 package org.apache.jmeter.samplers; 20 21 import java.util.HashMap; 22 import java.util.LinkedList; 23 import java.util.List; 24 import java.util.Map; 25 26 import org.apache.jmeter.assertions.Assertion; 27 import org.apache.jmeter.config.ConfigElement; 28 29 // TODO - not used at present - could perhaps be removed 30 public class Entry { 31 32 private Map configSet; 33 34 // Set clonedSet; 35 private Class sampler; 36 37 private List assertions; 38 39 public Entry() { 40 configSet = new HashMap(); 41 // clonedSet = new HashSet(); 42 assertions = new LinkedList(); 43 } 44 45 public void addAssertion(Assertion assertion) { 46 assertions.add(assertion); 47 } 48 49 public List getAssertions() { 50 return assertions; 51 } 52 53 public void setSamplerClass(Class samplerClass) { 54 this.sampler = samplerClass; 55 } 56 57 public Class getSamplerClass() { 58 return this.sampler; 59 } 60 61 public ConfigElement getConfigElement(Class configClass) { 62 return (ConfigElement) configSet.get(configClass); 63 } 64 65 public void addConfigElement(ConfigElement config) { 66 addConfigElement(config, config.getClass()); 67 } 68 69 /** 70 * Add a config element as a specific class. Usually this is done to add a 71 * subclass as one of it's parent classes. 72 */ 73 public void addConfigElement(ConfigElement config, Class asClass) { 74 if (config != null) { 75 ConfigElement current = (ConfigElement) configSet.get(asClass); 76 if (current == null) { 77 configSet.put(asClass, cloneIfNecessary(config)); 78 } else { 79 current.addConfigElement(config); 80 } 81 } 82 } 83 84 private ConfigElement cloneIfNecessary(ConfigElement config) { 85 if (config.expectsModification()) { 86 return config; 87 } 88 return (ConfigElement) config.clone(); 89 } 90 }