@Nonnull
    public ResourceProfile multiply(final int multiplier) {
        checkArgument(multiplier >= 0, "multiplier must be >= 0");
        if (equals(ANY)) {
            return ANY;
        }

        if (this.equals(UNKNOWN)) {
            return UNKNOWN;
        }

        if (multiplier == 0) {
            return ZERO;
        }

        Map<String, ExternalResource> resultExtendedResource =
                extendedResources.entrySet().stream()
                        .map(
                                entry ->
                                        Tuple2.of(
                                                entry.getKey(),
                                                entry.getValue().multiply(multiplier)))
                        .collect(Collectors.toMap(tuple -> tuple.f0, tuple -> tuple.f1));

        return new ResourceProfile(
                cpuCores.multiply(multiplier),
                taskHeapMemory.multiply(multiplier),
                taskOffHeapMemory.multiply(multiplier),
                managedMemory.multiply(multiplier),
                networkMemory.multiply(multiplier),
                resultExtendedResource);
    }
@Test
    void testMultiply() {
        final int by = 3;
        final ResourceProfile rp1 =
                ResourceProfile.newBuilder()
                        .setCpuCores(1.0)
                        .setTaskHeapMemoryMB(100)
                        .setTaskOffHeapMemoryMB(100)
                        .setNetworkMemoryMB(100)
                        .setManagedMemoryMB(100)
                        .setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, 1.0))
                        .build();

        ResourceProfile rp2 = rp1;
        for (int i = 1; i < by; ++i) {
            rp2 = rp2.merge(rp1);
        }

        assertThat(rp1.multiply(by)).isEqualTo(rp2);
    }