com.bytex.snamp.connector.dataStream.UnaryFunctionAttribute Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of data-stream Show documentation
Show all versions of data-stream Show documentation
Framework for writing connectors based on message processing
The newest version!
package com.bytex.snamp.connector.dataStream;
import com.bytex.snamp.connector.attributes.AttributeDescriptor;
import com.bytex.snamp.connector.attributes.AttributeSpecifier;
import com.bytex.snamp.connector.attributes.AttributeSupport;
import com.bytex.snamp.gateway.modeling.AttributeAccessor;
import javax.management.openmbean.OpenType;
import java.util.Objects;
/**
* Represents attribute that transforms value of another attribute in read-only manner.
* @since 2.0
* @version 2.0
* @author Roman Sakno
*/
public abstract class UnaryFunctionAttribute extends DerivedAttribute {
private static final long serialVersionUID = 3652422235984102814L;
private final String sourceAttribute;
protected UnaryFunctionAttribute(final String name,
final String sourceAttribute,
final OpenType type,
final String description,
final AttributeDescriptor descriptor) {
super(name, type, description, AttributeSpecifier.READ_ONLY, descriptor);
this.sourceAttribute = Objects.requireNonNull(sourceAttribute);
}
protected abstract T getValue(final AttributeAccessor operand) throws Exception;
@Override
protected final T getValue(final AttributeSupport support) throws Exception {
try(final AttributeAccessor accessor = new AttributeAccessor(sourceAttribute, support)){
return getValue(accessor);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy