java.util.function.ToIntBiFunction Java Examples
The following examples show how to use
java.util.function.ToIntBiFunction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NMS_1_14.java From 1.13-Command-API with Apache License 2.0 | 6 votes |
@Override public FunctionWrapper[] getFunction(CommandContext cmdCtx, String str) throws CommandSyntaxException { Collection<CustomFunction> customFuncList = ArgumentTag.a(cmdCtx, str); FunctionWrapper[] result = new FunctionWrapper[customFuncList.size()]; CustomFunctionData customFunctionData = getCLW(cmdCtx).getServer().getFunctionData(); CommandListenerWrapper commandListenerWrapper = getCLW(cmdCtx).a().b(2); int count = 0; for (CustomFunction customFunction : customFuncList) { @SuppressWarnings("deprecation") NamespacedKey minecraftKey = new NamespacedKey(customFunction.a().b(), customFunction.a().getKey()); ToIntBiFunction<CustomFunction, CommandListenerWrapper> obj = customFunctionData::a; FunctionWrapper wrapper = new FunctionWrapper(minecraftKey, obj, customFunction, commandListenerWrapper, e -> getCLW(cmdCtx).a(((CraftEntity) e).getHandle())); result[count] = wrapper; count++; } return result; }
Example #2
Source File: DateTimeFormatGuesser.java From LogFX with GNU General Public License v3.0 | 6 votes |
private static Optional<ZonedDateTime> dateTimeFromTemporal( TemporalAccessor ta ) { ToIntBiFunction<ChronoField, Integer> getField = ( field, orElse ) -> ta.isSupported( field ) ? ta.get( field ) : orElse; ZoneId zone = Optional.<ZoneId>ofNullable( ta.query( offset() ) ) .orElse( Optional.ofNullable( ta.query( zoneId() ) ) .orElse( ZoneOffset.UTC ) ); int year = getField.applyAsInt( ChronoField.YEAR, THIS_YEAR ); int month = getField.applyAsInt( ChronoField.MONTH_OF_YEAR, 1 ); int day = getField.applyAsInt( ChronoField.DAY_OF_MONTH, 1 ); int hour = getField.applyAsInt( ChronoField.HOUR_OF_DAY, 0 ); int minute = getField.applyAsInt( ChronoField.MINUTE_OF_HOUR, 0 ); int second = getField.applyAsInt( ChronoField.SECOND_OF_MINUTE, 0 ); int nanos = getField.applyAsInt( ChronoField.NANO_OF_SECOND, 0 ); ZonedDateTime dateTime = ZonedDateTime.of( year, month, day, hour, minute, second, nanos, zone ); return Optional.of( dateTime ); }
Example #3
Source File: NMS_1_13_1.java From 1.13-Command-API with Apache License 2.0 | 6 votes |
@Override public FunctionWrapper[] getFunction(CommandContext cmdCtx, String str) throws CommandSyntaxException { Collection<CustomFunction> customFuncList = ArgumentTag.a(cmdCtx, str); FunctionWrapper[] result = new FunctionWrapper[customFuncList.size()]; CustomFunctionData customFunctionData = getCLW(cmdCtx).getServer().getFunctionData(); CommandListenerWrapper commandListenerWrapper = getCLW(cmdCtx).a().b(2); int count = 0; for(CustomFunction customFunction : customFuncList) { @SuppressWarnings("deprecation") NamespacedKey minecraftKey = new NamespacedKey(customFunction.a().b(), customFunction.a().getKey()); ToIntBiFunction<CustomFunction, CommandListenerWrapper> obj = customFunctionData::a; FunctionWrapper wrapper = new FunctionWrapper(minecraftKey, obj, customFunction, commandListenerWrapper, e -> { return (Object) getCLW(cmdCtx).a(((CraftEntity) e).getHandle()); }); result[count] = wrapper; count++; } return result; }
Example #4
Source File: NMS_1_14_3.java From 1.13-Command-API with Apache License 2.0 | 6 votes |
@Override public FunctionWrapper[] getFunction(CommandContext cmdCtx, String str) throws CommandSyntaxException { Collection<CustomFunction> customFuncList = ArgumentTag.a(cmdCtx, str); FunctionWrapper[] result = new FunctionWrapper[customFuncList.size()]; CustomFunctionData customFunctionData = getCLW(cmdCtx).getServer().getFunctionData(); CommandListenerWrapper commandListenerWrapper = getCLW(cmdCtx).a().b(2); int count = 0; for(CustomFunction customFunction : customFuncList) { @SuppressWarnings("deprecation") NamespacedKey minecraftKey = new NamespacedKey(customFunction.a().b(), customFunction.a().getKey()); ToIntBiFunction<CustomFunction, CommandListenerWrapper> obj = customFunctionData::a; FunctionWrapper wrapper = new FunctionWrapper(minecraftKey, obj, customFunction, commandListenerWrapper, e -> getCLW(cmdCtx).a(((CraftEntity) e).getHandle())); result[count] = wrapper; count++; } return result; }
Example #5
Source File: NMS_1_14_4.java From 1.13-Command-API with Apache License 2.0 | 6 votes |
@Override public FunctionWrapper[] getFunction(CommandContext cmdCtx, String str) throws CommandSyntaxException { Collection<CustomFunction> customFuncList = ArgumentTag.a(cmdCtx, str); FunctionWrapper[] result = new FunctionWrapper[customFuncList.size()]; CustomFunctionData customFunctionData = getCLW(cmdCtx).getServer().getFunctionData(); CommandListenerWrapper commandListenerWrapper = getCLW(cmdCtx).a().b(2); int count = 0; for(CustomFunction customFunction : customFuncList) { @SuppressWarnings("deprecation") NamespacedKey minecraftKey = new NamespacedKey(customFunction.a().getNamespace(), customFunction.a().getKey()); ToIntBiFunction<CustomFunction, CommandListenerWrapper> obj = customFunctionData::a; FunctionWrapper wrapper = new FunctionWrapper(minecraftKey, obj, customFunction, commandListenerWrapper, e -> { return (Object) getCLW(cmdCtx).a(((CraftEntity) e).getHandle()); }); result[count] = wrapper; count++; } return result; }
Example #6
Source File: NMS_1_13_2.java From 1.13-Command-API with Apache License 2.0 | 6 votes |
@Override public FunctionWrapper[] getFunction(CommandContext cmdCtx, String str) throws CommandSyntaxException { Collection<CustomFunction> customFuncList = ArgumentTag.a(cmdCtx, str); FunctionWrapper[] result = new FunctionWrapper[customFuncList.size()]; CustomFunctionData customFunctionData = getCLW(cmdCtx).getServer().getFunctionData(); CommandListenerWrapper commandListenerWrapper = getCLW(cmdCtx).a().b(2); int count = 0; for(CustomFunction customFunction : customFuncList) { @SuppressWarnings("deprecation") NamespacedKey minecraftKey = new NamespacedKey(customFunction.a().b(), customFunction.a().getKey()); ToIntBiFunction<CustomFunction, CommandListenerWrapper> obj = customFunctionData::a; FunctionWrapper wrapper = new FunctionWrapper(minecraftKey, obj, customFunction, commandListenerWrapper, e -> getCLW(cmdCtx).a(((CraftEntity) e).getHandle())); result[count] = wrapper; count++; } return result; }
Example #7
Source File: NMS_1_13.java From 1.13-Command-API with Apache License 2.0 | 6 votes |
@Override public FunctionWrapper[] getFunction(CommandContext cmdCtx, String str) throws CommandSyntaxException { Collection<CustomFunction> customFuncList = ArgumentTag.a(cmdCtx, str); FunctionWrapper[] result = new FunctionWrapper[customFuncList.size()]; CustomFunctionData customFunctionData = getCLW(cmdCtx).getServer().getFunctionData(); CommandListenerWrapper commandListenerWrapper = getCLW(cmdCtx).a().b(2); int count = 0; for(CustomFunction customFunction : customFuncList) { @SuppressWarnings("deprecation") NamespacedKey minecraftKey = new NamespacedKey(customFunction.a().b(), customFunction.a().getKey()); ToIntBiFunction<CustomFunction, CommandListenerWrapper> obj = customFunctionData::a; FunctionWrapper wrapper = new FunctionWrapper(minecraftKey, obj, customFunction, commandListenerWrapper, e -> { return getCLW(cmdCtx).a(((CraftEntity) e).getHandle()); }); result[count] = wrapper; count++; } return result; }
Example #8
Source File: FunctionWrapper.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
/** * Creates a FunctionWrapper * @param minecraftKey the MinecraftKey which is used to reference this function * @param invoker a method which, when invoked, runs the function * @param customFunction an NMS CustomFunction that contains the information about the function * @param clwArgB the instance of the CommandListenerWrapper which executed this command * @param mapper a function that maps a Bukkit Entity to a Minecraft Entity */ @SuppressWarnings("unchecked") public FunctionWrapper(NamespacedKey minecraftKey, @SuppressWarnings("rawtypes") ToIntBiFunction invoker, Object customFunction, Object clwArgB, Function<Entity, Object> mapper) { this.minecraftKey = minecraftKey; this.functionExecutor = invoker; this.customFunction = customFunction; this.commandListenerWrapper = clwArgB; this.mapper = mapper; }
Example #9
Source File: NMS_1_15.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public FunctionWrapper[] getFunction(CommandContext cmdCtx, String str) throws CommandSyntaxException { Collection<CustomFunction> customFuncList = ArgumentTag.a(cmdCtx, str); FunctionWrapper[] result = new FunctionWrapper[customFuncList.size()]; CustomFunctionData customFunctionData = getCLW(cmdCtx).getServer().getFunctionData(); CommandListenerWrapper commandListenerWrapper = getCLW(cmdCtx).a().b(2); int count = 0; for (CustomFunction customFunction : customFuncList) { @SuppressWarnings("deprecation") NamespacedKey minecraftKey = new NamespacedKey(customFunction.a().getNamespace(), customFunction.a().getKey()); ToIntBiFunction<CustomFunction, CommandListenerWrapper> obj = customFunctionData::a; FunctionWrapper wrapper = new FunctionWrapper(minecraftKey, obj, customFunction, commandListenerWrapper, e -> { return (Object) getCLW(cmdCtx).a(((CraftEntity) e).getHandle()); }); result[count] = wrapper; count++; } return result; }
Example #10
Source File: BiCollectors.java From mug with Apache License 2.0 | 5 votes |
/** * Returns a {@link BiCollector} that produces the sum of an integer-valued * function applied to the input pair. If no input entries are present, * the result is 0. * * @since 3.2 */ public static <K, V> BiCollector<K, V, Integer> summingInt( ToIntBiFunction<? super K, ? super V> mapper) { requireNonNull(mapper); return new BiCollector<K, V, Integer>() { @Override public <E> Collector<E, ?, Integer> splitting( Function<E, K> toKey, Function<E, V> toValue) { return Collectors.summingInt(e -> mapper.applyAsInt(toKey.apply(e), toValue.apply(e))); } }; }
Example #11
Source File: BiCollectors.java From mug with Apache License 2.0 | 5 votes |
/** * Returns a {@link BiCollector} that produces the arithmetic mean of an integer-valued * function applied to the input pair. If no input entries are present, * the result is 0. * * @since 3.2 */ public static <K, V> BiCollector<K, V, Double> averagingInt( ToIntBiFunction<? super K, ? super V> mapper) { requireNonNull(mapper); return new BiCollector<K, V, Double>() { @Override public <E> Collector<E, ?, Double> splitting( Function<E, K> toKey, Function<E, V> toValue) { return Collectors.averagingInt(e -> mapper.applyAsInt(toKey.apply(e), toValue.apply(e))); } }; }
Example #12
Source File: BiCollectors.java From mug with Apache License 2.0 | 5 votes |
/** * Returns a {@link BiCollector} which applies an {@code int}-producing * mapping function to each input pair, and returns summary statistics * for the resulting values. * * * @since 3.2 */ public static <K, V> BiCollector<K, V, IntSummaryStatistics> summarizingInt( ToIntBiFunction<? super K, ? super V> mapper) { requireNonNull(mapper); return new BiCollector<K, V, IntSummaryStatistics>() { @Override public <E> Collector<E, ?, IntSummaryStatistics> splitting( Function<E, K> toKey, Function<E, V> toValue) { return Collectors.summarizingInt(e -> mapper.applyAsInt(toKey.apply(e), toValue.apply(e))); } }; }
Example #13
Source File: SimpleBufferTriggerBuilder.java From buffer-trigger with Artistic License 2.0 | 5 votes |
/** * <b>warning:</b> the container must be thread-safed. * * @param queueAdder return the change size occurred. */ public <E1, C1> SimpleBufferTriggerBuilder<E1, C1> setContainerEx( Supplier<? extends C1> factory, ToIntBiFunction<? super C1, ? super E1> queueAdder) { checkNotNull(factory); checkNotNull(queueAdder); SimpleBufferTriggerBuilder<E1, C1> thisBuilder = (SimpleBufferTriggerBuilder<E1, C1>) this; thisBuilder.bufferFactory = (Supplier<C1>) factory; thisBuilder.queueAdder = (ToIntBiFunction<C1, E1>) queueAdder; return thisBuilder; }
Example #14
Source File: GenericSimpleBufferTriggerBuilder.java From buffer-trigger with Artistic License 2.0 | 5 votes |
/** * @param queueAdder return the change size occurred. */ @CheckReturnValue public GenericSimpleBufferTriggerBuilder<E, C> setContainerEx(Supplier<? extends C> factory, ToIntBiFunction<? super C, ? super E> queueAdder) { builder.setContainerEx(factory, queueAdder); return this; }
Example #15
Source File: NMS_1_16_R1.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public FunctionWrapper[] getFunction(CommandContext cmdCtx, String str) throws CommandSyntaxException { Collection<CustomFunction> customFuncList = ArgumentTag.a(cmdCtx, str); FunctionWrapper[] result = new FunctionWrapper[customFuncList.size()]; CustomFunctionData customFunctionData = getCLW(cmdCtx).getServer().getFunctionData(); CommandListenerWrapper commandListenerWrapper = getCLW(cmdCtx).a().b(2); int count = 0; for (CustomFunction customFunction : customFuncList) { @SuppressWarnings("deprecation") NamespacedKey minecraftKey = new NamespacedKey(customFunction.a().getNamespace(), customFunction.a().getKey()); ToIntBiFunction<CustomFunction, CommandListenerWrapper> obj = customFunctionData::a; FunctionWrapper wrapper = new FunctionWrapper(minecraftKey, obj, customFunction, commandListenerWrapper, e -> { return (Object) getCLW(cmdCtx).a(((CraftEntity) e).getHandle()); }); result[count] = wrapper; count++; } return result; }
Example #16
Source File: PartitionedFeatureVectors.java From oryx with Apache License 2.0 | 5 votes |
public PartitionedFeatureVectors(int numPartitions, ExecutorService executor, ToIntBiFunction<String,float[]> partitioner) { Preconditions.checkArgument(numPartitions > 0); Objects.requireNonNull(executor); Objects.requireNonNull(partitioner); partitions = new FeatureVectorsPartition[numPartitions]; for (int i = 0; i < numPartitions; i++) { partitions[i] = new FeatureVectorsPartition(); } partitionMap = ObjectIntHashMap.newMap(); partitionMapLock = new AutoReadWriteLock(); this.partitioner = partitioner; this.executor = executor; }
Example #17
Source File: MapStream.java From Strata with Apache License 2.0 | 2 votes |
/** * Transforms the entries in the stream to integers by applying a mapper function to each key and value. * * @param mapper a mapper function whose return values are included in the new stream * @return a stream containing the integer values returned from the mapper function */ public IntStream mapToInt(ToIntBiFunction<? super K, ? super V> mapper) { return underlying.mapToInt(e -> mapper.applyAsInt(e.getKey(), e.getValue())); }