@Test public void shouldReturnDummyComponentNameForInvalidFlattenString() { val resultForNull = ComponentNameUtils.fromFlattenString(null); assertThat(resultForNull, is(ComponentNameUtils.DUMMY_COMPONENT)); val resultForEmpty = ComponentNameUtils.fromFlattenString(""); assertThat(resultForEmpty, is(ComponentNameUtils.DUMMY_COMPONENT)); val resultForInvalidFormat = ComponentNameUtils.fromFlattenString("com.abc.MyActivity"); assertThat(resultForInvalidFormat, is(ComponentNameUtils.DUMMY_COMPONENT)); }
@NonNull public static ComponentName fromFlattenString(@Nullable final String flattenComponentName) { val parts = nullToEmpty(flattenComponentName).split(COMPONENT_NAME_SEPARATOR); return (parts.length == 2) ? new ComponentName(parts[0], parts[1]) : DUMMY_COMPONENT; }
ComponentNameUtils { @NonNull public static ComponentName fromFlattenString(@Nullable final String flattenComponentName) { val parts = nullToEmpty(flattenComponentName).split(COMPONENT_NAME_SEPARATOR); return (parts.length == 2) ? new ComponentName(parts[0], parts[1]) : DUMMY_COMPONENT; } }
ComponentNameUtils { @NonNull public static ComponentName fromFlattenString(@Nullable final String flattenComponentName) { val parts = nullToEmpty(flattenComponentName).split(COMPONENT_NAME_SEPARATOR); return (parts.length == 2) ? new ComponentName(parts[0], parts[1]) : DUMMY_COMPONENT; } private  ComponentNameUtils(); }
ComponentNameUtils { @NonNull public static ComponentName fromFlattenString(@Nullable final String flattenComponentName) { val parts = nullToEmpty(flattenComponentName).split(COMPONENT_NAME_SEPARATOR); return (parts.length == 2) ? new ComponentName(parts[0], parts[1]) : DUMMY_COMPONENT; } private  ComponentNameUtils(); @NonNull static String packageNameFrom(@Nullable final String flattenComponentName); @NonNull static ComponentName fromFlattenString(@Nullable final String flattenComponentName); }
ComponentNameUtils { @NonNull public static ComponentName fromFlattenString(@Nullable final String flattenComponentName) { val parts = nullToEmpty(flattenComponentName).split(COMPONENT_NAME_SEPARATOR); return (parts.length == 2) ? new ComponentName(parts[0], parts[1]) : DUMMY_COMPONENT; } private  ComponentNameUtils(); @NonNull static String packageNameFrom(@Nullable final String flattenComponentName); @NonNull static ComponentName fromFlattenString(@Nullable final String flattenComponentName); static final ComponentName DUMMY_COMPONENT; }