@Override public void visitTypeVariable(String name) { List<JavaSymbol> lookup = Lists.newArrayList(); JavaSymbol currentSymbol = classSymbol; if (methodSymbol != null) { currentSymbol = methodSymbol; } while ((currentSymbol.isKind(JavaSymbol.TYP) || currentSymbol.isKind(JavaSymbol.MTH)) && lookup.isEmpty()) { if (currentSymbol.isKind(JavaSymbol.MTH)) { lookup = ((JavaSymbol.MethodJavaSymbol) currentSymbol).typeParameters().lookup(name); } else if (currentSymbol.isKind(JavaSymbol.TYP)) { lookup = ((JavaSymbol.TypeJavaSymbol) currentSymbol).typeParameters().lookup(name); } currentSymbol = currentSymbol.owner(); } Preconditions.checkState( !lookup.isEmpty(), "Could not resolve type parameter: " + name + " in class " + classSymbol.getName()); Preconditions.checkState( lookup.size() == 1, "More than one type parameter with the same name"); typeRead = lookup.get(0).type; visitEnd(); }
/** * Create a new {@link DataStream} in the given execution environment with partitioning set to * forward by default. * * @param environment The StreamExecutionEnvironment */ public DataStream( StreamExecutionEnvironment environment, StreamTransformation<T> transformation) { this.environment = Preconditions.checkNotNull(environment, "Execution Environment must not be null."); this.transformation = Preconditions.checkNotNull(transformation, "Stream Transformation must not be null."); }
public Boolean set(int i, Boolean boolean1) { Preconditions.checkElementIndex(i, size()); boolean flag = array[start + i]; array[start + i] = ((Boolean)Preconditions.checkNotNull(boolean1)).booleanValue(); return Boolean.valueOf(flag); }
@Nonnull @Override public ComponentItem createComponent( @Nonnull String label, @Nonnull ComponentDescriptor descriptor) throws ComponentCreationException { Preconditions.checkNotNull(label, "label is null!"); Preconditions.checkNotNull(descriptor, "descriptor is null!"); ComponentItemConfig config = getConfig().addNewComponent(); config.setType(descriptor.getType()); config.setLabel(label); ComponentItemImpl component = ComponentItemImpl.newInstance(this, config); component.setAttribute(ComponentItem.TYPE, descriptor.getLabel()); if (descriptor.getHelpUrl() != null) component.getContext().setHelpUrl(descriptor.getHelpUrl()); try { component.setBehavior(componentRegistry.createBehavior(descriptor, component.getContext())); component.addEventListener(BaseEvent.class, componentListener); if (counterSupport instanceof AggregatedCounterSupport) ((AggregatedCounterSupport) counterSupport).addChild(component); componentList.addItem(component); } catch (ComponentCreationException e) { component.delete(); throw e; } return component; }
/** * @param androidSdkDir where the user's Android SDK is installed. * @param buildDependencies How to include dependencies when building rules. */ public Build( DependencyGraph dependencyGraph, Optional<File> androidSdkDir, Optional<File> ndkRoot, ProjectFilesystem projectFilesystem, ArtifactCache artifactCache, ListeningExecutorService listeningExecutorService, JavaPackageFinder javaPackageFinder, Console console, long defaultTestTimeoutMillis, boolean isCodeCoverageEnabled, boolean isDebugEnabled, BuildDependencies buildDependencies) { this.dependencyGraph = Preconditions.checkNotNull(dependencyGraph); Optional<AndroidPlatformTarget> androidPlatformTarget = findAndroidPlatformTarget(dependencyGraph, androidSdkDir, console.getStdErr()); this.executionContext = ExecutionContext.builder() .setProjectFilesystem(projectFilesystem) .setConsole(console) .setAndroidPlatformTarget(androidPlatformTarget) .setNdkRoot(ndkRoot) .setDefaultTestTimeoutMillis(defaultTestTimeoutMillis) .setCodeCoverageEnabled(isCodeCoverageEnabled) .setDebugEnabled(isDebugEnabled) .build(); this.artifactCache = Preconditions.checkNotNull(artifactCache); this.stepRunner = new DefaultStepRunner(executionContext, listeningExecutorService); this.javaPackageFinder = Preconditions.checkNotNull(javaPackageFinder); this.buildDependencies = Preconditions.checkNotNull(buildDependencies); }
private static boolean canMerge( IjFolder parent, IjFolder child, PackagePathCache packagePathCache) { Preconditions.checkArgument(child.getPath().startsWith(parent.getPath())); if (!child.canMergeWith(parent)) { return false; } if (parent.getWantsPackagePrefix() != child.getWantsPackagePrefix()) { return false; } if (parent.getWantsPackagePrefix()) { Optional<Path> parentPackage = packagePathCache.lookup(parent); if (!parentPackage.isPresent()) { return false; } Path childPackage = packagePathCache.lookup(child).get(); int pathDifference = child.getPath().getNameCount() - parent.getPath().getNameCount(); Preconditions.checkState(pathDifference == 1); if (childPackage.getNameCount() == 0) { return false; } if (!MorePaths.getParentOrEmpty(childPackage).equals(parentPackage.get())) { return false; } } return true; }
private double getMedian(List<Double> list) { Preconditions.checkNotNull(list); Preconditions.checkArgument(list.size() > 0); List<Double> copy = Lists.newArrayList(list); Collections.sort(copy); return copy.get(copy.size() / 2); }
/** * Move and rename temporary file to final version. Update vocabulary loaded into local lookup. * * @param tmpFile downloaded vocabulary file (in temporary location with temporary filename) * @param vocabulary vocabulary from JSON (excluding concepts) * @throws IOException if moving file fails */ private void finishInstall(File tmpFile, Vocabulary vocabulary) throws IOException { Preconditions.checkNotNull(tmpFile); Preconditions.checkNotNull(vocabulary); Preconditions.checkNotNull(vocabulary.getUriString()); try { File installedFile = getVocabFile(vocabulary.getUriResolvable()); // never replace an existing vocabulary file. It can only be uninstalled (removed), or updated if (!installedFile.exists()) { FileUtils.moveFile(tmpFile, installedFile); } // build Vocabulary from file, so it includes concepts Vocabulary fromFile = loadFromFile(installedFile); // don't forget to set vocabulary URL (only available from JSON) fromFile.setUriResolvable(vocabulary.getUriResolvable()); // keep vocabulary in local lookup: allowed one installed vocabulary per identifier vocabulariesById.put(vocabulary.getUriString(), fromFile); } catch (IOException e) { log.error( "Installing vocabulary failed, while trying to move and rename vocabulary file: " + e.getMessage(), e); throw e; } }
/** * Load the Vocabulary object from the XML definition file. * * @param localFile vocabulary XML definition file * @return vocabulary loaded from file * @throws InvalidConfigException if vocabulary could not be loaded successfully */ private Vocabulary loadFromFile(File localFile) throws InvalidConfigException { Preconditions.checkNotNull(localFile); Preconditions.checkState(localFile.exists()); Closer closer = Closer.create(); try { InputStream fileIn = closer.register(new FileInputStream(localFile)); Vocabulary v = vocabFactory.build(fileIn); v.setModified(new Date(localFile.lastModified())); // filesystem date log.info("Successfully loaded vocabulary: " + v.getUriString()); return v; } catch (IOException e) { log.error("Can't access local vocabulary file (" + localFile.getAbsolutePath() + ")", e); throw new InvalidConfigException( InvalidConfigException.TYPE.INVALID_VOCABULARY, "Can't access local vocabulary file"); } catch (SAXException e) { log.error("Can't parse local extension file (" + localFile.getAbsolutePath() + ")", e); throw new InvalidConfigException( InvalidConfigException.TYPE.INVALID_VOCABULARY, "Can't parse local vocabulary file"); } catch (ParserConfigurationException e) { log.error("Can't create sax parser", e); throw new InvalidConfigException( InvalidConfigException.TYPE.INVALID_VOCABULARY, "Can't create sax parser"); } finally { try { closer.close(); } catch (IOException e) { log.debug("Failed to close input stream on vocabulary file", e); } } }
public InterestRateSwapSecurity( final ExternalIdBundle id, final String name, final LocalDate effectiveDate, final LocalDate unAdjustedMaturityDate, final Collection<InterestRateSwapLeg> legs) { super(SECURITY_TYPE); setExternalIdBundle(id); setName(name); setEffectiveDate(effectiveDate); setUnadjustedMaturityDate(unAdjustedMaturityDate); setLegs(Lists.newArrayList(legs)); Preconditions.checkArgument( getPayLeg().getEffectiveDate() == null, "Pay leg effective date conflict: If effective date is set on the swap, then it must not be set on the legs"); Preconditions.checkArgument( getReceiveLeg().getEffectiveDate() == null, "Rec leg effective date conflict: If effective date is set on the swap, then it must not be set on the legs"); Preconditions.checkArgument( getPayLeg().getUnadjustedMaturityDate() == null, "Pay leg termination date conflict: If termination date is set on the swap, then it must not be set on the legs"); Preconditions.checkArgument( getReceiveLeg().getUnadjustedMaturityDate() == null, "Rec leg termination date conflict: If termination date is set on the swap, then it must not be set on the legs"); }
private static <E extends Object> ImmutableSortedSet<E> ofInternal( Comparator<? super E> var0, E... var1) { Object var2 = Preconditions.checkNotNull(var1); Object var7; switch (var1.length) { case 0: var7 = emptySet(var0); break; default: Object[] var3 = new Object[var1.length]; int var4 = 0; while (true) { int var5 = var1.length; if (var4 >= var5) { sort(var3, var0); Object[] var8 = removeDupes(var3, var0); var7 = new RegularImmutableSortedSet(var8, var0); break; } Object var6 = Preconditions.checkNotNull(var1[var4]); var3[var4] = var6; ++var4; } } return (ImmutableSortedSet) var7; }
public AbstractBoostingFactorFamily( VariableNumMap conditionalVars, VariableNumMap unconditionalVars) { this.conditionalVars = Preconditions.checkNotNull(conditionalVars); this.unconditionalVars = Preconditions.checkNotNull(unconditionalVars); Preconditions.checkArgument(!conditionalVars.containsAny(unconditionalVars)); }
/** * Returns ids for dependent nodes of a given node, sorted by attribute. Note that some * dependencies do not have a corresponding attribute here, and we use the null attribute to * represent those edges. Visibility attributes are only visited if {@code visitVisibility} is * {@code true}. * * <p>If {@code aspect} is null, returns the dependent nodes of the configured target node * representing the given target and configuration, otherwise that of the aspect node accompanying * the aforementioned configured target node for the specified aspect. * * <p>The values are not simply labels because this also implements the first step of applying * configuration transitions, namely, split transitions. This needs to be done before the labels * are resolved because late bound attributes depend on the configuration. A good example for this * is @{code :cc_toolchain}. * * <p>The long-term goal is that most configuration transitions be applied here. However, in order * to do that, we first have to eliminate transitions that depend on the rule class of the * dependency. */ public final ListMultimap<Attribute, Dependency> dependentNodeMap( TargetAndConfiguration node, BuildConfiguration hostConfig, AspectDefinition aspect, AspectParameters aspectParameters, Set<ConfigMatchingProvider> configConditions) throws EvalException, InterruptedException { Target target = node.getTarget(); BuildConfiguration config = node.getConfiguration(); ListMultimap<Attribute, Dependency> outgoingEdges = ArrayListMultimap.create(); if (target instanceof OutputFile) { Preconditions.checkNotNull(config); visitTargetVisibility(node, outgoingEdges.get(null)); Rule rule = ((OutputFile) target).getGeneratingRule(); outgoingEdges.put(null, new Dependency(rule.getLabel(), config)); } else if (target instanceof InputFile) { visitTargetVisibility(node, outgoingEdges.get(null)); } else if (target instanceof EnvironmentGroup) { visitTargetVisibility(node, outgoingEdges.get(null)); } else if (target instanceof Rule) { Preconditions.checkNotNull(config); visitTargetVisibility(node, outgoingEdges.get(null)); Rule rule = (Rule) target; ListMultimap<Attribute, LabelAndConfiguration> labelMap = resolveAttributes(rule, aspect, config, hostConfig, configConditions); visitRule(rule, aspect, aspectParameters, labelMap, outgoingEdges); } else if (target instanceof PackageGroup) { visitPackageGroup(node, (PackageGroup) target, outgoingEdges.get(null)); } else { throw new IllegalStateException(target.getLabel().toString()); } return outgoingEdges; }
private void handleVertexStateUpdate(VertexStateUpdate stateUpdate) { Preconditions.checkArgument( stateUpdate.getVertexState() == VertexState.CONFIGURED, "Received incorrect state notification : " + stateUpdate.getVertexState() + " for vertex: " + stateUpdate.getVertexName() + " in vertex: " + getContext().getVertexName()); Preconditions.checkArgument( srcVertexInfo.containsKey(stateUpdate.getVertexName()), "Received incorrect vertex notification : " + stateUpdate.getVertexState() + " for vertex: " + stateUpdate.getVertexName() + " in vertex: " + getContext().getVertexName()); SourceVertexInfo vInfo = srcVertexInfo.get(stateUpdate.getVertexName()); Preconditions.checkState(vInfo.vertexIsConfigured == false); vInfo.vertexIsConfigured = true; LOG.info( "Received configured notification : " + stateUpdate.getVertexState() + " for vertex: " + stateUpdate.getVertexName() + " in vertex: " + getContext().getVertexName()); schedulePendingTasks(); }
/** * Returns a new AdGroupCriterion configured for an ADD operation. * * @param node the node whose criterion should be added * @param adGroupId the ad group ID of the criterion * @param biddingConfig the bidding strategy configuration of the criterion */ static AdGroupCriterion createCriterionForAdd( ProductPartitionNode node, long adGroupId, BiddingStrategyConfiguration biddingConfig) { Preconditions.checkNotNull(node, "Null node"); Preconditions.checkNotNull(biddingConfig, "Null bidding configuration"); AdGroupCriterion adGroupCriterion; if (node.isExcludedUnit()) { adGroupCriterion = new NegativeAdGroupCriterion(); } else { adGroupCriterion = new BiddableAdGroupCriterion(); if (node.isUnit() && node.getBid() != null) { Money bidMoney = new Money(); bidMoney.setMicroAmount(node.getBid()); CpcBid cpcBid = new CpcBid(); cpcBid.setBid(bidMoney); cpcBid.setCpcBidSource(BidSource.CRITERION); biddingConfig.setBids(new Bids[] {cpcBid}); ((BiddableAdGroupCriterion) adGroupCriterion) .setBiddingStrategyConfiguration(biddingConfig); } } adGroupCriterion.setAdGroupId(adGroupId); ProductPartition partition = new ProductPartition(); partition.setId(node.getProductPartitionId()); if (node.getParent() != null) { partition.setParentCriterionId(node.getParent().getProductPartitionId()); } partition.setCaseValue(node.getDimension()); partition.setPartitionType( node.isUnit() ? ProductPartitionType.UNIT : ProductPartitionType.SUBDIVISION); adGroupCriterion.setCriterion(partition); return adGroupCriterion; }
/** * Add a new console preference consumer, and, if the supplied key maps to a non-null console * preference value, immediately fire a change event * * @param triggerPrefKey * @param consumer */ public void setConsumer(String triggerPrefKey, Function<PreferenceChangeEvent, ?> consumer) { Preconditions.checkNotNull(triggerPrefKey); // Preferences javadoc mandates that no path contain successive slashes Preconditions.checkArgument(!triggerPrefKey.startsWith("/")); String k = PREF_TINKERPOP_PREFIX + triggerPrefKey; Function<?, ?> oldConsumer = prefChangeConsumers.putIfAbsent(k, consumer); if (null == oldConsumer) { log.debug("Installing new preference consumer for key {}", k); } else { log.debug( "Replacing existing preference consumer for key {} (old consumer: {})", k, oldConsumer); } String currentValue = Preferences.get(k); if (null != currentValue) { log.debug("Resetting stored value to trigger consumer: {}={}", k, currentValue); Preferences.put(k, currentValue); } else { log.debug("Read null for {}", k); } }
@Override protected Object doExecute() throws Exception { final FacebookManager facebookMgr = getBean(FacebookManager.class); final EntityLookup<FacebookAccessible, String> lookup = getBean(EntityLookup.class, FacebookRelated.class); Preconditions.checkArgument( id != null || accessToken != null, "Either id or access token must be specified."); final String realToken; if (id != null) { final FacebookAccessible facebookAccessible = Preconditions.checkNotNull(lookup.findOne(id), "Cannot find '%s' using %s", id, lookup); realToken = facebookAccessible.getFacebookAccessToken(); } else { realToken = accessToken; } final DefaultFacebookClient facebook = new DefaultFacebookClient(realToken); final String connection = objectId + "/likes"; final String abbrToken = StringUtils.abbreviateMiddle(realToken, "…", 15); log.debug("Deleting like to Facebook {} using {}", connection, abbrToken); System.out.print( ansi().render("Unliking @|bold %s|@ using @|yellow %s|@", connection, abbrToken)); final boolean deletedLike = facebook.deleteObject(connection); System.out.println(ansi().render(" @|bold %s|@", deletedLike)); log.info("Deleted like {} to Facebook {}", deletedLike, connection, deletedLike); return deletedLike; }
/** * Constructs a GlobDescriptor. * * @param packageId the name of the owner package (must be an existing package) * @param subdir the subdirectory being looked at (must exist and must be a directory. It's * assumed that there are no other packages between {@code packageName} and {@code subdir}. * @param pattern a valid glob pattern * @param excludeDirs true if directories should be excluded from results */ GlobDescriptor( PackageIdentifier packageId, PathFragment subdir, String pattern, boolean excludeDirs) { this.packageId = Preconditions.checkNotNull(packageId); this.subdir = Preconditions.checkNotNull(subdir); this.pattern = Preconditions.checkNotNull(StringCanonicalizer.intern(pattern)); this.excludeDirs = excludeDirs; }
private ImmutableList<Path> conditionallyCopy(ImmutableList<Path> roots) throws IOException { final Builder<Path> builder = ImmutableList.builder(); for (Path root : roots) { Preconditions.checkArgument( root.startsWith(workingDirectory), root + " must start with root " + workingDirectory + " from " + roots); Preconditions.checkArgument( !root.equals(workingDirectory), "Cannot deduplicate root directory: " + root + " from " + roots); if (!seen.containsKey(root)) { seen.put(root, null); final Path newRoot = out.resolve(workingDirectory.relativize(root)); Files.walkFileTree( root, ImmutableSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new ConditionalCopyVisitor(newRoot, root, seen, hashFunction)); builder.add(newRoot); } else { // Duplicated directories are ok -- multiple files from different libraries // can reside in the same directory, but duplicate files should not be seen mulitple times. } } return builder.build(); }
/** * Unregisters a listener actor. * * <p>The registry is NOT thread-safe, and so this can only be called from within the actor * mailbox context. * * @return true on success. */ @Override public final boolean unregister(final Object topic, final TActor listener) { Preconditions.checkNotNull(topic, "topic cannot be null"); Preconditions.checkNotNull(listener, "listener cannot be null"); if (listeners != null) { final List<Object> list = listeners.get(topic); if (list != null) { final int size = list.size(); for (int i = 0; i < size; i++) { final Object obj = list.get(i); if (obj == listener) { if (list.size() == 1) { listeners.remove(topic); } else { list.remove(i); } return true; } else if (obj instanceof WeakReferenceWithTopic) { final WeakReferenceWithTopic ref = (WeakReferenceWithTopic) obj; if (ref.get() == listener) { if (list.size() == 1) { listeners.remove(topic); } else { list.remove(i); } return true; } } } } } return false; }
public static <T> BatchingVisitableView<T> skip( final BatchingVisitable<T> visitable, final long toSkip) { Preconditions.checkNotNull(visitable); Preconditions.checkArgument(toSkip >= 0); if (toSkip == 0) { return BatchingVisitableView.of(visitable); } return BatchingVisitableView.of( new AbstractBatchingVisitable<T>() { @Override protected <K extends Exception> void batchAcceptSizeHint( int batchSizeHint, final ConsistentVisitor<T, K> v) throws K { visitable.batchAccept( batchSizeHint, new AbortingVisitor<List<T>, K>() { long visited = 0; @Override public boolean visit(List<T> batch) throws K { for (T item : batch) { if (visited < toSkip) { visited++; continue; } if (!v.visitOne(item)) { return false; } } return true; } }); } }); }
/** * Registers a listener actor. * * <p>The registry is NOT thread-safe, and so this can only be called from within the actor * mailbox context. * * <p>The topic might be anything, but should be immutable. Remember that the registry is also * used by base classes and derived classes. The topic cannot be null. The listener cannot be * null. The listener must not already have been registered to this topic. */ @Override public final void register(final Object topic, final TActor listener, final boolean weakRef) { Preconditions.checkNotNull(topic, "topic cannot be null"); Preconditions.checkNotNull(listener, "listener cannot be null"); if (listeners == null) { listeners = new HashMap<Object, List<Object>>(); } List<Object> list = listeners.get(topic); if (list == null) { list = new ArrayList<Object>(); listeners.put(topic, list); } for (final Object obj : list) { if (obj == listener) { throw new IllegalStateException( "listener " + listener + " already registered for topic " + topic); } else if (obj instanceof WeakReferenceWithTopic) { final WeakReferenceWithTopic ref = (WeakReferenceWithTopic) obj; if (ref.get() == listener) { throw new IllegalStateException( "listener " + listener + " already registered for topic " + topic); } } } if (weakRef) { if (refQueue == null) { refQueue = new ReferenceQueue<Object>(); } list.add(new WeakReferenceWithTopic(topic, listener, refQueue)); } else { list.add(listener); } }
/** * @param client client instance * @param mode creation mode * @param useProtection if true, call {@link CreateBuilder#withProtection()} * @param basePath the base path for the node * @param initData data for the node */ public PersistentNode( CuratorFramework client, final CreateMode mode, boolean useProtection, final String basePath, byte[] initData) { this.useProtection = useProtection; this.client = Preconditions.checkNotNull(client, "client cannot be null"); this.basePath = PathUtils.validatePath(basePath); this.mode = Preconditions.checkNotNull(mode, "mode cannot be null"); final byte[] data = Preconditions.checkNotNull(initData, "data cannot be null"); backgroundCallback = new BackgroundCallback() { @Override public void processResult(CuratorFramework client, CuratorEvent event) throws Exception { if (state.get() == State.STARTED) { processBackgroundCallback(event); } else { processBackgroundCallbackClosedState(event); } } }; createMethod = useProtection ? client.create().creatingParentContainersIfNeeded().withProtection() : client.create().creatingParentContainersIfNeeded(); this.data.set(Arrays.copyOf(data, data.length)); }
public Index(Column column, Order order) { Preconditions.checkNotNull(column); Preconditions.checkNotNull(order); this.column = column; this.order = order; }
private void handleFunction(Node node) { // A block transfer control to its first child if it is not empty. Preconditions.checkState(node.getChildCount() >= 3); createEdge(node, Branch.UNCOND, computeFallThrough(node.getFirstChild().getNext().getNext())); Preconditions.checkState(exceptionHandler.peek() == node); exceptionHandler.pop(); }
public void addListener(Listener listener) { Preconditions.checkNotNull(listener); Preconditions.checkNotNull(mListeners); if (!mListeners.contains(listener)) { mListeners.add(listener); } }
public void setPhase(@Nonnull EventPriority value) { Preconditions.checkArgument(value != null, "setPhase argument must not be null"); int prev = phase == null ? -1 : phase.ordinal(); Preconditions.checkArgument( prev < value.ordinal(), "Attempted to set event phase to %s when already %s", value, phase); phase = value; }
/** * Returns a new AdGroupCriterion configured for a SET operation that will set the criterion's * bid. * * @param node the node whose criterion should be updated * @param adGroupId the ad group ID of the criterion * @param biddingConfig the bidding strategy configuration of the criterion */ static AdGroupCriterion createCriterionForSetBid( ProductPartitionNode node, long adGroupId, BiddingStrategyConfiguration biddingConfig) { Preconditions.checkNotNull(node, "Null node"); Preconditions.checkNotNull(biddingConfig, "Null bidding configuration"); Preconditions.checkArgument(node.isBiddableUnit(), "Node is not a biddable unit"); BiddableAdGroupCriterion biddableCriterion = new BiddableAdGroupCriterion(); biddableCriterion.setAdGroupId(adGroupId); ProductPartition partition = new ProductPartition(); partition.setId(node.getProductPartitionId()); if (node.getParent() != null) { partition.setParentCriterionId(node.getParent().getProductPartitionId()); } partition.setCaseValue(node.getDimension()); partition.setPartitionType(ProductPartitionType.UNIT); biddableCriterion.setCriterion(partition); if (node.getBid() != null) { Money bidMoney = new Money(); bidMoney.setMicroAmount(node.getBid()); CpcBid cpcBid = new CpcBid(); cpcBid.setBid(bidMoney); biddingConfig.setBids(new Bids[] {cpcBid}); } else { biddingConfig.setBids(new Bids[0]); } biddableCriterion.setBiddingStrategyConfiguration(biddingConfig); return biddableCriterion; }
@Override public void addValue(final int index, final FeatureValue fvalue) { Preconditions.checkArgument(fvalue != null, "fvalue is null"); Preconditions.checkArgument( index <= values.size() && index >= 0, "index is not in range of: 0 and " + values.size()); values.add(index, fvalue); }
@Nonnull public static TestMatrixArtifact convertToConsumableArtifact( @Nonnull final TestMatrixVersion testMatrix) { final Audit audit = new Audit(); final Date published = Preconditions.checkNotNull(testMatrix.getPublished(), "Missing publication date"); audit.setUpdated(published.getTime()); audit.setVersion(testMatrix.getVersion()); audit.setUpdatedBy(testMatrix.getAuthor()); final TestMatrixArtifact artifact = new TestMatrixArtifact(); artifact.setAudit(audit); final TestMatrixDefinition testMatrixDefinition = Preconditions.checkNotNull( testMatrix.getTestMatrixDefinition(), "Missing test matrix definition"); final Map<String, TestDefinition> testDefinitions = testMatrixDefinition.getTests(); final Map<String, ConsumableTestDefinition> consumableTestDefinitions = Maps.newLinkedHashMap(); for (final Entry<String, TestDefinition> entry : testDefinitions.entrySet()) { final TestDefinition td = entry.getValue(); final ConsumableTestDefinition ctd = convertToConsumableTestDefinition(td); consumableTestDefinitions.put(entry.getKey(), ctd); } artifact.setTests(consumableTestDefinitions); return artifact; }