@Test public void add_duplicate_parameter() { Resource r = mockResource(); Logger logger = mockLogger(); replay(); MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null); model.addParameter("fred", true, true, BindingConstants.PROP); try { model.addParameter("Fred", true, true, BindingConstants.PROP); unreachable(); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage(), "Parameter 'Fred' of component class org.example.components.Foo is already defined."); } verify(); }
public void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix, boolean cached) { assert InternalUtils.isNonBlank(name); assert InternalUtils.isNonBlank(defaultBindingPrefix); if (parameters == null) { parameters = CollectionFactory.newCaseInsensitiveMap(); } if (parameters.containsKey(name)) { throw new IllegalArgumentException(String.format("Parameter '%s' of component class %s is already defined.", name, componentClassName)); } ParameterModel existingModel = getParameterModel(name); if (existingModel != null) { throw new IllegalArgumentException(String.format("Parameter '%s' of component class %s conflicts with the parameter defined by the %s base class.", name, componentClassName, existingModel.getComponentModel().getComponentClassName())); } parameters.put(name, new ParameterModelImpl(this, name, required, allowNull, defaultBindingPrefix, cached)); }
MutableComponentModelImpl implements MutableComponentModel { public void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix, boolean cached) { assert InternalUtils.isNonBlank(name); assert InternalUtils.isNonBlank(defaultBindingPrefix); if (parameters == null) { parameters = CollectionFactory.newCaseInsensitiveMap(); } if (parameters.containsKey(name)) { throw new IllegalArgumentException(String.format("Parameter '%s' of component class %s is already defined.", name, componentClassName)); } ParameterModel existingModel = getParameterModel(name); if (existingModel != null) { throw new IllegalArgumentException(String.format("Parameter '%s' of component class %s conflicts with the parameter defined by the %s base class.", name, componentClassName, existingModel.getComponentModel().getComponentClassName())); } parameters.put(name, new ParameterModelImpl(this, name, required, allowNull, defaultBindingPrefix, cached)); } }
MutableComponentModelImpl implements MutableComponentModel { public void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix, boolean cached) { assert InternalUtils.isNonBlank(name); assert InternalUtils.isNonBlank(defaultBindingPrefix); if (parameters == null) { parameters = CollectionFactory.newCaseInsensitiveMap(); } if (parameters.containsKey(name)) { throw new IllegalArgumentException(String.format("Parameter '%s' of component class %s is already defined.", name, componentClassName)); } ParameterModel existingModel = getParameterModel(name); if (existingModel != null) { throw new IllegalArgumentException(String.format("Parameter '%s' of component class %s conflicts with the parameter defined by the %s base class.", name, componentClassName, existingModel.getComponentModel().getComponentClassName())); } parameters.put(name, new ParameterModelImpl(this, name, required, allowNull, defaultBindingPrefix, cached)); } MutableComponentModelImpl(String componentClassName, Logger logger, Resource baseResource,
                                     ComponentModel parentModel, boolean pageClass, String libraryName); }
MutableComponentModelImpl implements MutableComponentModel { public void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix, boolean cached) { assert InternalUtils.isNonBlank(name); assert InternalUtils.isNonBlank(defaultBindingPrefix); if (parameters == null) { parameters = CollectionFactory.newCaseInsensitiveMap(); } if (parameters.containsKey(name)) { throw new IllegalArgumentException(String.format("Parameter '%s' of component class %s is already defined.", name, componentClassName)); } ParameterModel existingModel = getParameterModel(name); if (existingModel != null) { throw new IllegalArgumentException(String.format("Parameter '%s' of component class %s conflicts with the parameter defined by the %s base class.", name, componentClassName, existingModel.getComponentModel().getComponentClassName())); } parameters.put(name, new ParameterModelImpl(this, name, required, allowNull, defaultBindingPrefix, cached)); } MutableComponentModelImpl(String componentClassName, Logger logger, Resource baseResource,
                                     ComponentModel parentModel, boolean pageClass, String libraryName); String getLibraryName(); @Override String toString(); Logger getLogger(); Resource getBaseResource(); String getComponentClassName(); void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix,
                             boolean cached); void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix); ParameterModel getParameterModel(String parameterName); boolean isFormalParameter(String parameterName); List<String> getParameterNames(); List<String> getDeclaredParameterNames(); MutableEmbeddedComponentModel addEmbeddedComponent(String id, String type, String componentClassName,
                                                              boolean inheritInformalParameters, Location location); List<String> getEmbeddedComponentIds(); EmbeddedComponentModel getEmbeddedComponentModel(String componentId); String getFieldPersistenceStrategy(String fieldName); List<String> getPersistentFieldNames(); String setFieldPersistenceStrategy(String fieldName, String strategy); boolean isRootClass(); void addMixinClassName(String mixinClassName, String... order); List<String> getMixinClassNames(); void enableSupportsInformalParameters(); boolean getSupportsInformalParameters(); ComponentModel getParentModel(); boolean isMixinAfter(); void setMixinAfter(boolean mixinAfter); void setMeta(String key, String value); void addRenderPhase(Class renderPhase); void addEventHandler(String eventType); String getMeta(String key); Set<Class> getHandledRenderPhases(); boolean handlesEvent(String eventType); String[] getOrderForMixin(String mixinClassName); boolean isPage(); void doHandleActivationEventContext(); boolean handleActivationEventContext(); }
MutableComponentModelImpl implements MutableComponentModel { public void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix, boolean cached) { assert InternalUtils.isNonBlank(name); assert InternalUtils.isNonBlank(defaultBindingPrefix); if (parameters == null) { parameters = CollectionFactory.newCaseInsensitiveMap(); } if (parameters.containsKey(name)) { throw new IllegalArgumentException(String.format("Parameter '%s' of component class %s is already defined.", name, componentClassName)); } ParameterModel existingModel = getParameterModel(name); if (existingModel != null) { throw new IllegalArgumentException(String.format("Parameter '%s' of component class %s conflicts with the parameter defined by the %s base class.", name, componentClassName, existingModel.getComponentModel().getComponentClassName())); } parameters.put(name, new ParameterModelImpl(this, name, required, allowNull, defaultBindingPrefix, cached)); } MutableComponentModelImpl(String componentClassName, Logger logger, Resource baseResource,
                                     ComponentModel parentModel, boolean pageClass, String libraryName); String getLibraryName(); @Override String toString(); Logger getLogger(); Resource getBaseResource(); String getComponentClassName(); void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix,
                             boolean cached); void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix); ParameterModel getParameterModel(String parameterName); boolean isFormalParameter(String parameterName); List<String> getParameterNames(); List<String> getDeclaredParameterNames(); MutableEmbeddedComponentModel addEmbeddedComponent(String id, String type, String componentClassName,
                                                              boolean inheritInformalParameters, Location location); List<String> getEmbeddedComponentIds(); EmbeddedComponentModel getEmbeddedComponentModel(String componentId); String getFieldPersistenceStrategy(String fieldName); List<String> getPersistentFieldNames(); String setFieldPersistenceStrategy(String fieldName, String strategy); boolean isRootClass(); void addMixinClassName(String mixinClassName, String... order); List<String> getMixinClassNames(); void enableSupportsInformalParameters(); boolean getSupportsInformalParameters(); ComponentModel getParentModel(); boolean isMixinAfter(); void setMixinAfter(boolean mixinAfter); void setMeta(String key, String value); void addRenderPhase(Class renderPhase); void addEventHandler(String eventType); String getMeta(String key); Set<Class> getHandledRenderPhases(); boolean handlesEvent(String eventType); String[] getOrderForMixin(String mixinClassName); boolean isPage(); void doHandleActivationEventContext(); boolean handleActivationEventContext();  }