AttributeFilterChain { public AttributeFilterChain addLast(AttributeFilter attributeFilter) { filters.addLast(attributeFilter); return this; } AttributeFilterChain();  AttributeFilterChain(AttributeFilter filter);  AttributeFilterChain(List<AttributeFilter> filters); Object getAttribute(UaNode node, AttributeId attributeId); Object getAttribute(@Nullable Session session, UaNode node, AttributeId attributeId); void setAttribute(UaNode node, AttributeId attributeId, Object value); void setAttribute(@Nullable Session session, UaNode node, AttributeId attributeId, Object value); AttributeFilterChain addFirst(AttributeFilter attributeFilter); AttributeFilterChain addFirst(AttributeFilter... attributeFilters); AttributeFilterChain addLast(AttributeFilter attributeFilter); AttributeFilterChain addLast(AttributeFilter... attributeFilters);  }
@Test public void testAddLast() { AttributeFilterChain chain = new AttributeFilterChain(); chain.addLast( AttributeFilters.getValue(ctx -> (DataValue) ctx.getAttribute(AttributeId.Value)), AttributeFilters.getValue(ctx -> new DataValue(new Variant("Last"))) ); DataValue value = (DataValue) chain.getAttribute(null, AttributeId.Value); assertEquals(value.getValue().getValue(), "Last"); }
@Test public void testObservable() { final AtomicBoolean observed = new AtomicBoolean(false); UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(context) .setNodeId(NodeId.NULL_VALUE) .setAccessLevel(AccessLevel.READ_WRITE) .setBrowseName(QualifiedName.NULL_VALUE) .setDisplayName(LocalizedText.NULL_VALUE) .setDataType(Identifiers.String) .setTypeDefinition(Identifiers.BaseDataVariableType) .build(); node.addAttributeObserver((node1, attributeId, value) -> { observed.set(true); }); node.getFilterChain().addLast( AttributeFilters.getValue( ctx -> { ctx.setObservable(true); return new DataValue(new Variant("foo")); } ) ); assertEquals(node.getValue().getValue().getValue(), "foo"); assertTrue(observed.get()); }