@Test(expected = IllegalArgumentException.class) public void throws_exception_when_long_can_not_be_converted_to_int() { TCMURI.safeLongToInt(Long.MAX_VALUE); TCMURI.safeLongToInt(Long.MIN_VALUE); }
public static int safeLongToInt(long l) { if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw new IllegalArgumentException(l + " cannot be cast to int without changing its value."); } return (int) l; }
TCMURI implements Serializable { public static int safeLongToInt(long l) { if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw new IllegalArgumentException(l + " cannot be cast to int without changing its value."); } return (int) l; } }
TCMURI implements Serializable { public static int safeLongToInt(long l) { if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw new IllegalArgumentException(l + " cannot be cast to int without changing its value."); } return (int) l; } TCMURI(String uri);  TCMURI(String uri, int version);  TCMURI(int publicationId, int itemId, int itemType);  TCMURI(int publicationId, int itemId, int itemType, int version);  TCMURI(Namespace namespace, int publicationId, int itemId, int itemType, int version); private  TCMURI(Builder builder); }
TCMURI implements Serializable { public static int safeLongToInt(long l) { if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw new IllegalArgumentException(l + " cannot be cast to int without changing its value."); } return (int) l; } TCMURI(String uri);  TCMURI(String uri, int version);  TCMURI(int publicationId, int itemId, int itemType);  TCMURI(int publicationId, int itemId, int itemType, int version);  TCMURI(Namespace namespace, int publicationId, int itemId, int itemType, int version); private  TCMURI(Builder builder); static boolean isValid(String tcmUri); static int safeLongToInt(long l); @Override String toString(); int getItemType(); int getItemId(); int getPublicationId(); int getVersion(); }
TCMURI implements Serializable { public static int safeLongToInt(long l) { if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw new IllegalArgumentException(l + " cannot be cast to int without changing its value."); } return (int) l; } TCMURI(String uri);  TCMURI(String uri, int version);  TCMURI(int publicationId, int itemId, int itemType);  TCMURI(int publicationId, int itemId, int itemType, int version);  TCMURI(Namespace namespace, int publicationId, int itemId, int itemType, int version); private  TCMURI(Builder builder); static boolean isValid(String tcmUri); static int safeLongToInt(long l); @Override String toString(); int getItemType(); int getItemId(); int getPublicationId(); int getVersion(); static final String URI_NAMESPACE; }