Node node = document.createElement( "transient" ); addAttribute( "type", descriptor.types().findFirst().get().getName(), node ); addAttribute( "visibility", descriptor.visibility().name(), node );
@Override public <T> TransientBuilder<T> newTransientBuilder( Class<T> mixinType ) throws NoSuchTransientTypeException { Objects.requireNonNull( mixinType, "mixinType" ); TransientDescriptor model = typeLookup.lookupTransientModel( mixinType ); if( model == null ) { throw new NoSuchTransientTypeException( mixinType.getName(), descriptor() ); } Map<AccessibleObject, Property<?>> properties = new HashMap<>(); model.state().properties().forEach( propertyModel -> { Object initialValue = propertyModel.resolveInitialValue( model.module() ); Property<?> property = new PropertyInstance<>( ( (PropertyModel) propertyModel ).getBuilderInfo(), initialValue ); properties.put( propertyModel.accessor(), property ); } ); TransientStateInstance state = new TransientStateInstance( properties ); return new TransientBuilderInstance<>( model, state, UsesInstance.EMPTY_USES ); }
@Test public final void testCompositeDescriptorWithMixin() { // Test with composite TransientDescriptor addressDesc = module.transientDescriptor( AddressComposite.class.getName() ); assertNotNull( addressDesc ); assertEquals( AddressComposite.class, addressDesc.types().findFirst().orElse( null ) ); }
@Test public final void testTransientCompositeDescriptorWithComposite() throws Throwable { // Test with Standard composite AddressComposite address = transientBuilderFactory.newTransient( AddressComposite.class ); TransientDescriptor addressDescriptor = spi.transientDescriptorFor( address ); assertNotNull( addressDescriptor ); assertEquals( AddressComposite.class, addressDescriptor.types().findFirst().orElse( null ) ); assertTrue( TransientDescriptor.class.isAssignableFrom( addressDescriptor.getClass() ) ); }
compositeUri = context.createCompositeUri( moduleUri, transientDescriptor.types().findFirst().orElse( null ) ); context.addType( compositeUri, PolygeneRdf.TYPE_COMPOSITE ); context.addRelationship( moduleUri, PolygeneRdf.RELATIONSHIP_COMPOSITE, compositeUri );