public static Result validate(PropertyType type, @Nullable String value, List<String> options) { if (isBlank(value)) { return Result.SUCCESS; } EnumMap<PropertyType, Function<String, Result>> validations = createValidations(options); return validations.getOrDefault(type, aValue -> Result.SUCCESS).apply(value); }
/** * Invoke the handlers in this collection attached to the given {@code phase}. * * @param unitOfWork The Unit of Work that is changing its phase * @param phase The phase for which attached handlers should be invoked */ @SuppressWarnings("unchecked") public void notifyHandlers(UnitOfWork<T> unitOfWork, Phase phase) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Notifying handlers for phase {}", phase.toString()); } Deque<Consumer<UnitOfWork<T>>> l = handlers.getOrDefault(phase, EMPTY); while (!l.isEmpty()) { l.remove().accept(unitOfWork); } }
/** * Get the number of {@link #accept(SourceRecord) added} records that had the given {@link Operation}. * * @param op the operation for which the record count is to be returned * @return the count; never negative */ public long numberOf(Operation op) { return statsByOperation.getOrDefault(op, EMPTY).get(); }
@Override protected boolean isQuiet(EnumMap<SummarizeOptions, Optional<Object>> config) { return (boolean) config.getOrDefault(SummarizeOptions.QUIET, Optional.of(false)).get(); }
@Override protected int batchSize(EnumMap<SummarizeOptions, Optional<Object>> config) { return (int) config.getOrDefault(SummarizeOptions.BATCH_SIZE, Optional.of(1)).get(); }
eventHandlers.getOrDefault(eventType, this::ignoreEvent).accept(event);
List<Node> endNodes = nodeFilter.getOrDefault(END_NODES, Collections.EMPTY_LIST); List<Node> terminatorNodes = nodeFilter.getOrDefault(TERMINATOR_NODES, Collections.EMPTY_LIST); List<Node> blacklistNodes = nodeFilter.getOrDefault(BLACKLIST_NODES, Collections.EMPTY_LIST); List<Node> whitelistNodes;
private static BytesRefUtils.Converter getConverter(final FieldDefinition definition) { if (!(definition instanceof CustomFieldDefinition)) return null; final CustomFieldDefinition customDef = (CustomFieldDefinition) definition; return legacyTypeConverterSet.getOrDefault(customDef.numericType, BytesRefUtils.Converter.STRING); }
@SuppressWarnings("squid:S2445") private void increment(EnumMap<ReportColumns, Object> row, ReportColumns col, long amt) { if (row != null) { synchronized (row) { row.put(col, (Long) row.getOrDefault(col, 0) + amt); } } }
@SuppressWarnings("squid:S2445") private void increment(EnumMap<ReportColumns, Object> row, ReportColumns col, long amt) { if (row != null) { synchronized (row) { row.put(col, (Long) row.getOrDefault(col, 0) + amt); } } }
@SuppressWarnings("squid:S2445") protected void incrementCount(EnumMap<ReportColumns, Object> row, int amt) { synchronized (row) { row.put(ReportColumns.count, (int) row.getOrDefault(ReportColumns.count, 0) + amt); } }
public void addClientLibraries(ClientLibraryType type, Collection<String> categories) { Set<String> categoriesSet = clientLibraries.getOrDefault(type, new LinkedHashSet<>()); categoriesSet.addAll(categories); clientLibraries.put(type, categoriesSet); }
@SuppressWarnings("unchecked") @Nullable default Long getThreadId() { return (Long) getMetadataMap().getOrDefault(LogUnitMetadataType.THREAD_ID, null); }
/** * Get the rank of this append. * * @return The rank of this append. */ @SuppressWarnings("unchecked") @Nullable default DataRank getRank() { return (DataRank) getMetadataMap().getOrDefault(LogUnitMetadataType.RANK, null); }
/** * Get checkpoint type. */ @Nullable default CheckpointEntry.CheckpointEntryType getCheckpointType() { return (CheckpointEntry.CheckpointEntryType) getMetadataMap() .getOrDefault(LogUnitMetadataType.CHECKPOINT_TYPE, null); }
@SuppressWarnings("unchecked") default Map<UUID, Long> getBackpointerMap() { return (Map<UUID, Long>) getMetadataMap().getOrDefault(LogUnitMetadataType.BACKPOINTER_MAP, Collections.EMPTY_MAP); }
@Nullable @SuppressWarnings({"checkstyle:abbreviationaswordinname", "checkstyle:membername"}) default UUID getCheckpointId() { return (UUID) getMetadataMap().getOrDefault(LogUnitMetadataType.CHECKPOINT_ID, null); }
/** * Returns the tail of the checkpointed stream at the time of taking the checkpoint snapshot. */ default Long getCheckpointedStreamStartLogAddress() { return (Long) getMetadataMap() .getOrDefault(LogUnitMetadataType.CHECKPOINTED_STREAM_START_LOG_ADDRESS, Address.NO_BACKPOINTER); }
/** * Get the streams that belong to this append. * * @return A set of streams that belong to this append. */ @SuppressWarnings("unchecked") default Set<UUID> getStreams() { return (Set<UUID>) ((Map<UUID, Long>)getMetadataMap().getOrDefault( LogUnitMetadataType.BACKPOINTER_MAP, Collections.emptyMap())).keySet(); }
@SuppressWarnings("unchecked") @Nullable default UUID getClientId() { return (UUID) getMetadataMap().getOrDefault(LogUnitMetadataType.CLIENT_ID, null); }