Resource implements Comparable<Resource> { protected static int castToIntSafely(long value) { if (value > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } return Long.valueOf(value).intValue(); }  @Public @Stable static Resource newInstance(int memory, int vCores); @Public @Stable static Resource newInstance(long memory, int vCores); @Public @Stable static Resource newInstance(long memory, int vCores,
      Map<String, Long> others); @InterfaceAudience.Private @InterfaceStability.Unstable static Resource newInstance(Resource resource); @InterfaceAudience.Private @InterfaceStability.Unstable static void copy(Resource source, Resource dest); @Public @Deprecated abstract int getMemory(); @Public @Stable long getMemorySize(); @Public @Deprecated abstract void setMemory(int memory); @Public @Stable void setMemorySize(long memory); @Public @Evolving abstract int getVirtualCores(); @Public @Evolving abstract void setVirtualCores(int vCores); @InterfaceAudience.Private @InterfaceStability.Unstable ResourceInformation[] getResources(); @InterfaceAudience.Private @InterfaceStability.Unstable List<ResourceInformation> getAllResourcesListCopy(); @Public @InterfaceStability.Unstable ResourceInformation getResourceInformation(String resource); @InterfaceAudience.Private @InterfaceStability.Unstable ResourceInformation getResourceInformation(int index); @Public @InterfaceStability.Unstable long getResourceValue(String resource); @Public @InterfaceStability.Unstable void setResourceInformation(String resource,
      ResourceInformation resourceInformation); @InterfaceAudience.Private @InterfaceStability.Unstable void setResourceInformation(int index,
      ResourceInformation resourceInformation); @Public @InterfaceStability.Unstable void setResourceValue(String resource, long value); @InterfaceAudience.Private @InterfaceStability.Unstable void setResourceValue(int index, long value); @Override boolean equals(Object obj); @Override int compareTo(Resource other); @Override String toString(); @Override int hashCode(); @Private
  static final int MEMORY_INDEX; @Private
  static final int VCORES_INDEX; }
@Test public void testCastToIntSafely() { assertEquals(0, Resource.castToIntSafely(0)); assertEquals(1, Resource.castToIntSafely(1)); assertEquals(Integer.MAX_VALUE, Resource.castToIntSafely(Integer.MAX_VALUE)); assertEquals("Cast to Integer.MAX_VALUE if the long is greater than " + "Integer.MAX_VALUE", Integer.MAX_VALUE, Resource.castToIntSafely(Integer.MAX_VALUE + 1L)); assertEquals("Cast to Integer.MAX_VALUE if the long is greater than " + "Integer.MAX_VALUE", Integer.MAX_VALUE, Resource.castToIntSafely(Long.MAX_VALUE)); }