Source:
private WriteRequest(final Mode mode, ContentFormat format, final LwM2mPath target, final LwM2mNode node) { super(target); Validate.notNull(mode); Validate.notNull(node); if (getPath().isResource() && mode == Mode.UPDATE) { throw new IllegalArgumentException( String.format("Invalid mode for '%s': update is not allowed on resource", target.toString())); } if (getPath().isResource()) { if (!(node instanceof LwM2mResource)) { throw new IllegalArgumentException(String.format("path '%s' and node type '%s' does not match", target.toString(), node.getClass().getSimpleName())); } } else if (getPath().isObjectInstance()) { if (!(node instanceof LwM2mObjectInstance)) { throw new IllegalArgumentException(String.format("path '%s' and node type '%s' does not match", target.toString(), node.getClass().getSimpleName())); } } else if (getPath().isObject()) { throw new IllegalArgumentException("write request cannot target an object: " + target.toString()); } if (ContentFormat.TEXT == format || ContentFormat.OPAQUE == format) { if (!getPath().isResource()) { throw new IllegalArgumentException( String.format("%s format must be used only for single resources", format.toString())); } else { LwM2mResource resource = (LwM2mResource) node; if (resource.isMultiInstances()) { throw new IllegalArgumentException( String.format("%s format must be used only for single resources", format.toString())); } else { if (resource.getType() == Type.OPAQUE && format == ContentFormat.TEXT) { throw new IllegalArgumentException(String.format( "TEXT format must not be used for byte array single resources", format.toString())); } else if (resource.getType() != Type.OPAQUE && format == ContentFormat.OPAQUE) { throw new IllegalArgumentException(String.format( "OPAQUE format must be used only for byte array single resources", format.toString())); } } } } this.node = node; if (format == null) { this.contentFormat = ContentFormat.TLV; } else { this.contentFormat = format; } this.mode = mode; }

Target:
private WriteRequest(final Mode mode, ContentFormat format, final LwM2mPath target, final LwM2mNode node) { super(target); Validate.notNull(mode); Validate.notNull(node); if (getPath().isResource() && mode == Mode.UPDATE) { throw new IllegalArgumentException( String.format("Invalid mode for '%s': update is not allowed on resource", target.toString())); } if (getPath().isResource()) { if (!(node instanceof LwM2mResource)) { throw new IllegalArgumentException(String.format("path '%s' and node type '%s' does not match", target.toString(), node.getClass().getSimpleName())); } } else if (getPath().isObjectInstance()) { if (!(node instanceof LwM2mObjectInstance)) { throw new IllegalArgumentException(String.format("path '%s' and node type '%s' does not match", target.toString(), node.getClass().getSimpleName())); } } else if (getPath().isObject()) { throw new IllegalArgumentException("write request cannot target an object: " + target.toString()); } if (ContentFormat.TEXT == format || ContentFormat.OPAQUE == format) { if (!getPath().isResource()) { throw new IllegalArgumentException( String.format("%s format must be used only for single resources", format.toString())); } else { LwM2mResource resource = (LwM2mResource) node; if (resource.isMultiInstances()) { throw new IllegalArgumentException( String.format("%s format must be used only for single resources", format.toString())); } else { if (resource.getType() == Type.OPAQUE && format == ContentFormat.TEXT) { throw new IllegalArgumentException( "TEXT format must not be used for byte array single resources"); } else if (resource.getType() != Type.OPAQUE && format == ContentFormat.OPAQUE) { throw new IllegalArgumentException( "OPAQUE format must be used only for byte array single resources"); } } } } this.node = node; if (format == null) { this.contentFormat = ContentFormat.TLV; } else { this.contentFormat = format; } this.mode = mode; }