@Test public void testRemoveBindingsForPmo() { BindingContext context = new BindingContext(); TestPmo pmo = new TestPmo(); ElementBinding binding1 = createBinding(context, pmo, field1); ElementBinding binding2 = createBinding(context, pmo, field2); context.add(binding1, TestComponentWrapper.with(binding1)); context.add(binding2, TestComponentWrapper.with(binding2)); assertThat(context.getBindings(), hasSize(2)); context.removeBindingsForPmo(pmo); assertThat(context.getBindings(), is(empty())); }
public void removeBindingsForPmo(Object pmo) { bindings.values().removeIf(ref -> { Binding binding = ref.get(); return binding != null && binding.getPmo() == pmo; }); getBindingStream() .filter(BindingContext.class::isInstance) .map(BindingContext.class::cast) .forEach(bc -> bc.removeBindingsForPmo(pmo)); if (pmo instanceof PresentationModelObject) { ((PresentationModelObject)pmo).getEditButtonPmo().ifPresent(this::removeBindingsForPmo); } if (pmo instanceof ContainerPmo) { ((ContainerPmo<?>)pmo).getAddItemButtonPmo().ifPresent(this::removeBindingsForPmo); } }
BindingContext implements UiUpdateObserver { public void removeBindingsForPmo(Object pmo) { bindings.values().removeIf(ref -> { Binding binding = ref.get(); return binding != null && binding.getPmo() == pmo; }); getBindingStream() .filter(BindingContext.class::isInstance) .map(BindingContext.class::cast) .forEach(bc -> bc.removeBindingsForPmo(pmo)); if (pmo instanceof PresentationModelObject) { ((PresentationModelObject)pmo).getEditButtonPmo().ifPresent(this::removeBindingsForPmo); } if (pmo instanceof ContainerPmo) { ((ContainerPmo<?>)pmo).getAddItemButtonPmo().ifPresent(this::removeBindingsForPmo); } } }
BindingContext implements UiUpdateObserver { public void removeBindingsForPmo(Object pmo) { bindings.values().removeIf(ref -> { Binding binding = ref.get(); return binding != null && binding.getPmo() == pmo; }); getBindingStream() .filter(BindingContext.class::isInstance) .map(BindingContext.class::cast) .forEach(bc -> bc.removeBindingsForPmo(pmo)); if (pmo instanceof PresentationModelObject) { ((PresentationModelObject)pmo).getEditButtonPmo().ifPresent(this::removeBindingsForPmo); } if (pmo instanceof ContainerPmo) { ((ContainerPmo<?>)pmo).getAddItemButtonPmo().ifPresent(this::removeBindingsForPmo); } } BindingContext();  BindingContext(String contextName);  BindingContext(String contextName, PropertyBehaviorProvider behaviorProvider,
            Handler afterUpdateHandler);  BindingContext(String contextName, PropertyBehaviorProvider behaviorProvider,
            PropertyDispatcherFactory dispatcherFactory, Handler afterUpdateHandler); }
BindingContext implements UiUpdateObserver { public void removeBindingsForPmo(Object pmo) { bindings.values().removeIf(ref -> { Binding binding = ref.get(); return binding != null && binding.getPmo() == pmo; }); getBindingStream() .filter(BindingContext.class::isInstance) .map(BindingContext.class::cast) .forEach(bc -> bc.removeBindingsForPmo(pmo)); if (pmo instanceof PresentationModelObject) { ((PresentationModelObject)pmo).getEditButtonPmo().ifPresent(this::removeBindingsForPmo); } if (pmo instanceof ContainerPmo) { ((ContainerPmo<?>)pmo).getAddItemButtonPmo().ifPresent(this::removeBindingsForPmo); } } BindingContext();  BindingContext(String contextName);  BindingContext(String contextName, PropertyBehaviorProvider behaviorProvider,
            Handler afterUpdateHandler);  BindingContext(String contextName, PropertyBehaviorProvider behaviorProvider,
            PropertyDispatcherFactory dispatcherFactory, Handler afterUpdateHandler); String getName(); @Deprecated BindingContext add(Binding binding); BindingContext add(Binding binding, ComponentWrapper componentWrapper); Collection<Binding> getBindings(); void removeBindingsForComponent(Object uiComponent); void removeBindingsForPmo(Object pmo); @Deprecated void updateUI(); void modelChanged(); @Override void uiUpdated(); @Deprecated final void updateMessages(MessageList messages); MessageList displayMessages(MessageList messages); PropertyBehaviorProvider getBehaviorProvider(); @Override String toString(); Binding bind(Object pmo,
            BindingDescriptor bindingDescriptor,
            ComponentWrapper componentWrapper); Binding bind(Object pmo,
            BoundProperty boundProperty,
            List<LinkkiAspectDefinition> aspectDefs,
            ComponentWrapper componentWrapper); ContainerBinding bindContainer(Object pmo,
            BoundProperty boundProperty,
            List<LinkkiAspectDefinition> aspectDefs,
            ComponentWrapper componentWrapper); @Deprecated final PropertyDispatcher createDispatcherChain(Object pmo,
            BindingDescriptor bindingDescriptor); }
BindingContext implements UiUpdateObserver { public void removeBindingsForPmo(Object pmo) { bindings.values().removeIf(ref -> { Binding binding = ref.get(); return binding != null && binding.getPmo() == pmo; }); getBindingStream() .filter(BindingContext.class::isInstance) .map(BindingContext.class::cast) .forEach(bc -> bc.removeBindingsForPmo(pmo)); if (pmo instanceof PresentationModelObject) { ((PresentationModelObject)pmo).getEditButtonPmo().ifPresent(this::removeBindingsForPmo); } if (pmo instanceof ContainerPmo) { ((ContainerPmo<?>)pmo).getAddItemButtonPmo().ifPresent(this::removeBindingsForPmo); } } BindingContext();  BindingContext(String contextName);  BindingContext(String contextName, PropertyBehaviorProvider behaviorProvider,
            Handler afterUpdateHandler);  BindingContext(String contextName, PropertyBehaviorProvider behaviorProvider,
            PropertyDispatcherFactory dispatcherFactory, Handler afterUpdateHandler); String getName(); @Deprecated BindingContext add(Binding binding); BindingContext add(Binding binding, ComponentWrapper componentWrapper); Collection<Binding> getBindings(); void removeBindingsForComponent(Object uiComponent); void removeBindingsForPmo(Object pmo); @Deprecated void updateUI(); void modelChanged(); @Override void uiUpdated(); @Deprecated final void updateMessages(MessageList messages); MessageList displayMessages(MessageList messages); PropertyBehaviorProvider getBehaviorProvider(); @Override String toString(); Binding bind(Object pmo,
            BindingDescriptor bindingDescriptor,
            ComponentWrapper componentWrapper); Binding bind(Object pmo,
            BoundProperty boundProperty,
            List<LinkkiAspectDefinition> aspectDefs,
            ComponentWrapper componentWrapper); ContainerBinding bindContainer(Object pmo,
            BoundProperty boundProperty,
            List<LinkkiAspectDefinition> aspectDefs,
            ComponentWrapper componentWrapper); @Deprecated final PropertyDispatcher createDispatcherChain(Object pmo,
            BindingDescriptor bindingDescriptor);  }