ExternalIdentityRef { @NotNull public static ExternalIdentityRef fromString(@NotNull String str) { int idx = str.indexOf(';'); if (idx < 0) { return new ExternalIdentityRef(Text.unescape(str), null); } else { return new ExternalIdentityRef( Text.unescape(str.substring(0, idx)), Text.unescape(str.substring(idx+1)) ); } } ExternalIdentityRef(@NotNull String id, @Nullable String providerName); @Nullable String getProviderName(); @NotNull String getId(); @NotNull String getString(); @NotNull static ExternalIdentityRef fromString(@NotNull String str); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testFromString() { ExternalIdentityRef r = ExternalIdentityRef.fromString(refNullProvider.getString()); assertEquals(refNullProvider, r); assertEquals(USERID, r.getId()); assertEquals(refNullProvider.getString(), r.getString()); assertNull(r.getProviderName()); r = ExternalIdentityRef.fromString(refEmptyProvider.getString()); assertEquals(refEmptyProvider, r); assertEquals(USERID, r.getId()); assertEquals(refEmptyProvider.getString(), r.getString()); assertNull(r.getProviderName()); r = ExternalIdentityRef.fromString(ref.getString()); assertEquals(ref, r); assertEquals(USERID, r.getId()); assertEquals(PROVIDER_NAME, r.getProviderName()); assertEquals(ref.getString(), r.getString()); }