/*
Since {@link VersionSelectionPolicy} does not have a factory to create new objects we need to use the legacy
pattern of creating new objects using GobblinConstructorUtils
508898
@SuppressWarnings("unchecked")
  protected VersionSelectionPolicy<DatasetVersion> createSelectionPolicy(Config selectionConfig, Config jobConfig) {
    try {
      String selectionPolicyKey =
          StringUtils.substringAfter(ConfigurableCleanableDataset.SELECTION_POLICY_CLASS_KEY,
              ConfigurableCleanableDataset.CONFIGURATION_KEY_PREFIX);
      Preconditions.checkArgument(selectionConfig.hasPath(selectionPolicyKey));
      String className = selectionConfig.getString(selectionPolicyKey);
      return (VersionSelectionPolicy<DatasetVersion>) GobblinConstructorUtils.invokeFirstConstructor(
          this.versionSelectionAliasResolver.resolveClass(className), ImmutableList.<Object> of(selectionConfig),
          ImmutableList.<Object> of(selectionConfig, ConfigUtils.configToProperties(jobConfig)),
          ImmutableList.<Object> of(ConfigUtils.configToProperties(jobConfig)));
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
        | ClassNotFoundException e) {
      throw new IllegalArgumentException(e);
    }
  }
764511
public void setCompileVersion(String version) {
        if (version == null || ClassUtils.isBeforeJava6(version)) {
            JavassistCompiler javassistCompiler = new JavassistCompiler();
            javassistCompiler.setLogger(logger);
            javassistCompiler.setCodeDirectory(codeDirectory);
            compiler = javassistCompiler;
        } else {
            JdkCompiler jdkCompiler = new JdkCompiler();
            jdkCompiler.setCompileVersion(version);
            jdkCompiler.setLogger(logger);
            jdkCompiler.setCodeDirectory(codeDirectory);
            compiler = jdkCompiler;
        }
    }
768440
public static void doMetaUpdateVersionsOnStores(AdminClient adminClient,
                                                        List<StoreDefinition> oldStoreDefs,
                                                        List<StoreDefinition> newStoreDefs) {
            Set<String> storeNamesUnion = new HashSet<String>();
            Map<String, StoreDefinition> oldStoreDefinitionMap = new HashMap<String, StoreDefinition>();
            Map<String, StoreDefinition> newStoreDefinitionMap = new HashMap<String, StoreDefinition>();
            List<String> storesChanged = new ArrayList<String>();
            for(StoreDefinition storeDef: oldStoreDefs) {
                String storeName = storeDef.getName();
                storeNamesUnion.add(storeName);
                oldStoreDefinitionMap.put(storeName, storeDef);
            }
            for(StoreDefinition storeDef: newStoreDefs) {
                String storeName = storeDef.getName();
                storeNamesUnion.add(storeName);
                newStoreDefinitionMap.put(storeName, storeDef);
            }
            for(String storeName: storeNamesUnion) {
                StoreDefinition oldStoreDef = oldStoreDefinitionMap.get(storeName);
                StoreDefinition newStoreDef = newStoreDefinitionMap.get(storeName);
                if(oldStoreDef == null && newStoreDef != null || oldStoreDef != null
                   && newStoreDef == null || oldStoreDef != null && newStoreDef != null
                   && !oldStoreDef.equals(newStoreDef)) {
                    storesChanged.add(storeName);
                }
            }
            System.out.println("Updating metadata version for the following stores: "
                               + storesChanged);
            try {
                adminClient.metadataMgmtOps.updateMetadataversion(adminClient.getAdminClientCluster()
                                                                             .getNodeIds(),
                                                                  storesChanged);
            } catch(Exception e) {
                System.err.println("Error while updating metadata version for the specified store.");
            }
        }
866669
function buildNewOptions (options, newUrl) {

    // Old method
    /*
    var o = createDefaultOptions(newUrl);

    // Copy only options attributes that are in the options used for the previous request
    // Could be more simple ? ;-)

    o =  _.extend(o, _.pick(options, _.without(_.keys(o), "url")));
    */
    var o = _.clone(options);
    o.url = newUrl;


    o.depthLimit = options.depthLimit;
    o.currentRetries = 0;

    if (options.canCrawl) {
      o.canCrawl = options.canCrawl;
    }

    return o;

 }
