Package hudson.util

Examples of hudson.util.CopyOnWriteList


            for (Trigger trigger : oldTriggers.values()) {
                triggers.add(trigger);
            }

      DescribableList<BuildWrapper, Descriptor<BuildWrapper>> implementationBuildWrappers = ((BuildableItemWithBuildWrappers) newImplementation).getBuildWrappersList();
      CopyOnWriteList data = ReflectionUtils.getField(CopyOnWriteList.class, implementationBuildWrappers, "data");

      //strip out any template definitions or implementation definitions copied from the template
      List<BuildWrapper> toRemove = new LinkedList<BuildWrapper>();
      for (BuildWrapper buildWrapper : implementationBuildWrappers) {
        if(buildWrapper instanceof TemplateBuildWrapper) {
          if(template.getName().equals(((TemplateBuildWrapper) buildWrapper).getTemplateName())) {
            toRemove.add(buildWrapper);
          }
        } else if(buildWrapper instanceof ImplementationBuildWrapper) {
          toRemove.add(buildWrapper);
        }
      }
      for (BuildWrapper buildWrapper : toRemove) {
        data.remove(buildWrapper);
      }

      //make sure the implementation definition is still in there
      data.add(implementationBuildWrapper);

      newImplementation.getConfigFile().write(newImplementation); //don't call save() because it calls the event handlers.
      item = (TopLevelItem) Items.load(Jenkins.getInstance(), implementationXmlFile.getFile().getParentFile());

      putItemInJenkins(Jenkins.getInstance(), item);
View Full Code Here


        for(Object obj : rawList) {
            DBObject dbObj = (DBObject) obj;
            core.add(getMapper().fromDBObject(optionalExtraInfo.getSubClass(), dbObj, getMapper().createEntityCache()));
        }

        return new CopyOnWriteList(core);
    }
View Full Code Here

    @Override
    public Object encode(Object value, MappedField optionalExtraInfo) {
        if (value == null) return null;

        CopyOnWriteList copyOnWriteList = (CopyOnWriteList) value;
        List core = new BasicDBList();

        for(Object obj : copyOnWriteList) {
            core.add(getMapper().toDBObject(obj));
        }
View Full Code Here

    /**
     * Verify {@link CopyOnWriteListProjectProperty#getDefaultValue()} method.
     */
    @Test
    public void testGetDefaultValue() {
        CopyOnWriteList defaultValue = property.getDefaultValue();
        assertNotNull(defaultValue);
        //Default value should be initialized and stored as original value
        assertTrue(property.getOriginalValue() == defaultValue);
        assertFalse(property.isOverridden());
    }
View Full Code Here

     * Verify {@link CopyOnWriteListProjectProperty#getOriginalValue()} method.
     */
    @Test
    public void testGetOriginalValue() {
        //Original value is not initialized. Default value will be used instead. Shouldn't be null
        CopyOnWriteList originalValue = property.getOriginalValue();
        assertNotNull(originalValue);
        //Value was set, so return it without modification
        assertTrue(originalValue == property.getOriginalValue());
    }
View Full Code Here

        //Return properties' originalValue if it was overridden
        property.setOverridden(true);
        assertTrue(property.returnOriginalValue());
        //If property has not empty value - return it (basically for non-cascadable projects)
        property.setOriginalValue(new CopyOnWriteList(Arrays.asList(new Object())), false);
        assertTrue(property.returnOriginalValue());
        //If property has not empty value and was overridden - return it
        property.setOriginalValue(new CopyOnWriteList(Arrays.asList(new Object())), true);
        assertTrue(property.returnOriginalValue());
    }
View Full Code Here

    @Test
    public void testClearOriginalValue() {
        //Overridden flag should be cleared to false. Pre-set true value
        property.setOverridden(true);
        assertTrue(property.isOverridden());
        CopyOnWriteList originalValue = new CopyOnWriteList(Arrays.asList(new Object()));
        property.clearOriginalValue(originalValue);
        //Original value should be set with overridden flag == false
        assertFalse(property.isOverridden());
        assertTrue(originalValue == property.getOriginalValue());
    }
View Full Code Here

        super(job);
    }

    @Override
    public CopyOnWriteList getDefaultValue() {
        CopyOnWriteList result = new CopyOnWriteList();
        setOriginalValue(result, false);
        return result;
    }
View Full Code Here

        return isOverridden() || !getOriginalValue().isEmpty();
    }

    @Override
    public CopyOnWriteList getOriginalValue() {
        CopyOnWriteList result = super.getOriginalValue();
        return null != result ? result : getDefaultValue();
    }
View Full Code Here

     * to cascadingJobProperties set.
     *
     * @param properties list of {@link JobProperty}
     */
    private void convertCascadingJobProperties(CopyOnWriteList<JobProperty<? super JobT>> properties) {
        CopyOnWriteList parameterDefinitionProperties = new CopyOnWriteList();
        for (JobProperty property : properties) {
            if (property instanceof AuthorizationMatrixProperty) {
                continue;
            }
            if (property instanceof ParametersDefinitionProperty) {
                parameterDefinitionProperties.add(property);
                continue;
            }
            BaseProjectProperty projectProperty = CascadingUtil.getBaseProjectProperty(this,
                property.getDescriptor().getJsonSafeClassName());
            addCascadingJobProperty(projectProperty);
View Full Code Here

TOP

Related Classes of hudson.util.CopyOnWriteList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.