public IndexFeatures(boolean supportsDocumentTTL, Mapping defaultMap, ImmutableSet<Mapping> supportedMap, String wildcardField, ImmutableSet<Cardinality> supportedCardinaities, boolean supportsNanoseconds) { Preconditions.checkArgument(defaultMap!=null || defaultMap!=Mapping.DEFAULT); Preconditions.checkArgument(supportedMap!=null && !supportedMap.isEmpty() && supportedMap.contains(defaultMap)); this.supportsDocumentTTL = supportsDocumentTTL; this.defaultStringMapping = defaultMap; this.supportedStringMappings = supportedMap; this.wildcardField = wildcardField; this.supportedCardinaities = supportedCardinaities; this.supportsNanoseconds = supportsNanoseconds; }
public IndexFeatures(boolean supportsDocumentTTL, Mapping defaultMap, ImmutableSet<Mapping> supportedMap, String wildcardField, ImmutableSet<Cardinality> supportedCardinalities, boolean supportsNanoseconds, boolean supportCustomAnalyzer, boolean supportsGeoContains, boolean supportsNotQueryNormalForm) { Preconditions.checkArgument(defaultMap!=null && defaultMap!=Mapping.DEFAULT); Preconditions.checkArgument(supportedMap!=null && !supportedMap.isEmpty() && supportedMap.contains(defaultMap)); this.supportsDocumentTTL = supportsDocumentTTL; this.defaultStringMapping = defaultMap; this.supportedStringMappings = supportedMap; this.wildcardField = wildcardField; this.supportedCardinalities = supportedCardinalities; this.supportsNanoseconds = supportsNanoseconds; this.supportsCustomAnalyzer = supportCustomAnalyzer; this.supportsGeoContains = supportsGeoContains; this.supportsNotQueryNormalForm = supportsNotQueryNormalForm; }
/** Returns true iff {@code suggestWhitelistAnnotation()} supports this annotation. */ public static boolean suggestedWhitelistAnnotationSupported(Element whitelistAnnotation) { return !supportedTreeTypes(whitelistAnnotation).isEmpty(); }
private static Set<Class<?>> getStateClasses(Class<?> clazz) { ImmutableSet.Builder<Class<?>> builder = ImmutableSet.builder(); for (Method inputFunction : FunctionsParserHelper.findPublicStaticMethodsWithAnnotation(clazz, InputFunction.class)) { checkArgument(inputFunction.getParameterTypes().length > 0, "Input function has no parameters"); Class<?> stateClass = AggregationImplementation.Parser.findAggregationStateParamType(inputFunction); checkArgument(AccumulatorState.class.isAssignableFrom(stateClass), "stateClass is not a subclass of AccumulatorState"); builder.add(stateClass); } ImmutableSet<Class<?>> stateClasses = builder.build(); checkArgument(!stateClasses.isEmpty(), "No input functions found"); return stateClasses; } }
/** Creates an ImmutableSetMultimap from an asMap.entrySet. */ static <K, V> ImmutableSetMultimap<K, V> fromMapEntries( Collection<? extends Map.Entry<? extends K, ? extends Collection<? extends V>>> mapEntries, @Nullable Comparator<? super V> valueComparator) { if (mapEntries.isEmpty()) { return of(); } ImmutableMap.Builder<K, ImmutableSet<V>> builder = new ImmutableMap.Builder<>(mapEntries.size()); int size = 0; for (Entry<? extends K, ? extends Collection<? extends V>> entry : mapEntries) { K key = entry.getKey(); Collection<? extends V> values = entry.getValue(); ImmutableSet<V> set = valueSet(valueComparator, values); if (!set.isEmpty()) { builder.put(key, set); size += set.size(); } } return new ImmutableSetMultimap<>(builder.build(), size, valueComparator); }
static <E> Set<List<E>> create(List<? extends Set<? extends E>> sets) { ImmutableList.Builder<ImmutableSet<E>> axesBuilder = new ImmutableList.Builder<>(sets.size()); for (Set<? extends E> set : sets) { ImmutableSet<E> copy = ImmutableSet.copyOf(set); if (copy.isEmpty()) { return ImmutableSet.of(); } axesBuilder.add(copy); } final ImmutableList<ImmutableSet<E>> axes = axesBuilder.build(); ImmutableList<List<E>> listAxes = new ImmutableList<List<E>>() { @Override public int size() { return axes.size(); } @Override public List<E> get(int index) { return axes.get(index).asList(); } @Override boolean isPartialView() { return true; } }; return new CartesianSet<E>(axes, new CartesianList<E>(listAxes)); }
private static Optional<String> getCommonImmutableTypeForAllReturnStatementsTypes( ImmutableSet<ClassType> returnStatementsTypes) { checkState(!returnStatementsTypes.isEmpty()); ClassType arbitraryClassType = returnStatementsTypes.asList().get(0); ImmutableList<String> superTypes = getImmutableSuperTypesForClassType(arbitraryClassType); return superTypes.stream() .filter(areAllReturnStatementsAssignable(returnStatementsTypes)) .findFirst(); }
/** Creates a ProvisionException containing {@code messages}. */ public ProvisionException(Iterable<Message> messages) { this.messages = ImmutableSet.copyOf(messages); checkArgument(!this.messages.isEmpty()); initCause(Messages.getOnlyCause(this.messages)); }
/** Creates a CreationException containing {@code messages}. */ public CreationException(Collection<Message> messages) { this.messages = ImmutableSet.copyOf(messages); checkArgument(!this.messages.isEmpty()); initCause(Messages.getOnlyCause(this.messages)); }
private ImmutableMap<String, FileAttributeView> createInheritedViews( FileLookup lookup, AttributeProvider provider) { if (provider.inherits().isEmpty()) { return ImmutableMap.of(); } Map<String, FileAttributeView> inheritedViews = new HashMap<>(); createInheritedViews(lookup, provider, inheritedViews); return ImmutableMap.copyOf(inheritedViews); }
/** Builds the canonical import statement for the type. */ public String importStatement() { if (members().isEmpty()) { return String.format("import %s;", canonicalName()); } else { return String.format("import static %s.%s;", canonicalName(), simpleName().get()); } }
/** * Loads executors. Can be also used to reload executors if there have been changes in the DB. * * @throws ExecutorManagerException if no active executors are found or if loading executors * fails. */ public void setupExecutors() throws ExecutorManagerException { final ImmutableSet<Executor> newExecutors = loadExecutors(); if (newExecutors.isEmpty()) { final String error = "No active executors found"; logger.error(error); throw new ExecutorManagerException(error); } else { this.activeExecutors = newExecutors; } }
public void testToSet_empty() { assertTrue(fluent().toSet().isEmpty()); }
private Description check(ExpressionTree condition, ImmutableList<Tree> loopBodyTrees) { ImmutableSet<Symbol.VarSymbol> conditionVars = LoopConditionVisitor.scan(condition); if (conditionVars.isEmpty()) { return NO_MATCH; } for (Tree tree : loopBodyTrees) { if (UpdateScanner.scan(tree, conditionVars)) { return NO_MATCH; } } return buildDescription(condition) .setMessage( String.format( "condition variable(s) never modified in loop body: %s", Joiner.on(", ").join(conditionVars))) .build(); }
MembersInjectorImpl( InjectorImpl injector, TypeLiteral<T> typeLiteral, EncounterImpl<T> encounter, ImmutableList<SingleMemberInjector> memberInjectors) { this.injector = injector; this.typeLiteral = typeLiteral; this.memberInjectors = memberInjectors.isEmpty() ? null : memberInjectors; this.userMembersInjectors = encounter.getMembersInjectors().isEmpty() ? null : encounter.getMembersInjectors().asList(); this.injectionListeners = encounter.getInjectionListeners().isEmpty() ? null : encounter.getInjectionListeners().asList(); /*if[AOP]*/ this.addedAspects = encounter.getAspects().isEmpty() ? null : encounter.getAspects(); /*end[AOP]*/ }
@Override public Description matchImport(ImportTree tree, VisitorState state) { StaticImportInfo importInfo = StaticImports.tryCreate(tree, state); if (importInfo == null || !importInfo.members().isEmpty()) { return Description.NO_MATCH; } return describeMatch(tree, SuggestedFix.replace(tree, importInfo.importStatement())); } }
@Override public Description matchImport(ImportTree tree, VisitorState state) { StaticImportInfo importInfo = StaticImports.tryCreate(tree, state); if (importInfo == null || importInfo.isCanonical() || importInfo.members().isEmpty()) { return Description.NO_MATCH; } return describeMatch(tree, SuggestedFix.replace(tree, importInfo.importStatement())); } }
@Override public Description matchImport(ImportTree tree, VisitorState state) { StaticImportInfo importInfo = StaticImports.tryCreate(tree, state); if (importInfo == null || importInfo.isCanonical() || !importInfo.members().isEmpty()) { return Description.NO_MATCH; } return describeMatch(tree, SuggestedFix.replace(tree, importInfo.importStatement())); } }
private void initImmutableCopyOf() { ensureTypeIntrospected(); this.isGenerateImmutableCopyOf = containingType.kind().isValue() && !style().immutableCopyOfRoutinesNames().isEmpty() && (typeKind.isRegular() || typeKind.isOptionalKind()) && !isPrimitiveOrWrapped(rawTypeName) && !isUnwrappedElementPrimitiveType() && !isStringType() && !isEnumType() && attributeValueType == null; }