265762
@Override
    public void merge(final Object from, final Object target, final NullHandlingPolicy nullPolicy) {
        if (from == null || target == null) {
            return;
        }

        final BeanWrapper fromWrapper = beanWrapper(from);
        final BeanWrapper targetWrapper = beanWrapper(target);

        final DomainTypeAdministrationConfiguration domainTypeAdministrationConfiguration = configuration.forManagedDomainType(target.getClass());
        final PersistentEntity<?, ?> entity = domainTypeAdministrationConfiguration.getPersistentEntity();

        entity.doWithProperties(new SimplePropertyHandler() {
            @Override
            public void doWithPersistentProperty(PersistentProperty<?> persistentProperty) {
                Object sourceValue = fromWrapper.getPropertyValue(persistentProperty.getName());
                Object targetValue = targetWrapper.getPropertyValue(persistentProperty.getName());

                if (entity.isIdProperty(persistentProperty)) {
                    return;
                }

                if (nullSafeEquals(sourceValue, targetValue)) {
                    return;
                }

                if (propertyIsHiddenInFormView(persistentProperty, domainTypeAdministrationConfiguration)) {
                    return;
                }

                if (nullPolicy == APPLY_NULLS || sourceValue != null) {
                    targetWrapper.setPropertyValue(persistentProperty.getName(), sourceValue);
                }
            }
        });

        entity.doWithAssociations(new SimpleAssociationHandler() {
            @Override
            @SuppressWarnings("unchecked")
            public void doWithAssociation(Association<? extends PersistentProperty<?>> association) {
                PersistentProperty<?> persistentProperty = association.getInverse();

                Object fromValue = fromWrapper.getPropertyValue(persistentProperty.getName());
                Object targetValue = targetWrapper.getPropertyValue(persistentProperty.getName());

                if (propertyIsHiddenInFormView(persistentProperty, domainTypeAdministrationConfiguration)) {
                    return;
                }

                if ((fromValue == null && nullPolicy == APPLY_NULLS)) {
                    targetWrapper.setPropertyValue(persistentProperty.getName(), fromValue);
                }

                if (persistentProperty.isCollectionLike()) {
                    Collection<Object> sourceCollection = (Collection) fromValue;
                    Collection<Object> targetCollection = (Collection) targetValue;

                    Collection<Object> candidatesForAddition = candidatesForAddition(sourceCollection, targetCollection, persistentProperty);
                    Collection<Object> candidatesForRemoval = candidatesForRemoval(sourceCollection, targetCollection, persistentProperty);

                    removeReferencedItems(targetCollection, candidatesForRemoval);

                    addReferencedItems(targetCollection, candidatesForAddition);

                    return;
                }

                if (!nullSafeEquals(fromValue, targetWrapper.getPropertyValue(persistentProperty.getName()))) {
                    targetWrapper.setPropertyValue(persistentProperty.getName(), fromValue);
                }
            }
        });
    }
1033272
@Override
    public R visitVersion(VersionTree node, P p) {
        return defaultAction(node, p);
    }
