Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added null and zero-sized value support
- Loading branch information
Showing
7 changed files
with
106 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...s/flow/src/main/java/org/opennms/netmgt/telemetry/listeners/flow/ie/values/NullValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/******************************************************************************* | ||
* This file is part of OpenNMS(R). | ||
* | ||
* Copyright (C) 2017 The OpenNMS Group, Inc. | ||
* OpenNMS(R) is Copyright (C) 1999-2017 The OpenNMS Group, Inc. | ||
* | ||
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. | ||
* | ||
* OpenNMS(R) is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* OpenNMS(R) is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with OpenNMS(R). If not, see: | ||
* http://www.gnu.org/licenses/ | ||
* | ||
* For more information contact: | ||
* OpenNMS(R) Licensing <license@opennms.org> | ||
* http://www.opennms.org/ | ||
* http://www.opennms.com/ | ||
*******************************************************************************/ | ||
|
||
package org.opennms.netmgt.telemetry.listeners.flow.ie.values; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.Optional; | ||
|
||
import org.opennms.netmgt.telemetry.listeners.flow.InvalidPacketException; | ||
import org.opennms.netmgt.telemetry.listeners.flow.ie.InformationElement; | ||
import org.opennms.netmgt.telemetry.listeners.flow.ie.Semantics; | ||
import org.opennms.netmgt.telemetry.listeners.flow.ie.Value; | ||
import org.opennms.netmgt.telemetry.listeners.flow.session.TemplateManager; | ||
|
||
import com.google.common.base.MoreObjects; | ||
|
||
public class NullValue extends Value<Void> { | ||
public NullValue(final String name, | ||
final Optional<Semantics> semantics) { | ||
super(name, semantics); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.add("name", getName()) | ||
.add("value", "(null)") | ||
.toString(); | ||
} | ||
|
||
public static InformationElement parser(final String name, final Optional<Semantics> semantics) { | ||
return new InformationElement() { | ||
@Override | ||
public Value<?> parse(final TemplateManager.TemplateResolver templateResolver, | ||
final ByteBuffer buffer) throws InvalidPacketException { | ||
return new NullValue(name, semantics); | ||
} | ||
|
||
@Override | ||
public int getMaximumFieldLength() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getMinimumFieldLength() { | ||
return 0; | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public Void getValue() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void visit(final Visitor visitor) { | ||
visitor.accept(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters