class ResourceProfile implements Serializable, Comparable<ResourceProfile> {

	@Nonnull
	public ResourceProfile merge(@Nonnull ResourceProfile other) {
		if (equals(ANY) || other.equals(ANY)) {
			return ANY;
		}

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

		Map<String, Resource> resultExtendedResource = new HashMap<>(extendedResources);

		other.extendedResources.forEach((String name, Resource resource) -> {
			resultExtendedResource.compute(name, (ignored, oldResource) ->
				oldResource == null ? resource : oldResource.merge(resource));
		});

		return new ResourceProfile(
			addNonNegativeDoublesConsideringOverflow(cpuCores, other.cpuCores),
			addNonNegativeIntegersConsideringOverflow(heapMemoryInMB, other.heapMemoryInMB),
			addNonNegativeIntegersConsideringOverflow(directMemoryInMB, other.directMemoryInMB),
			addNonNegativeIntegersConsideringOverflow(nativeMemoryInMB, other.nativeMemoryInMB),
			addNonNegativeIntegersConsideringOverflow(networkMemoryInMB, other.networkMemoryInMB),
			addNonNegativeIntegersConsideringOverflow(managedMemoryInMB, other.managedMemoryInMB),
			resultExtendedResource);
	}

	public  ResourceProfile(
			double cpuCores,
			int heapMemoryInMB,
			int directMemoryInMB,
			int nativeMemoryInMB,
			int networkMemoryInMB,
			int managedMemoryInMB,
			Map<String, Resource> extendedResources);
	public  ResourceProfile(double cpuCores, int heapMemoryInMB);
	private  ResourceProfile();
	public  ResourceProfile(ResourceProfile other);

}