/** * Marks the {@link State} as ready to receive transitions. Returns true if no transitions have * been observed yet. */ void markReady() { monitor.enter(); try { if (!transitioned) { // nothing has transitioned since construction, good. ready = true; } else { // This should be an extremely rare race condition. List<Service> servicesInBadStates = Lists.newArrayList(); for (Service service : servicesByState().values()) { if (service.state() != NEW) { servicesInBadStates.add(service); } } throw new IllegalArgumentException( "Services started transitioning asynchronously before " + "the ServiceManager was constructed: " + servicesInBadStates); } } finally { monitor.leave(); } }
/** * Marks the {@link State} as ready to receive transitions. Returns true if no transitions have * been observed yet. */ void markReady() { monitor.enter(); try { if (!transitioned) { // nothing has transitioned since construction, good. ready = true; } else { // This should be an extremely rare race condition. List<Service> servicesInBadStates = Lists.newArrayList(); for (Service service : servicesByState().values()) { if (service.state() != NEW) { servicesInBadStates.add(service); } } throw new IllegalArgumentException( "Services started transitioning asynchronously before " + "the ServiceManager was constructed: " + servicesInBadStates); } } finally { monitor.leave(); } }
/** * Marks the {@link State} as ready to receive transitions. Returns true if no transitions have * been observed yet. */ void markReady() { monitor.enter(); try { if (!transitioned) { // nothing has transitioned since construction, good. ready = true; } else { // This should be an extremely rare race condition. List<Service> servicesInBadStates = Lists.newArrayList(); for (Service service : servicesByState().values()) { if (service.state() != NEW) { servicesInBadStates.add(service); } } throw new IllegalArgumentException( "Services started transitioning asynchronously before " + "the ServiceManager was constructed: " + servicesInBadStates); } } finally { monitor.leave(); } }
Set<Key<V>> keysFromProviderMapEntrys = Sets.newHashSet(keyToValueKey.values()); Set<Key<V>> keysFromBindings = valueKeyToBinding.keySet();
private boolean methodCallsMeetConditions(Symbol sym, VisitorState state) { ImmutableMultimap<String, MethodInvocationTree> methodCallMap = methodCallsForSymbol(sym, getTopLevelClassTree(state)); if (methodCallMap.isEmpty()) { // no method invocations for this method, safe to refactor return true; } for (MethodInvocationTree methodInvocationTree : methodCallMap.values()) { if (methodInvocationTree.getArguments().stream() .filter(a -> Kind.LAMBDA_EXPRESSION.equals(a.getKind())) .filter(a -> hasFunctionAsArg(a, state)) .noneMatch( a -> isFunctionArgSubtypeOf(a, 0, state.getTypeFromString(JAVA_LANG_NUMBER), state) || isFunctionArgSubtypeOf( a, 1, state.getTypeFromString(JAVA_LANG_NUMBER), state))) { return false; } } return true; }
@CheckReturnValue public BundleModule sanitize(BundleModule module) { // The maps index native files by their containing ABI directory (example key is "lib/x86"). ImmutableMultimap<ZipPath, ModuleEntry> libFilesByAbiDir = indexLibFilesByAbiDir(module); ImmutableMultimap<ZipPath, ModuleEntry> libFilesByAbiDirToKeep = discardAbiDirsWithTooFewFiles(libFilesByAbiDir); if (libFilesByAbiDirToKeep.size() == libFilesByAbiDir.size()) { // ABI directories are correct, nothing to do. return module; } logger.warning( String.format( "Native directories of module '%s' don't contain the same number of files." + " The following files were therefore discarded: %s", module.getName(), Sets.difference( ImmutableSet.copyOf(libFilesByAbiDir.values()), ImmutableSet.copyOf(libFilesByAbiDirToKeep.values())) .stream() .map(ModuleEntry::getPath) .map(ZipPath::toString) .sorted() .collect(toImmutableList()))); return sanitizedModule(module, libFilesByAbiDirToKeep); }
@Test @SuppressWarnings("deprecation") public void modifiableImmutableCollections() { ModifiableMutableImmutableCollection m = ModifiableMutableImmutableCollection.create(); m.addA("a"); m.addA("b", "c"); m.addB("d", "e"); m.putC("x", 1); m.putC("y", 2); check(m.a()).isA(ImmutableCollection.class); check(m.b()).isA(ImmutableCollection.class); check(m.c()).isA(ImmutableMultimap.class); check(m.d()).isA(ImmutableMap.class); check(m.a()).isOf("a", "b", "c"); check(m.b()).isOf("d", "e"); check(m.c().values()).isOf(1, 2); check(m.c().keySet()).isOf("x", "y"); check(m.d().isEmpty()); m.clear(); check(m.a()).isEmpty(); check(m.b()).isEmpty(); check(m.c().entries()).isEmpty(); check(m.d().entrySet()).isEmpty(); }
public Iterable<NamedComponent<? extends Object>> getAllComponents() { return materials.values(); } }
@Override public String toString() { return functions.values().toString(); }
public Stream<Function> stream() { return functions.values().stream(); }
@Override public String toString() { return functions.values().toString(); }
@Override public int length() { return proofs.values().stream().mapToInt(AsymmetricKeyProof::getCombinedLength).sum(); }
public Iterator<Function> iterator() { return functions.values().iterator(); }
@Override public void setBackReference( String referenceName, Object reference, M value, JsonDeserializationContext ctx ) { if ( null != value ) { for ( V val : value.values() ) { valueDeserializer.setBackReference( referenceName, reference, val, ctx ); } } } }
public Iterator<Function> iterator() { return functions.values().iterator(); }
public Stream<Function> stream() { return functions.values().stream(); }
public DlpDomainRules build() { ImmutableMultimap<Targets.Type, Rule> rules = this.rules.build(); Preconditions.checkState(!containsDuplicateIds(rules), "Rules should not contain duplicated `id`"); return new DlpDomainRules(rules.values()); }
Collection<RDSInstance> listDatabaseInstancesFromQueryExpression(final String expression, final AWSDatabase db) throws OgnlException { final Collection<RDSInstance> allInstances = db.getRdsInstances().values(); if (expression == null) return allInstances; final Object compiled = Ognl.parseExpression(expression); final List<RDSInstance> instances = new ArrayList<>(); for (RDSInstance instance : allInstances) { final Object value = Ognl.getValue(compiled, instance); if (value instanceof Boolean && (Boolean) value) instances.add(instance); } return instances; }
@Override public String toString() { if (placeHolders.size()==1) { PlaceHolder placeHolder = CollectionUtil.getAny(placeHolders.values()); if (string.length()==placeHolder.getEnd()) { return string.substring(0, placeHolder.getOffset()); } } return string; }
public Functions copy() { return builder().add(functions.values()).build(); }