List of usage examples for java.util StringJoiner toString
@Override
public String toString()
From source file:org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.ConsentMgtPostAuthnHandler.java
private String buildConsentClaimString(List<ClaimMetaData> consentClaimsData) { StringJoiner joiner = new StringJoiner(CLAIM_SEPARATOR); for (ClaimMetaData claimMetaData : consentClaimsData) { joiner.add(claimMetaData.getId() + "_" + claimMetaData.getDisplayName()); }//from w ww.ja v a 2 s. com return joiner.toString(); }
From source file:org.mule.service.soap.client.CxfClientProvider.java
private Map<String, Object> buildSecurityProperties(List<SecurityStrategyCxfAdapter> strategies, SecurityStrategyType type) {/* w ww. ja v a 2 s . co m*/ if (strategies.isEmpty()) { return emptyMap(); } Map<String, Object> props = new HashMap<>(); StringJoiner actionsJoiner = new StringJoiner(" "); ImmutableList.Builder<CallbackHandler> callbackHandlersBuilder = ImmutableList.builder(); strategies.stream().filter(securityStrategy -> securityStrategy.securityType().equals(type)) .forEach(securityStrategy -> { props.putAll(securityStrategy.buildSecurityProperties()); actionsJoiner.add(securityStrategy.securityAction()); securityStrategy.buildPasswordCallbackHandler().ifPresent(callbackHandlersBuilder::add); }); List<CallbackHandler> handlers = callbackHandlersBuilder.build(); if (!handlers.isEmpty()) { props.put(PW_CALLBACK_REF, new CompositeCallbackHandler(handlers)); } String actions = actionsJoiner.toString(); if (isNotBlank(actions)) { // the list of actions is passed as a String with the action names separated by a black space. props.put(ACTION, actions); } // This Map needs to be mutable, cxf will add properties if needed. return props; }
From source file:com.sri.ai.praise.model.imports.church.ChurchToModelVisitor.java
protected Expression defineInHOGM(Expression name, List<Expression> params, Expression body) { Expression result = null;//from w w w . j a v a2 s . c o m // Track the known random variable names knownRandomVariableNames.add(name); // Determine the correct argument names for any of the StringBuilder rArgs = new StringBuilder(); final Map<Expression, Expression> paramVarNames = new HashMap<Expression, Expression>(); boolean firstArg = true; int cnt = 0; Expression randomVariable = name; List<Expression> rvArgs = new ArrayList<Expression>(); for (Expression arg : params) { if (firstArg) { firstArg = false; rArgs.append(" "); } else { rArgs.append(" x "); } // Ensure name is upper cased Expression logicalVariableArg = newLogicalVariable(arg.toString()); rvArgs.add(logicalVariableArg); params.set(cnt, logicalVariableArg); paramVarNames.put(arg, params.get(cnt)); // TODO - anything better? rArgs.append(CHURCH_VALUES_SORT); cnt++; } randoms.add("random " + name + ":" + rArgs + (rArgs.length() > 0 ? " -> " : " ") + "Boolean"); StringJoiner knownRandomVariablesHLM = new StringJoiner(";\n", "", ";"); randoms.forEach(r -> knownRandomVariablesHLM.add(r)); RewritingProcess processForRV = LBPFactory.newLBPProcessWithHighLevelModel( "sort " + CHURCH_VALUES_SORT + ";\n\n" + knownRandomVariablesHLM.toString()); if (rvArgs.size() > 0) { randomVariable = Expressions.apply(randomVariable, rvArgs); processForRV = LPIUtil .extendContextualSymbolsWithFreeVariablesInferringDomainsFromUsageInRandomVariables( randomVariable, processForRV); } final List<List<Boolean>> flipValues = new ArrayList<List<Boolean>>(); final List<Boolean> trueFalseValues = new ArrayList<Boolean>(); final Map<Expression, Integer> flipMarkerToId = new LinkedHashMap<Expression, Integer>(); final Map<Expression, Integer> flipMarkerToFlipValuesIdx = new LinkedHashMap<Expression, Integer>(); // Flips <- array of flip applications in body trueFalseValues.add(Boolean.FALSE); trueFalseValues.add(Boolean.TRUE); for (Integer flipId : flipIdToValue.keySet()) { Expression flipMarker = newSymbol(FLIP_ID_PREFIX + flipId); if (!flipMarkerToId.containsKey(flipMarker) && Expressions.isSubExpressionOf(flipMarker, body)) { flipMarkerToId.put(flipMarker, flipId); flipMarkerToFlipValuesIdx.put(flipMarker, flipMarkerToFlipValuesIdx.size()); flipValues.add(trueFalseValues); } } if (flipValues.size() == 0) { Expression potentialRule = createPotentialRule(randomVariable, deterministicChurch2HOGM(body, paramVarNames, processForRV), Expressions.ONE, Expressions.ZERO); result = rNormalize.rewrite(potentialRule, processForRV); } else { // H <- empty list List<Expression> h = new ArrayList<Expression>(); // for all assignments of FlipsValues to Flips do CartesianProductEnumeration<Boolean> cpe = new CartesianProductEnumeration<Boolean>(flipValues); while (cpe.hasMoreElements()) { final List<Boolean> values = cpe.nextElement(); // caseC <- subsitute FlipsValues for Flips in body Expression caseC = body .replaceAllOccurrences(new AbstractReplacementFunctionWithContextuallyUpdatedProcess() { @Override public Expression apply(Expression expression, RewritingProcess process) { Expression result = expression; if (Expressions.isSymbol(expression)) { Integer idx = flipMarkerToFlipValuesIdx.get(expression); if (idx != null) { result = values.get(idx) ? Expressions.TRUE : Expressions.FALSE; } } return result; } }, LBPFactory.newLBPProcess()); // caseH <- deterministicChurch2HOGM(caseC) Expression caseH = deterministicChurch2HOGM(caseC, paramVarNames, processForRV); // Calculate q Rational q = Rational.ONE; for (Map.Entry<Expression, Integer> flipMarkerToIdEntry : flipMarkerToId.entrySet()) { Rational pi = flipIdToValue.get(flipMarkerToIdEntry.getValue()); if (!values.get(flipMarkerToFlipValuesIdx.get(flipMarkerToIdEntry.getKey()))) { pi = Rational.ONE.subtract(pi); } q = q.multiply(pi); } h.add(createPotentialRule(randomVariable, caseH, Expressions.makeSymbol(q), Expressions.ZERO)); } Expression plusH = Plus.make(h); List<Expression> constants = new ArrayList<>(FormulaUtil.getConstants(plusH, processForRV)); // Ensure we exclude known random variable names constants.removeAll(knownRandomVariableNames); // And also ensure we remove these known constants as well. constants.remove(Expressions.TRUE); constants.remove(Expressions.FALSE); if (constants.size() > 0) { knownConstants.addAll(constants); Model model = Model.getRewritingProcessesModel(processForRV); Set<Expression> sortDeclarationExpressions = new LinkedHashSet<>(); sortDeclarationExpressions.add(new SortDeclaration(Expressions.makeSymbol(CHURCH_VALUES_SORT), SortDeclaration.UNKNOWN_SIZE, ExtensionalSet.makeUniSet(constants)).getSortDeclaration()); Set<Expression> randomVariableDeclarationExpressions = new LinkedHashSet<>(); model.getRandomVariableDeclarations() .forEach(randomVariableDeclaration -> randomVariableDeclarationExpressions .add(randomVariableDeclaration.getRandomVariableDeclaration())); processForRV = Model.setKnownSortsAndRandomVariables(sortDeclarationExpressions, randomVariableDeclarationExpressions, processForRV); } result = SimplifyWithRelationsAtBottom.simplify(plusH, name, processForRV); } rules.add(result.toString()); return result; }
From source file:io.mapzone.arena.share.content.ArenaContentProvider.java
@Override public ArenaContent get() { StringJoiner layers = new StringJoiner(","); for (SelectionDescriptor selection : context.selectionDescriptors.get()) { layers.add(selection.layer.get().label.get()); // FIXME, if multilayers are working, remove this break!!! break;//from w w w. j a v a2s . c o m } Envelope envelope = context.boundingBox.get(); StringJoiner extent = new StringJoiner(","); extent.add(String.valueOf((int) envelope.getMinX())); extent.add(String.valueOf((int) envelope.getMinY())); extent.add(String.valueOf((int) envelope.getMaxX())); extent.add(String.valueOf((int) envelope.getMaxY())); StringBuffer shareInfo = new StringBuffer(ArenaPlugin.instance().config().getProxyUrl()); shareInfo.append(ShareServletsStarter.ALIAS_SHAREINFO).append("?"); try { shareInfo.append(ShareInfoServlet.PARAMETER_LAYERS).append("=") .append(URLEncoder.encode(layers.toString(), "utf-8")); shareInfo.append("&").append(ShareInfoServlet.PARAMETER_BBOX).append("=") .append(URLEncoder.encode(extent.toString(), "utf-8")); if (!StringUtils.isBlank(ArenaPlugin.instance().config().getServiceAuthToken())) { shareInfo.append("&").append(ShareInfoServlet.PARAMETER_AUTHTOKEN).append("=") .append(URLEncoder.encode(ArenaPlugin.instance().config().getServiceAuthToken(), "utf-8")); } } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } ArenaContent content = new ArenaContent(); content.arena = ArenaPlugin.instance().config().getProxyUrl() + ArenaPlugin.ALIAS; content.shareInfo = shareInfo.toString(); return content; }
From source file:info.archinnov.achilles.internals.codegen.meta.EntityMetaCodeGen.java
private MethodSpec buildCounterColumns(List<FieldMetaSignature> parsingResults, TypeName rawClassType) { StringJoiner joiner = new StringJoiner(","); parsingResults.stream().filter(x -> x.context.columnType == COUNTER) .map(x -> Tuple2.of(x.context.cqlColumn, x.context.fieldName)).sorted(BY_CQL_NAME_COLUMN_SORTER) .map(x -> x._2()).forEach(x -> joiner.add(x)); return MethodSpec.methodBuilder("getCounterColumns").addAnnotation(Override.class) .addModifiers(Modifier.PROTECTED).returns(propertyListType(rawClassType)) .addStatement("return $T.asList($L)", ARRAYS, joiner.toString()).build(); }
From source file:info.archinnov.achilles.internals.codegen.meta.EntityMetaCodeGen.java
private MethodSpec buildNormalColumns(List<FieldMetaSignature> parsingResults, TypeName rawClassType) { StringJoiner joiner = new StringJoiner(","); parsingResults.stream().filter(x -> x.context.columnType == ColumnType.NORMAL) .map(x -> Tuple2.of(x.context.cqlColumn, x.context.fieldName)).sorted(BY_CQL_NAME_COLUMN_SORTER) .map(x -> x._2()).forEach(x -> joiner.add(x)); return MethodSpec.methodBuilder("getNormalColumns").addAnnotation(Override.class) .addModifiers(Modifier.PROTECTED).returns(propertyListType(rawClassType)) .addStatement("return $T.asList($L)", ARRAYS, joiner.toString()).build(); }
From source file:info.archinnov.achilles.internals.codegen.meta.EntityMetaCodeGen.java
private MethodSpec buildPartitionKeys(List<FieldMetaSignature> parsingResults, TypeName rawClassType) { StringJoiner joiner = new StringJoiner(","); parsingResults.stream().filter(x -> x.context.columnType == ColumnType.PARTITION) .map(x -> Tuple2.of(x.context.fieldName, (PartitionKeyInfo) x.context.columnInfo)) .sorted(PARTITION_KEY_SORTER).map(x -> x._1()).forEach(x -> joiner.add(x)); return MethodSpec.methodBuilder("getPartitionKeys").addAnnotation(Override.class) .addModifiers(Modifier.PROTECTED).returns(propertyListType(rawClassType)) .addStatement("return $T.asList($L)", ARRAYS, joiner.toString()).build(); }
From source file:info.archinnov.achilles.internals.codegen.meta.EntityMetaCodeGen.java
private MethodSpec buildClusteringColumns(List<FieldMetaSignature> parsingResults, TypeName rawClassType) { StringJoiner joiner = new StringJoiner(","); parsingResults.stream().filter(x -> x.context.columnType == CLUSTERING) .map(x -> Tuple2.of(x.context.fieldName, (ClusteringColumnInfo) x.context.columnInfo)) .sorted(CLUSTERING_COLUMN_SORTER).map(x -> x._1()).forEach(x -> joiner.add(x)); return MethodSpec.methodBuilder("getClusteringColumns").addAnnotation(Override.class) .addModifiers(Modifier.PROTECTED).returns(propertyListType(rawClassType)) .addStatement("return $T.asList($L)", ARRAYS, joiner.toString()).build(); }
From source file:info.archinnov.achilles.internals.codegen.meta.EntityMetaCodeGen.java
private MethodSpec buildComputedColumns(List<FieldMetaSignature> parsingResults, TypeName rawClassType) { StringJoiner joiner = new StringJoiner(","); parsingResults.stream().filter(x -> x.context.columnType == ColumnType.COMPUTED) .map(x -> Tuple2.of(((ComputedColumnInfo) x.context.columnInfo).alias, x.context.fieldName)) .sorted(BY_CQL_NAME_COLUMN_SORTER).map(x -> x._2()).forEach(x -> joiner.add(x)); return MethodSpec.methodBuilder("getComputedColumns").addAnnotation(Override.class) .addModifiers(Modifier.PROTECTED).returns(propertyListType(rawClassType)) .addStatement("return $T.asList($L)", ARRAYS, joiner.toString()).build(); }
From source file:com.offbynull.voip.kademlia.GraphHelper.java
@SuppressWarnings("unchecked") private void applyRoutingTreeChanges(Context ctx, RouteTreeChangeSet changeSet) { Set<BitString> updatedPrefixes = new HashSet<>(); // Remove nodes from graph and set for (Activity removedNode : changeSet.getKBucketChangeSet().getBucketChangeSet().viewRemoved()) { Id id = removedNode.getNode().getId(); BitString prefix = findPrefixInRouteTreeIds(id); routeTreePrefixToIds.get(prefix).remove(id); updatedPrefixes.add(prefix);// w w w. ja va 2s.co m } // Add nodes to graph and set for (Activity addedNode : changeSet.getKBucketChangeSet().getBucketChangeSet().viewAdded()) { Id id = addedNode.getNode().getId(); BitString prefix = findPrefixInRouteTreeIds(id); routeTreePrefixToIds.get(prefix).add(id); updatedPrefixes.add(prefix); } for (BitString updatedPrefix : updatedPrefixes) { // Concatenate to string and set as label StringJoiner joiner = new StringJoiner("\n"); // Find parent int prefixBitLength = updatedPrefix.getBitLength(); BitString parentPrefix = getParentPrefix(routeTreePrefixToIds.keySet(), updatedPrefix); // Calculate number of bits after parent prefix (the bits to display) int newBitsOffset = parentPrefix.getBitLength(); int newBitsLength = prefixBitLength - parentPrefix.getBitLength(); BitString prefixDisplayBits = updatedPrefix.getBits(newBitsOffset, newBitsLength); // Change label to contain all nodes in the bucket joiner.add(prefixDisplayBits.toString()); routeTreePrefixToIds.get(updatedPrefix).forEach(id -> joiner.add(id.getBitString().toString())); ctx.addOutgoingMessage(graphAddress, new LabelNode(updatedPrefix.toString(), joiner.toString())); } }