@Test public void testOptionsForMatching() { String path = "testPath"; req.addOptionHeader(hostOpt); req.addOptionHeader(portOpt); CoAPOptionHeader pathOpt = new CoAPOptionHeader( CoAPOptionName.URI_PATH, path.getBytes()); req.addOptionHeader(pathOpt); int seconds = 40; byte[] maxAgeBytes = BitUtil.splitIntToBytes(seconds); CoAPOptionHeader maxAgeHeader = new CoAPOptionHeader( CoAPOptionName.MAX_AGE, maxAgeBytes); req.addOptionHeader(maxAgeHeader); String etag = "helloetag"; CoAPOptionHeader etagOpt = new CoAPOptionHeader( CoAPOptionName.ETAG, etag.getBytes()); req.addOptionHeader(etagOpt); Set<CoAPOptionHeader> options = req.optionsForMatching(); assertFalse(options.contains(etagOpt)); assertFalse(options.contains(maxAgeHeader)); assertTrue(options.contains(this.hostOpt)); assertTrue(options.contains(this.portOpt)); }
public Set<CoAPOptionHeader> optionsForMatching() { return getOptionHeaders() .stream() .filter(h -> h.getOptionName() != CoAPOptionName.ETAG) .filter(h -> h.getOptionName() != CoAPOptionName.MAX_AGE) .collect(Collectors.toSet()); }
CoAPRequest extends CoAPMessage { public Set<CoAPOptionHeader> optionsForMatching() { return getOptionHeaders() .stream() .filter(h -> h.getOptionName() != CoAPOptionName.ETAG) .filter(h -> h.getOptionName() != CoAPOptionName.MAX_AGE) .collect(Collectors.toSet()); } }
CoAPRequest extends CoAPMessage { public Set<CoAPOptionHeader> optionsForMatching() { return getOptionHeaders() .stream() .filter(h -> h.getOptionName() != CoAPOptionName.ETAG) .filter(h -> h.getOptionName() != CoAPOptionName.MAX_AGE) .collect(Collectors.toSet()); } CoAPRequest(int version, CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId, byte[] token);  CoAPRequest(int version, CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId);  CoAPRequest(CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId, byte[] token);  CoAPRequest(CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId); }
CoAPRequest extends CoAPMessage { public Set<CoAPOptionHeader> optionsForMatching() { return getOptionHeaders() .stream() .filter(h -> h.getOptionName() != CoAPOptionName.ETAG) .filter(h -> h.getOptionName() != CoAPOptionName.MAX_AGE) .collect(Collectors.toSet()); } CoAPRequest(int version, CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId, byte[] token);  CoAPRequest(int version, CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId);  CoAPRequest(CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId, byte[] token);  CoAPRequest(CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId); void setUri(URI uri); void generateTokenHeader(); void createUriFromRequest(SocketAddress socketAddress); @Override CoAPRequestCode getCode(); URI getUriFromRequest(); void setListener(CoAPRequestListener listener); CoAPRequestListener getListener(); Set<CoAPOptionHeader> optionsForMatching(); }
CoAPRequest extends CoAPMessage { public Set<CoAPOptionHeader> optionsForMatching() { return getOptionHeaders() .stream() .filter(h -> h.getOptionName() != CoAPOptionName.ETAG) .filter(h -> h.getOptionName() != CoAPOptionName.MAX_AGE) .collect(Collectors.toSet()); } CoAPRequest(int version, CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId, byte[] token);  CoAPRequest(int version, CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId);  CoAPRequest(CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId, byte[] token);  CoAPRequest(CoAPMessageType messageType, CoAPRequestCode methodCode, int messageId); void setUri(URI uri); void generateTokenHeader(); void createUriFromRequest(SocketAddress socketAddress); @Override CoAPRequestCode getCode(); URI getUriFromRequest(); void setListener(CoAPRequestListener listener); CoAPRequestListener getListener(); Set<CoAPOptionHeader> optionsForMatching();  }