@Test public void resetStringValue() { TestPlanDefinition planDefinition = new TestPlanDefinition(); BaseExtensionUtils.setStringValue( "testUrl", planDefinition, "testValue", TypeFactory::createType ); BaseExtensionUtils.setStringValue( "testUrl", planDefinition, null, TypeFactory::createType ); Assert.assertTrue( planDefinition.getExtension().isEmpty() ); }
@SuppressWarnings( "unchecked" ) protected static void setStringValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable String value, @Nonnull Function<String, IElement> typeFactory ) { resource.getExtension().removeIf( e -> url.equals( e.getUrl() ) ); if ( value != null ) { final IBaseExtension<?, ?> extension = resource.addExtension(); extension.setUrl( url ); extension.setValue( ( (IPrimitiveType<String>) typeFactory.apply( "string" ) ).setValue( value ) ); } }
BaseExtensionUtils { @SuppressWarnings( "unchecked" ) protected static void setStringValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable String value, @Nonnull Function<String, IElement> typeFactory ) { resource.getExtension().removeIf( e -> url.equals( e.getUrl() ) ); if ( value != null ) { final IBaseExtension<?, ?> extension = resource.addExtension(); extension.setUrl( url ); extension.setValue( ( (IPrimitiveType<String>) typeFactory.apply( "string" ) ).setValue( value ) ); } } }
BaseExtensionUtils { @SuppressWarnings( "unchecked" ) protected static void setStringValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable String value, @Nonnull Function<String, IElement> typeFactory ) { resource.getExtension().removeIf( e -> url.equals( e.getUrl() ) ); if ( value != null ) { final IBaseExtension<?, ?> extension = resource.addExtension(); extension.setUrl( url ); extension.setValue( ( (IPrimitiveType<String>) typeFactory.apply( "string" ) ).setValue( value ) ); } } private  BaseExtensionUtils(); }
BaseExtensionUtils { @SuppressWarnings( "unchecked" ) protected static void setStringValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable String value, @Nonnull Function<String, IElement> typeFactory ) { resource.getExtension().removeIf( e -> url.equals( e.getUrl() ) ); if ( value != null ) { final IBaseExtension<?, ?> extension = resource.addExtension(); extension.setUrl( url ); extension.setValue( ( (IPrimitiveType<String>) typeFactory.apply( "string" ) ).setValue( value ) ); } } private  BaseExtensionUtils();  }
BaseExtensionUtils { @SuppressWarnings( "unchecked" ) protected static void setStringValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable String value, @Nonnull Function<String, IElement> typeFactory ) { resource.getExtension().removeIf( e -> url.equals( e.getUrl() ) ); if ( value != null ) { final IBaseExtension<?, ?> extension = resource.addExtension(); extension.setUrl( url ); extension.setValue( ( (IPrimitiveType<String>) typeFactory.apply( "string" ) ).setValue( value ) ); } } private  BaseExtensionUtils();   }