719915
public PolicyFactory and(PolicyFactory f) {
    ImmutableMap.Builder<String, ElementAndAttributePolicies> b
        = ImmutableMap.builder();
    // Merge this and f into a map of element names to attribute policies.
    for (Map.Entry<String, ElementAndAttributePolicies> e
        : policies.entrySet()) {
      String elName = e.getKey();
      ElementAndAttributePolicies p = e.getValue();
      ElementAndAttributePolicies q = f.policies.get(elName);
      if (q != null) {
        p = p.and(q);
      } else {
        // Mix in any globals that are not already taken into account in this.
        p = p.andGlobals(f.globalAttrPolicies);
      }
      b.put(elName, p);
    }
    // Handle keys that are in f but not in this.
    for (Map.Entry<String, ElementAndAttributePolicies> e
        : f.policies.entrySet()) {
      String elName = e.getKey();
      if (!policies.containsKey(elName)) {
        ElementAndAttributePolicies p = e.getValue();
        // Mix in any globals that are not already taken into account in this.
        p = p.andGlobals(globalAttrPolicies);
        b.put(elName, p);
      }
    }
    ImmutableSet<String> allTextContainers;
    if (this.textContainers.containsAll(f.textContainers)) {
      allTextContainers = this.textContainers;
    } else if (f.textContainers.containsAll(this.textContainers)) {
      allTextContainers = f.textContainers;
    } else {
      allTextContainers = ImmutableSet.<String>builder()
        .addAll(this.textContainers)
        .addAll(f.textContainers)
        .build();
    }
    ImmutableMap<String, AttributePolicy> allGlobalAttrPolicies;
    if (f.globalAttrPolicies.isEmpty()) {
      allGlobalAttrPolicies = this.globalAttrPolicies;
    } else if (this.globalAttrPolicies.isEmpty()) {
      allGlobalAttrPolicies = f.globalAttrPolicies;
    } else {
      ImmutableMap.Builder<String, AttributePolicy> ab = ImmutableMap.builder();
      for (Map.Entry<String, AttributePolicy> e
          : this.globalAttrPolicies.entrySet()) {
        String attrName = e.getKey();
        ab.put(
            attrName,
            AttributePolicy.Util.join(
                e.getValue(), f.globalAttrPolicies.get(attrName)));
      }
      for (Map.Entry<String, AttributePolicy> e
          : f.globalAttrPolicies.entrySet()) {
        String attrName = e.getKey();
        if (!this.globalAttrPolicies.containsKey(attrName)) {
          ab.put(attrName, e.getValue());
        }
      }
      allGlobalAttrPolicies = ab.build();
    }
    HtmlStreamEventProcessor compositionOfPreprocessors
        = HtmlStreamEventProcessor.Processors.compose(
            this.preprocessor, f.preprocessor);
    HtmlStreamEventProcessor compositionOfPostprocessors
        = HtmlStreamEventProcessor.Processors.compose(
            this.postprocessor, f.postprocessor);
    return new PolicyFactory(
        b.build(), allTextContainers, allGlobalAttrPolicies,
        compositionOfPreprocessors, compositionOfPostprocessors);
  }
583372
public MetaConfig withInstanceCheck(InstanceCheckPolicy policy) {
    Ensure.that(policy != null, "policy != null");

    return new MetaConfigBuilder(this)
      .setInstanceCheckPolicy(policy)
      .build();
  }
141413
public static void incrementVersion(Object target) {
        MetaClass metaClass = GroovySystem.getMetaClassRegistry().getMetaClass(target.getClass());
        if (metaClass.hasProperty(target, GormProperties.VERSION)!=null) {
            Object version = metaClass.getProperty(target, GormProperties.VERSION);
            if (version instanceof Long) {
                Long newVersion = (Long) version + 1;
                metaClass.setProperty(target, GormProperties.VERSION, newVersion);
            }
        }
    }
17276
public java.util.List<? extends com.google.appengine.v1.VersionOrBuilder> 
      getVersionsOrBuilderList() {
    return versions_;
  }
485169
public static Artifact withVersion(Version v)
    {
        Artifact artifact = new Artifact();
        artifact.version = v;
        return artifact;
    }
1105264
@XmlElementDecl(namespace = "urn:oasis:names:tc:xacml:2.0:policy:schema:os", name = "PolicySetCombinerParameters", scope = PolicySetType.class)
    public JAXBElement<PolicySetCombinerParametersType> createPolicySetTypePolicySetCombinerParameters(PolicySetCombinerParametersType value) {
        return new JAXBElement<PolicySetCombinerParametersType>(_PolicySetCombinerParameters_QNAME, PolicySetCombinerParametersType.class, PolicySetType.class, value);
    }
311165
public void createBaseLine(List<VersionDescription> versions, ExcludeIncludeList excludesIncludes, Path descDest, Path jdkRoot) throws IOException {
        ClassList classes = new ClassList();

        for (VersionDescription desc : versions) {
            ClassList currentVersionClasses = new ClassList();
            try (BufferedReader descIn = Files.newBufferedReader(Paths.get(desc.classes))) {
                String classFileData;

                while ((classFileData = descIn.readLine()) != null) {
                    ByteArrayOutputStream data = new ByteArrayOutputStream();
                    for (int i = 0; i < classFileData.length(); i += 2) {
                        data.write(Integer.parseInt(classFileData.substring(i, i + 2), 16));
                    }
                    try (InputStream in = new ByteArrayInputStream(data.toByteArray())) {
                        inspectClassFile(in, currentVersionClasses, excludesIncludes, desc.version);
                    } catch (IOException | ConstantPoolException ex) {
                        throw new IllegalStateException(ex);
                    }
                }
            }

            Set<String> includedClasses = new HashSet<>();
            boolean modified;

            do {
                modified = false;

                for (ClassDescription clazz : currentVersionClasses) {
                    ClassHeaderDescription header = clazz.header.get(0);

                    if (includeEffectiveAccess(currentVersionClasses, clazz)) {
                        modified |= include(includedClasses, currentVersionClasses, clazz.name);
                    }

                    if (includedClasses.contains(clazz.name)) {
                        modified |= include(includedClasses, currentVersionClasses, header.extendsAttr);
                        for (String i : header.implementsAttr) {
                            modified |= include(includedClasses, currentVersionClasses, i);
                        }

                        modified |= includeOutputType(Collections.singleton(header),
                                                      h -> "",
                                                      includedClasses,
                                                      currentVersionClasses);
                        modified |= includeOutputType(clazz.fields,
                                                      f -> f.descriptor,
                                                      includedClasses,
                                                      currentVersionClasses);
                        modified |= includeOutputType(clazz.methods,
                                                      m -> m.descriptor,
                                                      includedClasses,
                                                      currentVersionClasses);
                    }
                }
            } while (modified);

            for (ClassDescription clazz : currentVersionClasses) {
                if (!includedClasses.contains(clazz.name)) {
                    continue;
                }

                ClassHeaderDescription header = clazz.header.get(0);

                if (header.innerClasses != null) {
                    Iterator<InnerClassInfo> innerClassIt = header.innerClasses.iterator();

                    while(innerClassIt.hasNext()) {
                        InnerClassInfo ici = innerClassIt.next();
                        if (!includedClasses.contains(ici.innerClass))
                            innerClassIt.remove();
                    }
                }

                ClassDescription existing = classes.find(clazz.name, true);

                if (existing != null) {
                    addClassHeader(existing, header, desc.version);
                    for (MethodDescription currentMethod : clazz.methods) {
                        addMethod(existing, currentMethod, desc.version);
                    }
                    for (FieldDescription currentField : clazz.fields) {
                        addField(existing, currentField, desc.version);
                    }
                } else {
                    classes.add(clazz);
                }
            }
        }

        classes.sort();

        Map<String, String> package2Modules = buildPackage2Modules(jdkRoot);
        Map<String, List<ClassDescription>> module2Classes = new HashMap<>();

        for (ClassDescription clazz : classes) {
            String pack;
            int lastSlash = clazz.name.lastIndexOf('/');
            if (lastSlash != (-1)) {
                pack = clazz.name.substring(0, lastSlash).replace('/', '.');
            } else {
                pack = "";
            }
            String module = package2Modules.get(pack);

            if (module == null) {
                module = "java.base";

                OUTER: while (!pack.isEmpty()) {
                    for (Entry<String, String> p2M : package2Modules.entrySet()) {
                        if (p2M.getKey().startsWith(pack)) {
                            module = p2M.getValue();
                            break OUTER;
                        }
                    }
                    int dot = pack.lastIndexOf('.');
                    if (dot == (-1))
                        break;
                    pack = pack.substring(0, dot);
                }
            }
            module2Classes.computeIfAbsent(module, m -> new ArrayList<>())
                    .add(clazz);
        }

        Path symbolsFile = descDest.resolve("symbols");

        Files.createDirectories(symbolsFile.getParent());

        try (Writer symbolsOut = Files.newBufferedWriter(symbolsFile)) {
            Map<VersionDescription, List<Path>> outputFiles = new LinkedHashMap<>();

            for (Entry<String, List<ClassDescription>> e : module2Classes.entrySet()) {
                for (VersionDescription desc : versions) {
                    Path f = descDest.resolve(e.getKey() + "-" + desc.version + ".sym.txt");
                    try (Writer out = Files.newBufferedWriter(f)) {
                        for (ClassDescription clazz : e.getValue()) {
                            clazz.write(out, desc.primaryBaseline, desc.version);
                        }
                    }
                    outputFiles.computeIfAbsent(desc, d -> new ArrayList<>())
                               .add(f);
                }
            }
            symbolsOut.append("generate platforms ")
                      .append(versions.stream()
                                      .map(v -> v.version)
                                      .collect(Collectors.joining(":")))
                      .append("\n");
            for (Entry<VersionDescription, List<Path>> versionFileEntry : outputFiles.entrySet()) {
                symbolsOut.append("platform version ")
                          .append(versionFileEntry.getKey().version);
                if (versionFileEntry.getKey().primaryBaseline != null) {
                    symbolsOut.append(" base ")
                              .append(versionFileEntry.getKey().primaryBaseline);
                }
                symbolsOut.append(" files ")
                          .append(versionFileEntry.getValue()
                                                  .stream()
                                                  .map(p -> p.getFileName().toString())
                                                  .sorted()
                                                  .collect(Collectors.joining(":")))
                          .append("\n");
            }
        }
    }
