abstract class Mixin implements Table { @State Property<List<Column>> cols; @Override public Cell cell(Row row, String columnName) { for (int i = 0; i < cols.get().size(); i++) { Column column = cols.get().get(i); if ( column.id().get().equals(columnName)) return row.c().get().get(i); } return null; } } }
if( annotation.value().isEmpty() ) name = annotation.value(); State annotation = (State) dependencyModel.injectionAnnotation(); String name; if( annotation.value().isEmpty() ) name = annotation.value(); State annotation = (State) dependencyModel.injectionAnnotation(); String name; if( annotation.value().isEmpty() ) name = annotation.value(); State annotation = (State) dependencyModel.injectionAnnotation(); String name; if( annotation.value().isEmpty() ) name = annotation.value();
implements HasIdentity @State private Property<Identity> identity;
implements HasIdentity @State private Property<Identity> identity;
public PropertyParameterInjectionMixin( @State( "testField" ) Property<String> testField ) { this.testField = testField; }
void init( @State( "namedField" ) Property<String> namedField ) { this.namedField = namedField; }
public static class TrialMixin implements Trial { @State private UnitOfWork uow; private String uowIdentity; public void doSomething() { uowIdentity = uow.usecase().name(); } public String usecaseName() { return uowIdentity; } } }
public static class TrialMixin implements Trial { @State private UnitOfWork uow; private String uowIdentity; public void doSomething() { uowIdentity = uow.usecase().name(); } public String usecaseName() { return uowIdentity; } } }
class Mixin implements BalanceData { @State @UseDefaults Property<Integer> balance; public void increasedBalance( Integer amount ) { balance.set( balance.get() + amount ); } public void decreasedBalance( Integer amount ) { balance.set( balance.get() - amount ); } public Integer getBalance() { return balance.get(); } } }
public abstract static class PropertyFieldInjectionMixin implements PropertyFieldInjectionComposite { @State Property<String> testField; @State( "testField" ) Property<String> namedField; @State StateHolder state; public StateHolder getState() { return state; } public Property<String> testField() { return testField; } public Property<String> namedField() { return namedField; } } }
implements InvocationHandler @State private AssociationStateHolder associations;
/** * Generic mixin for associations. */ @AppliesTo( { ManyAssociationMixin.AssociationFilter.class } ) public final class ManyAssociationMixin implements InvocationHandler { @State private AssociationStateHolder associations; @Override public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable { return associations.manyAssociationFor( method ); } /** * ManyAssociations generic mixin AppliesToFilter. */ static class AssociationFilter implements AppliesToFilter { @Override public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass ) { return ManyAssociation.class.isAssignableFrom( method.getReturnType() ); } } }
implements InvocationHandler @State private AssociationStateHolder associations;
implements InvocationHandler @State private AssociationStateHolder associations;
implements InvocationHandler @State private AssociationStateHolder associations;
implements InvocationHandler @State private StateHolder state;
/** * Generic mixin for associations. */ @AppliesTo( { ManyAssociationMixin.AssociationFilter.class } ) public final class ManyAssociationMixin implements InvocationHandler { @State private AssociationStateHolder associations; @Override public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable { return associations.manyAssociationFor( method ); } /** * ManyAssociations generic mixin AppliesToFilter. */ static class AssociationFilter implements AppliesToFilter { @Override public boolean appliesTo( Method method, Class<?> mixin, Class<?> compositeType, Class<?> modifierClass ) { return ManyAssociation.class.isAssignableFrom( method.getReturnType() ); } } }
implements InvocationHandler @State private StateHolder state;
class Mixin implements Describable { @State @UseDefaults public Property<String> description; @Override public String getDescription() { return description.get(); } @Override public void updateDescription( String newDescription ) { description.set( newDescription ); } } }
public ScriptMixin( @Structure PolygeneSPI spi, @This Object thisComposite, @State StateHolder state, @Structure Layer layer, @Structure Module module, @Structure Application application ) { descriptor = spi.compositeDescriptorFor( thisComposite ); engine = createNewEngine(); Bindings mixinBindings = engine.getBindings( ScriptContext.ENGINE_SCOPE ); mixinBindings.put( "Polygene", spi ); mixinBindings.put( "application", application ); mixinBindings.put( "layer", layer ); mixinBindings.put( "module", module ); mixinBindings.put( "This", thisComposite ); mixinBindings.put( "state", state ); mixinBindings.put( "objectFactory", module.objectFactory() ); mixinBindings.put( "unitOfWorkFactory", module.unitOfWorkFactory() ); mixinBindings.put( "valueBuilderFactory", module.valueBuilderFactory() ); mixinBindings.put( "transientBuilderFactory", module.transientBuilderFactory() ); mixinBindings.put( "serviceFinder", module.serviceFinder() ); mixinBindings.put( "typeLookup", module.typeLookup() ); }