private static Set<HttpMethod> initAllowedHttpMethods(Set<HttpMethod> declaredMethods) { if (declaredMethods.isEmpty()) { return EnumSet.allOf(HttpMethod.class).stream() .filter(method -> method != HttpMethod.TRACE) .collect(Collectors.toSet()); } else { Set<HttpMethod> result = new LinkedHashSet<>(declaredMethods); if (result.contains(HttpMethod.GET)) { result.add(HttpMethod.HEAD); } result.add(HttpMethod.OPTIONS); return result; } }
private static List<String> getNames() { return EnumSet.allOf(KinesisRegion.class).stream().map(KinesisRegion::serialize).collect(Collectors.toList()); }
@Override public Stream<? extends Arguments> provideArguments(ExtensionContext context) { return constants.stream().map(Arguments::of); }
/** * Convert an enum set of ClusterMetrics.Option to a list of ClusterStatusProtos.Option * @param options the ClusterMetrics options * @return a list of ClusterStatusProtos.Option */ public static List<ClusterStatusProtos.Option> toOptions(EnumSet<ClusterMetrics.Option> options) { return options.stream().map(ClusterMetricsBuilder::toOption).collect(Collectors.toList()); }
private EnumSet<E> evaluate(Predicate<E> predicate) { final EnumSet<E> result = EnumSet.noneOf(enumClass); constants.stream().filter(predicate).forEach(result::add); return result; } }
private EnumSet<E> evaluate(Predicate<E> predicate) { final EnumSet<E> result = EnumSet.noneOf(enumClass); constants.stream().filter(predicate).forEach(result::add); return result; }
@JsonCreator public static KinesisRegion fromString(String value) { return EnumSet.allOf(KinesisRegion.class) .stream() .filter(x -> x.serialize().equals(value)) .findFirst() .orElseThrow(() -> new IAE("Invalid region %s, region must be one of: %s", value, getNames())); }
/** * Builds a new code area with the given enum type as layer id provider. * Constants of the enum will identify layers of the code area. * * @param idEnum Enum type */ // the annotation lets the value be passed from FXML public HighlightLayerCodeArea(@NamedArg("idEnum") Class<K> idEnum) { super(); this.layersById = EnumSet.allOf(idEnum) .stream() .collect(Collectors.toConcurrentMap(id -> id, id -> new StyleLayer())); }
private static void writeAuthToken(XMLExtendedStreamWriter writer, Property token) throws XMLStreamException { writer.writeStartElement(XMLElement.forAuthTokenName(token.getName()).getLocalName()); if (PlainAuthTokenResourceDefinition.PATH.getValue().equals(token.getName())) { writeAttributes(writer, token.getValue(), AuthTokenResourceDefinition.Attribute.class); } if (DigestAuthTokenResourceDefinition.PATH.getValue().equals(token.getName())) { writeAttributes(writer, token.getValue(), Stream.concat(EnumSet.allOf(AuthTokenResourceDefinition.Attribute.class).stream(), EnumSet.allOf(DigestAuthTokenResourceDefinition.Attribute.class).stream())); } if (CipherAuthTokenResourceDefinition.PATH.getValue().equals(token.getName())) { writeAttributes(writer, token.getValue(), Stream.concat(EnumSet.allOf(AuthTokenResourceDefinition.Attribute.class).stream(), EnumSet.allOf(CipherAuthTokenResourceDefinition.Attribute.class).stream())); } writer.writeEndElement(); }
.withEventOrderingMode(EventOrderingType.fromValue(serviceConfig.orderingMode().name())) .withEventsToFireOn(serviceConfig.fireOn() .stream() .map(eventType -> EventType.fromValue(eventType.name())) .collect(toSet()));
/** * Convert an enum set of ClusterMetrics.Option to a list of ClusterStatusProtos.Option * @param options the ClusterMetrics options * @return a list of ClusterStatusProtos.Option */ public static List<ClusterStatusProtos.Option> toOptions(EnumSet<ClusterMetrics.Option> options) { return options.stream().map(ClusterMetricsBuilder::toOption).collect(Collectors.toList()); }
private static <E extends Enum<E>> ImmutableSortedMap<String, E> enumValuesByName( Class<E> enumType, ImmutableSet<E> ignoreValues) { return EnumSet.allOf(enumType) .stream() .filter(not(ignoreValues::contains)) .sorted() .collect(toImmutableSortedMap(Ordering.natural(), Enum::name, identity())); }
public String getTypeText() { StringBuilder type = new StringBuilder(); if (!getSuperTypes().isEmpty()) { type.append(String.join(" ", getSuperTypes().stream().map(SuperType::toString).collect(Collectors.toList()))); type.append(" "); } if (!getCardTypes().isEmpty()) { type.append(String.join(" ", getCardTypes().stream().map(CardType::toString).collect(Collectors.toList()))); type.append(" "); } if (!getSubTypes().isEmpty()) { type.append(" - "); type.append(String.join(" ", getSubTypes().stream().map(SubType::toString).collect(Collectors.toList()))); } return type.toString(); }
Property.MONITOR_SSL_TRUSTSTOREPASS); if (requireForSecure.stream().map(p -> conf.get(p)).anyMatch(s -> s == null || s.isEmpty())) { LOG.debug("Not configuring Jetty to use TLS"); return new AbstractConnectionFactory[] {httpFactory};
private static LexiconProto.DictionaryItem convertToProto(DictionaryItem item) { LexiconProto.DictionaryItem.Builder builder = LexiconProto.DictionaryItem.newBuilder() .setLemma(item.lemma) .setIndex(item.index) .setPrimaryPos(primaryPosConverter .convertTo(item.primaryPos, LexiconProto.PrimaryPos.PrimaryPos_Unknown)); String lowercaseLemma = item.lemma.toLowerCase(); if (item.root != null && !item.root.equals(lowercaseLemma)) { builder.setRoot(item.root); } if (item.pronunciation != null && !item.pronunciation.equals(lowercaseLemma)) { builder.setPronunciation(item.pronunciation); } if (item.secondaryPos != null && item.secondaryPos != SecondaryPos.None) { builder.setSecondaryPos(secondaryPosConverter.convertTo( item.secondaryPos, LexiconProto.SecondaryPos.SecondaryPos_Unknown)); } if (item.attributes != null && !item.attributes.isEmpty()) { builder.addAllRootAttributes(item.attributes .stream() .map((attribute) -> rootAttributeConverter .convertTo(attribute, LexiconProto.RootAttribute.RootAttribute_Unknown)) .collect(Collectors.toList())); } if (item.getReferenceItem() != null) { builder.setReference(item.getReferenceItem().id); } return builder.build(); }
/** * @param i the string to check * @return true if the string is for a namespace ignored by default */ public static boolean isDefaultIgnoredImport(String i) { return defaultIgnoredImports.stream().anyMatch(n -> n.hashless.equals(i)); }
/** * Returns a serialized form of this {@link MailboxACL.Right} as * {@link String}. * * @return a {@link String} */ public String serialize() { return value.stream() .map(Right::asCharacter) .map(String::valueOf) .collect(Collectors.joining()); }
List<Allergen> getList() { return EnumSet.allOf(Allergen.class).stream() .filter(this::isAllergicTo) .collect(Collectors.toList()); }
@Override public void serialize(EnumSet<TransitModes> modes, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { String str = modes.stream().map(TransitModes::toString).collect(Collectors.joining(",")); jsonGenerator.writeString(str); } }
public static String bitsToNames(long bits) { return bitsToTypes(bits).stream() .map(PredictorType::name) .collect(Collectors.joining(",")); }