119301
private void createVersion(Node fileNode, InputStream inputStream, String autoVersion, List<String> mixins) throws RepositoryException
   {
      if (!fileNode.isNodeType(VersionHistoryUtils.MIX_VERSIONABLE))
      {
         if (fileNode.canAddMixin(VersionHistoryUtils.MIX_VERSIONABLE))
         {
            fileNode.addMixin(VersionHistoryUtils.MIX_VERSIONABLE);
            fileNode.getSession().save();
         }
         if (!(CHECKIN_CHECKOUT.equals(autoVersion)))
         {
            fileNode.checkin();
            fileNode.getSession().save();
         }
      }
      if (CHECKIN_CHECKOUT.equals(autoVersion))
      {
         fileNode.checkin();
         fileNode.checkout();
         fileNode.getSession().save();
         updateContent(fileNode, inputStream, mixins);
         fileNode.getSession().save();
      }
      else
      {
         createVersion(fileNode, inputStream, mixins);
      }
   }
1125790
@Override
    public RealJsonEngine newAnotherEngine(OptionalThing<JsonMappingOption> mappingOption) {
        assertArgumentNotNull("mappingOption", mappingOption);
        final JsonEngineResource resource = new JsonEngineResource();
        mappingOption.ifPresent(op -> {
            resource.acceptMappingOption(op);
        });
        return newRuledEngine(resource);
    }
661060
public CacheConfigurationBuilder<K, V> withExpiry(ExpiryPolicy<? super K, ? super V> expiry) {
    if (expiry == null) {
      throw new NullPointerException("Null expiry");
    }
    CacheConfigurationBuilder<K, V> otherBuilder = new CacheConfigurationBuilder<>(this);
    otherBuilder.expiry = expiry;
    return otherBuilder;
  }
677132
public static final PlanVersionAlreadyExistsException planVersionAlreadyExistsException(String planName, String version) {
        return new PlanVersionAlreadyExistsException(Messages.i18n.format("PlanVersionAlreadyExists", planName, version)); //$NON-NLS-1$
    }