TLVElement { public List<TLVElement> getChildElements(int tag) { List<TLVElement> elements = new LinkedList<>(); for (TLVElement element : children) { if (tag == element.getType()) { elements.add(element); } } return elements; } TLVElement(boolean nonCritical, boolean forwarded, int type);  TLVElement(boolean inputTlv16, boolean nonCritical, boolean forwarded, int type); static TLVElement create(byte[] bytes); static TLVElement create(int type, long value); static TLVElement create(int type, Date value); static TLVElement create(int type, DataHash value); static TLVElement create(int type, String value); static TLVElement create(int type, byte[] value); static TLVElement create(int type, HashAlgorithm value); final Long getDecodedLong(); final String getDecodedString(); final DataHash getDecodedDataHash(); final Date getDecodedDate(); HashAlgorithm getDecodedHashAlgorithm(); byte[] getContent(); void setContent(byte[] content); void setStringContent(String s); void setLongContent(long value); void setDataHashContent(DataHash dataHash); void setDateContent(Date date); void setHashAlgorithmContent(HashAlgorithm hashAlgorithm); TLVElement getFirstChildElement(int tag); TLVElement getFirstChildElement(); TLVElement getLastChildElement(); List<TLVElement> getChildElements(int tag); List<TLVElement> getChildElements(); List<TLVElement> getChildElements(int... tags); int getType(); void setType(int type); boolean isOutputTlv16(); boolean isInputTlv16(); boolean isNonCritical(); boolean isForwarded(); byte[] encodeHeader(); int getContentLength(); int getHeaderLength(); void replace(TLVElement childToBeReplaced, TLVElement newChild); void remove(TLVElement elementToRemoved); void addChildElement(TLVElement element); void addFirstChildElement(TLVElement element); void writeTo(OutputStream out); byte[] getEncoded(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final int MAX_TLV16_CONTENT_LENGTH; }
@Test public void testGetAllTheChildElementsFormEncodeTlvElement_Ok() throws Exception { TLVElement element = load(CommonTestUtil.load("aggregation-203-error.tlv")); List<TLVElement> childElements = element.getChildElements(0x203); Assert.assertNotNull(childElements); Assert.assertEquals(childElements.size(), 1); Assert.assertTrue(element.getChildElements(0x202).isEmpty()); }