public void convertSource ( final Builder builder ) { Variant sourceValue; sourceValue = builder.getAttributes ().remove ( this.tag ); if ( sourceValue != null ) { builder.setAttribute ( this.attributeName, sourceValue ); } sourceValue = builder.getAttributes ().remove ( this.attributeCountName ); if ( sourceValue != null && this.debug ) { builder.setAttribute ( String.format ( "%s.%s.count", this.prefix, this.tag ), sourceValue ); } sourceValue = builder.getAttributes ().remove ( this.tag + ".items" ); if ( sourceValue != null && this.debug ) { builder.setAttribute ( String.format ( "%s.%s.items", this.prefix, this.tag ), sourceValue ); } }
@Override public void dataUpdate ( final Map<String, Object> context, final DataItemValue.Builder builder ) { // convert source errors convertSource ( builder ); for ( final Entry entry : this.entries ) { entry.start ( context, builder ); } // sum up for ( final Map.Entry<String, Variant> valueEntry : builder.getAttributes ().entrySet () ) { final Variant pValue = valueEntry.getValue (); final String name = valueEntry.getKey (); for ( final Entry entry : this.entries ) { entry.check ( name, pValue ); } } for ( final Entry entry : this.entries ) { entry.end ( context, builder ); } }
private void replaceAttribute ( final Builder builder, final String attribute, final String renamedAttribute, final Variant replacement ) { final Variant value = builder.getAttributes ().remove ( attribute ); if ( value != null ) { builder.setAttribute ( attribute, replacement ); builder.setAttribute ( renamedAttribute, value ); } }
AttributesHelper.mergeAttributes ( newValue.getAttributes (), attributes );
AttributesHelper.mergeAttributes ( newValue.getAttributes (), attributes );
@Override protected void performDataUpdate ( final Map<String, Object> context, final Builder builder ) { if ( builder.getSubscriptionState () != SubscriptionState.CONNECTED ) { setUnsafe (); return; } final Variant value = builder.getValue (); if ( value == null || value.isNull () ) { setUnsafe (); return; } if ( builder.getAttributes () != null ) { final Variant errorAttr = builder.getAttributes ().get ( "error" ); if ( errorAttr != null && errorAttr.asBoolean () ) { // error attribute set to "true" setUnsafe (); return; } } performValueUpdate ( context, builder, value ); }
public static Long getTimestamp ( final Builder builder ) { if ( builder == null || builder.getAttributes () == null ) { return null; } final Variant attr = builder.getAttributes ().get ( "timestamp" ); if ( attr == null ) { return null; } return attr.asLong ( null ); }
private void injectTimestamp ( final Builder builder, final ManualStateData state ) { if ( state.getTimestmap () != null ) { // we always inject a new timestamp final Variant originalTimestamp = builder.getAttributes ().get ( "timestamp" ); //$NON-NLS-1$ builder.setAttribute ( "timestamp", Variant.valueOf ( state.getTimestmap ().getTime () ) ); //$NON-NLS-1$ if ( originalTimestamp != null ) { builder.setAttribute ( this.attrTimestampOriginal, originalTimestamp ); } } }