List of usage examples for java.util.stream Collectors joining
public static Collector<CharSequence, ?, String> joining(CharSequence delimiter)
From source file:edu.kit.trufflehog.model.network.MacAddress.java
public MacAddress(long address) throws InvalidMACAddress { this.address = address; if (this.address > 0xFFFFFFFFFFFFL || this.address < 0) { throw new InvalidMACAddress(address); }//from www . j a v a 2s .co m hashcode = (new Long(address)).hashCode(); // transform to byte array final byte[] extractedBytes = ByteBuffer.allocate(8).putLong(address).array(); bytes = Arrays.copyOfRange(extractedBytes, 2, 8); // set multicast bit isMulticast = (bytes[0] & 1) == 1; // set string representation final List<Byte> bytes = Arrays.asList(ArrayUtils.toObject(toByteArray())); addressString = bytes.stream().map(b -> String.format("%02x", b)).collect(Collectors.joining(":")); }
From source file:alfio.manager.system.MockMailer.java
@Override public void send(Event event, String to, String subject, String text, Optional<String> html, Attachment... attachments) {/*from w w w.java 2 s . co m*/ String printedAttachments = Optional.ofNullable(attachments).map(Arrays::asList) .orElse(Collections.emptyList()).stream() .map(a -> "{filename:" + a.getFilename() + ", contentType: " + a.getContentType() + "}") .collect(Collectors.joining(", ")); log.info("Email: from: {}, replyTo: {}, to: {}, subject: {}, text: {}, html: {}, attachments: {}", event.getDisplayName(), configurationManager.getStringConfigValue( Configuration.from(event.getOrganizationId(), event.getId(), MAIL_REPLY_TO), ""), to, subject, text, html.orElse("no html"), printedAttachments); }
From source file:org.trustedanalytics.scoringengine.ATKScoringEngine.java
private String convertToCommaSeparated(float[] data) { return Floats.asList(data).stream().map(i -> String.format("%.4f", i)).collect(Collectors.joining(",")); }
From source file:edu.psu.swe.scim.spec.protocol.attribute.AttributeReferenceListWrapper.java
public String toString() { if (attributeReferences == null || attributeReferences.isEmpty()) { return ""; }// w w w . j a v a2s . com return attributeReferences.stream().map(AttributeReference::toString).collect(Collectors.joining(",")); }
From source file:com.formkiq.core.domain.type.FolderDTO.java
/** * @param string {@link String}/*from w w w . j av a 2 s .c om*/ */ public void setPermissionsasstring(final String string) { if (!StringUtils.isEmpty(string)) { if (StringUtils.containsIgnoreCase(string, FolderPermission.PERM_FORM_ADMIN.name())) { List<FolderPermission> list = new ArrayList<>(Arrays.asList(FolderPermission.values())); String join = list.stream().map(FolderPermission::name).collect(Collectors.joining(",")); String[] perms = join.split(","); setPermissions(Arrays.asList(perms)); } else { String[] perms = string.split(","); setPermissions(Arrays.asList(perms)); } } }
From source file:com.edduarte.vokter.keyword.Keyword.java
@Override public String toString() { String fullQuery = textStream().collect(Collectors.joining(" ")); return "'" + fullQuery + "'"; }
From source file:edu.emory.bmi.datacafe.core.DataCafeUtil.java
/** * Construct a string from a collection/* w w w . j av a 2 s. co m*/ * * @param collection the collection * @return the collection as a comma separated line */ public static String constructQueryFromCollection(Collection collection) { // This line of code is genius (despite looking ugly). // Future maintainer: Be careful if you are trying to refactor it. return (String) collection.stream().map(i -> append_string_(i.toString())).collect(Collectors.joining(",")); }
From source file:eu.stamp_project.automaticbuilder.MavenAutomaticBuilder.java
MavenAutomaticBuilder(InputConfiguration configuration) { this.mavenHome = DSpotUtils.buildMavenHome(configuration); this.configuration = configuration; final String pathToPom = this.configuration.getAbsolutePathToProjectRoot() + "/" + POM_FILE; if (PitMutantScoreSelector.descartesMode && DescartesChecker.shouldInjectDescartes(pathToPom)) { try (final BufferedReader buffer = new BufferedReader(new FileReader(pathToPom))) { this.contentOfOriginalPom = buffer.lines() .collect(Collectors.joining(AmplificationHelper.LINE_SEPARATOR)); } catch (Exception ignored) { }/*from ww w. j a v a2s. co m*/ DescartesInjector.injectDescartesIntoPom(pathToPom); } else { this.contentOfOriginalPom = null; } }
From source file:io.github.bluemarlin.ui.searchtree.SearchFile.java
public SearchFile(File file) throws IOException { List<String> lines = FileUtils.readLines(file, "UTF-8"); List<String> comments = lines.stream().filter(l -> l.startsWith("`")).collect(Collectors.toList()); renderer = comments.stream().filter(c -> c.contains("$renderer")).findFirst().orElse("default"); if ("default".equals(renderer)) { renderer = BluemarlinConfig.defaultRenderer(); } else {//from ww w . jav a 2 s. co m renderer = StringUtils.substringAfter(renderer, "="); } int twentyMinsInMillis = 20 * 60 * 1000; long timeNowInMillis = (new Date()).getTime(); String twentyMinsAgoInMillis = String.valueOf(timeNowInMillis - twentyMinsInMillis); jsonSearch = lines.stream().filter(l -> !l.startsWith("`")) .map(l -> l.replace("$DEFAULT_LEAGUE", BluemarlinConfig.defaultLeague())) .map(l -> l.replace("$TWENTY_MINS_AGO_IN_MILLISEC", twentyMinsAgoInMillis)) .collect(Collectors.joining(System.lineSeparator())); }
From source file:cn.com.fubon.springboot.starter.jwt.auth.JwtTokenServiceImpl.java
@Override public String createJwtToken(Authentication authentication, int minutes) { Claims claims = Jwts.claims().setId(UUID.randomUUID().toString()).setSubject(authentication.getName()) .setExpiration(new Date(currentTimeMillis() + minutes * 60 * 1000)).setIssuedAt(new Date()); String authorities = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority) .map(String::toUpperCase).collect(Collectors.joining(",")); claims.put(AUTHORITIES, authorities); return Jwts.builder().setClaims(claims).signWith(HS512, secretkey).compact(); }