Source:
public BootstrapWriteRequest(LwM2mPath target, LwM2mNode node, ContentFormat format) throws InvalidRequestException { super(target); if (node == null) throw new InvalidRequestException("new node value is mandatory for %s", target); if (getPath().isResource()) { if (!(node instanceof LwM2mResource)) { throw new InvalidRequestException("path '%s' and node type '%s' does not match", target, node.getClass().getSimpleName()); } } else if (getPath().isObjectInstance()) { if (!(node instanceof LwM2mObjectInstance)) { throw new InvalidRequestException("path '%s' and node type '%s' does not match", target, node.getClass().getSimpleName()); } } else if (getPath().isObject()) { if (!(node instanceof LwM2mObject)) { throw new InvalidRequestException("path '%s' and node type '%s' does not match", target, node.getClass().getSimpleName()); } } if (ContentFormat.TEXT == format || ContentFormat.OPAQUE == format) { if (!getPath().isResource()) { throw new InvalidRequestException( "Invalid format for path %s: %s format must be used only for single resources", target, format); } else { LwM2mResource resource = (LwM2mResource) node; if (resource.isMultiInstances()) { throw new InvalidRequestException( "Invalid format for path %s: %s format must be used only for single resources", target, format); } else { if (resource.getType() == Type.OPAQUE && format == ContentFormat.TEXT) { throw new InvalidRequestException( "Invalid format for path %s: TEXT format must not be used for byte array single resources", target); } else if (resource.getType() != Type.OPAQUE && format == ContentFormat.OPAQUE) { throw new InvalidRequestException( "Invalid format for path %s: OPAQUE format must be used only for byte array single resources", target); } } } } this.node = node; if (format == null) { this.contentFormat = ContentFormat.TLV; } else { this.contentFormat = format; } }

Target:
public BootstrapWriteRequest(LwM2mPath target, LwM2mNode node, ContentFormat format) throws InvalidRequestException { super(target); if (node == null) throw new InvalidRequestException("new node value is mandatory for %s", target); if (getPath().isResource()) { if (!(node instanceof LwM2mResource)) { throw new InvalidRequestException("path '%s' and node type '%s' do not match", target, node.getClass().getSimpleName()); } } else if (getPath().isObjectInstance()) { if (!(node instanceof LwM2mObjectInstance)) { throw new InvalidRequestException("path '%s' and node type '%s' do not match", target, node.getClass().getSimpleName()); } } else if (getPath().isObject()) { if (!(node instanceof LwM2mObject)) { throw new InvalidRequestException("path '%s' and node type '%s' do not match", target, node.getClass().getSimpleName()); } } if (ContentFormat.TEXT == format || ContentFormat.OPAQUE == format) { if (!getPath().isResource()) { throw new InvalidRequestException( "Invalid format for path %s: %s format must be used only for single resources", target, format); } else { LwM2mResource resource = (LwM2mResource) node; if (resource.isMultiInstances()) { throw new InvalidRequestException( "Invalid format for path %s: %s format must be used only for single resources", target, format); } else { if (resource.getType() == Type.OPAQUE && format == ContentFormat.TEXT) { throw new InvalidRequestException( "Invalid format for path %s: TEXT format must not be used for byte array single resources", target); } else if (resource.getType() != Type.OPAQUE && format == ContentFormat.OPAQUE) { throw new InvalidRequestException( "Invalid format for path %s: OPAQUE format must be used only for byte array single resources", target); } } } } this.node = node; if (format == null) { this.contentFormat = ContentFormat.TLV; } else { this.contentFormat = format; } }