@Test(expected = IllegalArgumentException.class) public void tripleComponentWrongSep() { UUIDGeneratorImpl impl = new UUIDGeneratorImpl(); impl.validateUuid("abcd001-abcdef-00001;defg002-ghijkl-00001;hijk003-mnopqr-00001"); }
@Override public String[] validateUuid(String uuid) { String[] components = uuid.split(Pattern.quote(UUIDGenerator.COMPONENT_SEPARATOR)); if (components.length != 1 && components.length != 3) { throw new IllegalArgumentException("UUid "+uuid+" has "+components.length+" component parts, expected 1 or 3"); } for (int i=0; i<components.length; i++) { if (!VALID_UUID_COMPONENT.matcher(components[i]).matches()) { throw new IllegalArgumentException("UUid component "+i+"("+components[i]+") invalid - must match pattern "+ VALID_UUID_COMPONENT.pattern()); } } if (components.length == 1) { return new String[] { null, null, uuid }; } return components; }
UUIDGeneratorImpl implements UUIDGenerator { @Override public String[] validateUuid(String uuid) { String[] components = uuid.split(Pattern.quote(UUIDGenerator.COMPONENT_SEPARATOR)); if (components.length != 1 && components.length != 3) { throw new IllegalArgumentException("UUid "+uuid+" has "+components.length+" component parts, expected 1 or 3"); } for (int i=0; i<components.length; i++) { if (!VALID_UUID_COMPONENT.matcher(components[i]).matches()) { throw new IllegalArgumentException("UUid component "+i+"("+components[i]+") invalid - must match pattern "+ VALID_UUID_COMPONENT.pattern()); } } if (components.length == 1) { return new String[] { null, null, uuid }; } return components; } }
UUIDGeneratorImpl implements UUIDGenerator { @Override public String[] validateUuid(String uuid) { String[] components = uuid.split(Pattern.quote(UUIDGenerator.COMPONENT_SEPARATOR)); if (components.length != 1 && components.length != 3) { throw new IllegalArgumentException("UUid "+uuid+" has "+components.length+" component parts, expected 1 or 3"); } for (int i=0; i<components.length; i++) { if (!VALID_UUID_COMPONENT.matcher(components[i]).matches()) { throw new IllegalArgumentException("UUid component "+i+"("+components[i]+") invalid - must match pattern "+ VALID_UUID_COMPONENT.pattern()); } } if (components.length == 1) { return new String[] { null, null, uuid }; } return components; }  }
UUIDGeneratorImpl implements UUIDGenerator { @Override public String[] validateUuid(String uuid) { String[] components = uuid.split(Pattern.quote(UUIDGenerator.COMPONENT_SEPARATOR)); if (components.length != 1 && components.length != 3) { throw new IllegalArgumentException("UUid "+uuid+" has "+components.length+" component parts, expected 1 or 3"); } for (int i=0; i<components.length; i++) { if (!VALID_UUID_COMPONENT.matcher(components[i]).matches()) { throw new IllegalArgumentException("UUid component "+i+"("+components[i]+") invalid - must match pattern "+ VALID_UUID_COMPONENT.pattern()); } } if (components.length == 1) { return new String[] { null, null, uuid }; } return components; }  @Override String getNextUUID(); @Override String[] validateUuid(String uuid); }
UUIDGeneratorImpl implements UUIDGenerator { @Override public String[] validateUuid(String uuid) { String[] components = uuid.split(Pattern.quote(UUIDGenerator.COMPONENT_SEPARATOR)); if (components.length != 1 && components.length != 3) { throw new IllegalArgumentException("UUid "+uuid+" has "+components.length+" component parts, expected 1 or 3"); } for (int i=0; i<components.length; i++) { if (!VALID_UUID_COMPONENT.matcher(components[i]).matches()) { throw new IllegalArgumentException("UUid component "+i+"("+components[i]+") invalid - must match pattern "+ VALID_UUID_COMPONENT.pattern()); } } if (components.length == 1) { return new String[] { null, null, uuid }; } return components; }  @Override String getNextUUID(); @Override String[] validateUuid(String uuid); static final String DEFAULT_HOSTNAME; }