/** * Creates a new `Spool` of given `elems`. */ @SuppressWarnings("unchecked") public static <T> Spool<T> newSpool(Collection<T> elems) { List<T> buffer = (List<T>)List.empty(); for (T item : elems) { buffer = buffer.$colon$colon(item); } Spool<T> result = (Spool<T>)EMPTY; while(!buffer.isEmpty()){ result = new Spool.Cons<T>(buffer.head(), Future.value(result)); buffer = (List<T>)buffer.tail(); } return result; }
private boolean allowableValuesIsEmpty(Optional<AllowableListValues> listValues) { return !listValues.isPresent() || listValues.get().values().size() == 0; }
public ClassModel(Model m){ id = m.id(); name = m.name(); qualifiedType = m.qualifiedType(); description = m.description().isEmpty() ? null : m.description().get(); baseModel = m.baseModel().isEmpty() ? null : m.baseModel().get(); discriminator = m.discriminator().isEmpty() ? null : m.discriminator().get(); properties = new HashMap<String,ClassModelProperty>(); LinkedHashMap<String,ModelProperty> propertiesMap = m.properties(); Iterator<Tuple2<String,ModelProperty>> i = propertiesMap.iterator(); while (i.hasNext()){ Tuple2<String,ModelProperty> t = i.next(); properties.put(t._1(),new ClassModelProperty(t._2())); } subTypes = new ArrayList<String>(); Iterator<String> stypes = m.subTypes().iterator(); while (stypes.hasNext()) subTypes.add(stypes.next()); }
public ConsumerGroupInfo consumerGroup(KafkaConsumer<String, Serializable> kafkaConsumer,String group){ scala.collection.immutable.List<ConsumerSummary> consumers = groupSummary.consumers().get(); if(consumers.isEmpty()){ System.out.println("Consumer group ["+group+"] does not exist or is rebalancing."); return null; consumerGroup.setActived(true); consumerGroup.setGroupName(group); Iterator<ConsumerSummary> iterator = consumers.iterator(); while (iterator.hasNext()) { ConsumerSummary consumer = iterator.next(); Iterator<TopicPartition> iterator2 = partitions.iterator();
/** * goes down the path on the subject to find the rewrite place, does the substitution, and reconstructs the term * on its way up */ private Term buildRHS(Term subject, Substitution<Variable, Term> substitution, scala.collection.immutable.List<Pair<Integer, Integer>> path, Term rhs, TermContext context) { if (path.isEmpty()) { return rhs.substituteAndEvaluate(substitution, context); } else { if (subject instanceof KItem) { KItem kItemSubject = (KItem) subject; List<Term> newContents = new ArrayList<>(((KList) kItemSubject.kList()).getContents()); //noinspection RedundantCast newContents.set(path.head().getLeft(), buildRHS(newContents.get(path.head().getLeft()), substitution, (scala.collection.immutable.List<Pair<Integer, Integer>>) path.tail(), rhs, context)); return KItem.of(kItemSubject.kLabel(), KList.concatenate(newContents), context.global()).applyAnywhereRules(context); } else if (subject instanceof BuiltinList) { BuiltinList builtinListSubject = (BuiltinList) subject; List<Term> newContents = new ArrayList<>(builtinListSubject.children); //noinspection RedundantCast newContents.set(path.head().getLeft(), buildRHS(newContents.get(path.head().getLeft()), substitution, (scala.collection.immutable.List<Pair<Integer, Integer>>) path.tail(), rhs, context)); return BuiltinList .builder(builtinListSubject.sort, builtinListSubject.operatorKLabel, builtinListSubject.unitKLabel, builtinListSubject.globalContext()) .addAll(newContents) .build(); } else { throw new AssertionError("unexpected rewrite in subject: " + subject); } } }
private Map<String, ApiListing> processControllers(Set<Class<?>> controllerClasses) { //Loop over end points (controllers) for (Class<?> controllerClass : controllerClasses) { if (ApiDocumentationController.class.isAssignableFrom(controllerClass)) { continue; } Set<Method> requestMappingMethods = AnnotationUtils.getAnnotatedMethods(controllerClass, RequestMapping.class); ApiListing apiListing = processControllerApi(controllerClass); String description = ""; Api controllerApi = controllerClass.getAnnotation(Api.class); if (controllerApi != null) { description = controllerApi.description(); } if (apiListing.apis().size() == 0) { apiListing = processMethods(requestMappingMethods, controllerClass, apiListing, description); } //Allow for multiple controllers having the same resource path. ApiListing existingApiListing = apiListingMap.get(apiListing.resourcePath()); if (existingApiListing != null) { apiListing = ApiListingUtil.mergeApiListing(existingApiListing, apiListing); } // controllers without any operations are excluded from the apiListingMap list if (apiListing.apis() != null && !apiListing.apis().isEmpty()) { apiListingMap.put(apiListing.resourcePath(), apiListing); } } return apiListingMap; }
@Override public boolean hasNext() { return !l.isEmpty(); }
constraints[i] = constraints[i].add(new LocalRewriteTerm(path.reverse(), innerRHSRewrite.theRHS[i]), BoolToken.TRUE); ruleMask = match(subjectKList.get(i), patternKList.get(i), ruleMask, path.$colon$colon(Pair.of(i, i + 1))); if (ruleMask.isEmpty()) { return ruleMask;
pattern.range(patternIndex, pattern.size()), ruleMask, subject instanceof BuiltinList.SingletonBuiltinList ? path : path.$colon$colon(Pair.of(subjectIndex, subject.size()))); elementMask.and(ruleMask); if (!elementMask.isEmpty()) { elementMask = match(subject.get(subjectIndex), patternElementTailSplit.element, elementMask, subject instanceof BuiltinList.SingletonBuiltinList ? path : path.$colon$colon(Pair.of(subjectIndex, subjectIndex + 1))); if (!elementMask.isEmpty()) { elementMask = matchAssoc(subject, subjectIndex + 1, pattern, patternIndex + 1, elementMask, path); tailMask.and(ruleMask); if (!tailMask.isEmpty()) { tailMask = match(subject.range(subjectIndex, subject.size()), patternElementTailSplit.tail, tailMask, path.$colon$colon(Pair.of(subjectIndex, subject.size()))); pattern.range(patternIndex, pattern.size()), ruleMask, subject instanceof BuiltinList.SingletonBuiltinList ? path : path.$colon$colon(Pair.of(subjectIndex, subject.size()))); ruleMask = match(subject.range(subjectIndex, i), pattern.get(patternIndex), ruleMask, subject instanceof BuiltinList.SingletonBuiltinList ? path : path.$colon$colon(Pair.of(subjectIndex, i)));
@GET @Path("/get") @Produces({MediaType.APPLICATION_JSON}) public Response test(@QueryParam("class") String className){ try{ if (className == null) throw new ClassNotFoundException(); List<ClassModel> list = new ArrayList<ClassModel>(); Iterator<Model> i = ModelConverters.readAll(Class.forName(className)).iterator(); while (i.hasNext()) list.add(new ClassModel(i.next())); return Response.ok(list).build(); } catch (ClassNotFoundException e) { return Response.status(400).entity("Could not find " + className).build(); } catch (Exception e){ return Response.status(500).entity("An error occurred: " + e.getMessage()).build(); } }
public List<BrokerInfo> fetchAllBrokers(){ List<BrokerInfo> result = new ArrayList<>(); Seq<Broker> brokers = zkUtils.getAllBrokersInCluster(); Iterator<Broker> iterator = brokers.toList().iterator(); while(iterator.hasNext()){ Broker broker = iterator.next(); Node node = broker.getNode(ListenerName.forSecurityProtocol(SecurityProtocol.PLAINTEXT)).get(); result.add(new BrokerInfo(node.idString(), node.host(), node.port())); } return result; }
if (rewrites.size() == 1 && rewrites.get(0).getLeft().isEmpty()) { return rewrites.get(0).getRight().substituteAndEvaluate(substitution, context); Map<Pair<Integer, Integer>, List<Pair<scala.collection.immutable.List<Pair<Integer, Integer>>, Term>>> commonPath = rewrites.stream().collect(Collectors.groupingBy(rw -> rw.getLeft().head())); (scala.collection.immutable.List<Pair<Integer, Integer>>) p.getLeft().tail(), p.getRight())).collect(Collectors.toList()); newContents.add(buildRHS(contents.get(i), substitution, theInnerRewrites, context)); } else {
@Override public boolean hasNext() { return !l.isEmpty(); }
protected List<String> group() { List<String> groups = new ArrayList<>(); scala.collection.immutable.List<GroupOverview> list = adminClient.listAllConsumerGroupsFlattened(); if (list == null) return groups; Iterator<GroupOverview> iterator = list.iterator(); while (iterator.hasNext()) { groups.add(iterator.next().groupId()); } return groups; }