@Test public void setDateValue() { TestPlanDefinition planDefinition = new TestPlanDefinition(); final Date date = new Date(); BaseExtensionUtils.setDateValue( "testUrl", planDefinition, new Date(), TypeFactory::createType ); Assert.assertEquals( 1, planDefinition.getExtension().size() ); Assert.assertEquals( "testUrl", planDefinition.getExtension().get( 0 ).getUrl() ); Assert.assertEquals( date, ( (DateDt) planDefinition.getExtension().get( 0 ).getValue() ).getValue() ); }
@SuppressWarnings( "unchecked" ) protected static void setDateValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable Date 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<Date>) typeFactory.apply( "date" ) ).setValue( value ) ); } }
BaseExtensionUtils { @SuppressWarnings( "unchecked" ) protected static void setDateValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable Date 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<Date>) typeFactory.apply( "date" ) ).setValue( value ) ); } } }
BaseExtensionUtils { @SuppressWarnings( "unchecked" ) protected static void setDateValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable Date 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<Date>) typeFactory.apply( "date" ) ).setValue( value ) ); } } private  BaseExtensionUtils(); }
BaseExtensionUtils { @SuppressWarnings( "unchecked" ) protected static void setDateValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable Date 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<Date>) typeFactory.apply( "date" ) ).setValue( value ) ); } } private  BaseExtensionUtils();  }
BaseExtensionUtils { @SuppressWarnings( "unchecked" ) protected static void setDateValue( @Nonnull String url, @Nonnull IBaseHasExtensions resource, @Nullable Date 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<Date>) typeFactory.apply( "date" ) ).setValue( value ) ); } } private  BaseExtensionUtils();   }