org.apache.polygene.api.association.Association类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.apache.polygene.api.association.Association类的一些代码示例,展示了Association类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Association类的具体详情如下:
包路径:org.apache.polygene.api.association.Association
类名称:Association

Association介绍

[英]Association to a single EntityComposite.
[中]与单个实体组件的关联。

代码示例

代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.api

@Override
public void set( Object associated )
  throws IllegalArgumentException
{
  next.set( associated );
}

代码示例来源:origin: apache/attic-polygene-java

@Override
public Object get()
{
  return next.get();
}

代码示例来源:origin: apache/attic-polygene-java

@Override
public EntityReference reference()
{
  return next.reference();
}

代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.testsupport

@Override
public void movedToNewAddress( String street, String zipCode, City city, Country country, Rent rent )
{
  Address newAddress = repository.createAddress( street, zipCode, city, country, rent );
  Address oldAddress = address().get();
  oldAddresses().add( oldAddress );
  address().set( newAddress );
}

代码示例来源:origin: apache/attic-polygene-java

@Override
  public void amendAddress( String street, String zipCode, City city, Country country )
  {
    Address newAddress = repository.createAddress( street, zipCode, city, country, address().get().rent().get() );
    address().set( newAddress );
  }
}

代码示例来源:origin: apache/attic-polygene-java

@Override
public void set( Object associated )
  throws IllegalArgumentException
{
  next.set( associated );
}

代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.api

@Override
public Object get()
{
  return next.get();
}

代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.testsupport

@Override
  public void amendAddress( String street, String zipCode, City city, Country country )
  {
    Address newAddress = repository.createAddress( street, zipCode, city, country, address().get().rent().get() );
    address().set( newAddress );
  }
}

代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.api

@Override
public EntityReference reference()
{
  return next.reference();
}

代码示例来源:origin: apache/attic-polygene-java

@Override
public void marry( PersonEntity entity )
{
  spouse.set( entity );
}

代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.api

@Override
public boolean test( Composite item )
{
  try
  {
    Association<T> assoc = association.apply( item );
    if( assoc == null )
    {
      return true;
    }
    return assoc.get() == null;
  }
  catch( IllegalArgumentException e )
  {
    return true;
  }
}

代码示例来源:origin: apache/attic-polygene-java

@Override
public void movedToNewAddress( String street, String zipCode, City city, Country country, Rent rent )
{
  Address newAddress = repository.createAddress( street, zipCode, city, country, rent );
  Address oldAddress = address().get();
  oldAddresses().add( oldAddress );
  address().set( newAddress );
}

代码示例来源:origin: apache/attic-polygene-java

@Override
public EntityReference entityReferenceOf( Association<?> assoc )
{
  return assoc.reference();
}

代码示例来源:origin: apache/attic-polygene-java

public void changeOwner( Person owner )
  {
    state.owner().set( owner );
  }
}

代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.api

@Override
public boolean test( Composite item )
{
  try
  {
    Association<T> assoc = association.apply( item );
    if( assoc == null )
    {
      return false;
    }
    return assoc.get() != null;
  }
  catch( IllegalArgumentException e )
  {
    return false;
  }
}

代码示例来源:origin: apache/attic-polygene-java

@Test
public void shouldBeAbleToSetLeadToTheCompany()
  throws UnitOfWorkCompletionException
{
  Identity identity;
  try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
  {
    Company startUp = uow.newEntity( Company.class );
    Employee niclas = uow.newEntity( Employee.class );
    startUp.lead().set( niclas );
    identity = ((HasIdentity) startUp).identity().get();
    uow.complete();
  }
  try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
  {
    Company startUp = uow.get( Company.class, identity );
    Employee niclas = startUp.lead().get();
    assertThat( niclas, notNullValue() );
    SalesTeam sales = uow.get( SalesTeam.class, identity );
    assertThat( sales.lead().get(), equalTo( niclas ) );
    ResearchTeam research = uow.get( ResearchTeam.class, identity );
    assertThat( research.lead().get(), equalTo( niclas ) );
  }
}

代码示例来源:origin: org.apache.polygene.core/org.apache.polygene.core.spi

association -> builder.add(
    association.qualifiedName().name(),
    doSerialize( options, state.associationFor( association.accessor() ).reference(), false ) ) );
valueType.manyAssociations().forEach(
  association -> builder.add(

代码示例来源:origin: apache/attic-polygene-java

@Override
  public void purchase( Steinway piano )
  {
    steinway().set( piano );
  }
}

代码示例来源:origin: apache/attic-polygene-java

@Override
public boolean test( Composite item )
{
  try
  {
    Association<T> assoc = association.apply( item );
    if( assoc == null )
    {
      return false;
    }
    return assoc.get() != null;
  }
  catch( IllegalArgumentException e )
  {
    return false;
  }
}

代码示例来源:origin: apache/attic-polygene-java

@Test
public void givenAssignmentOfAssociationAtCreationWhenDereferencingAssocationExpectCorrectValue()
  throws Exception
{
  UnitOfWork work = unitOfWorkFactory.newUnitOfWork();
  TheAssociatedType entity1 = work.newEntity( TheAssociatedType.class );
  EntityBuilder<TheMainType> builder = work.newEntityBuilder( TheMainType.class );
  builder.instance().assoc().set( entity1 );
  TheMainType entity2 = builder.newInstance();
  Identity id1 = entity1.identity().get();
  Identity id2 = entity2.identity().get();
  work.complete();
  assertThat(id1, notNullValue());
  assertThat(id2, notNullValue());
  work = unitOfWorkFactory.newUnitOfWork();
  TheMainType entity3 = work.get(TheMainType.class, id2 );
  TheAssociatedType entity4 = entity3.assoc().get();
  assertThat( entity4.identity().get(), equalTo(id1));
  work.discard();
}

相关文章

微信公众号

最新文章

更多