/** * Ensures that the given element is non-null and assignable to the type specified at construction time. * * @param element the object to check, or {@code null}. * @return {@code true} if the instance is valid, {@code false} if it shall be ignored. * @throws NullPointerException if the given element is {@code null}. * @throws ClassCastException if the given element is not of the expected type. */ private boolean ensureValid(final E element) { if (type.isInstance(element)) { return true; } final String message = illegalElement(this, element, type); if (message == null) { /* * If a unmarshalling process is under way, silently discard null element. * This case happen when a XML element for a collection contains no child. * See https://issues.apache.org/jira/browse/SIS-139 */ return false; } if (element == null) { throw new NullArgumentException(message); } else { throw new ClassCastException(message); } }
/** * Adds the specified element to this set if it is not already present. * * @param element element to be added to this set. * @return {@code true} if the set did not already contain the specified element. * @throws IllegalArgumentException if the specified element is not of the expected type. */ @Override public boolean add(final E element) throws IllegalArgumentException { if (type.isInstance(element)) { return super.add(element); } final String message = CheckedArrayList.illegalElement(this, element, type); if (message == null) { /* * If a unmarshalling process is under way, silently discard null element. * This case happen when a XML element for a collection contains no child. * See https://issues.apache.org/jira/browse/SIS-139 */ return false; } if (element == null) { throw new NullArgumentException(message); } else { throw new IllegalArgumentException(message); } }
/** * Ensures that the given element is non-null and assignable to the type specified at construction time. * * @param element the object to check, or {@code null}. * @return {@code true} if the instance is valid, {@code false} if it shall be ignored. * @throws NullPointerException if the given element is {@code null}. * @throws ClassCastException if the given element is not of the expected type. */ private boolean ensureValid(final E element) { if (type.isInstance(element)) { return true; } final String message = illegalElement(this, element, type); if (message == null) { /* * If a unmarshalling process is under way, silently discard null element. * This case happen when a XML element for a collection contains no child. * See https://issues.apache.org/jira/browse/SIS-139 */ return false; } if (element == null) { throw new NullArgumentException(message); } else { throw new ClassCastException(message); } }
/** * Adds the specified element to this set if it is not already present. * * @param element element to be added to this set. * @return {@code true} if the set did not already contain the specified element. * @throws IllegalArgumentException if the specified element is not of the expected type. */ @Override public boolean add(final E element) throws IllegalArgumentException { if (type.isInstance(element)) { return super.add(element); } final String message = CheckedArrayList.illegalElement(this, element, type); if (message == null) { /* * If a unmarshalling process is under way, silently discard null element. * This case happen when a XML element for a collection contains no child. * See https://issues.apache.org/jira/browse/SIS-139 */ return false; } if (element == null) { throw new NullArgumentException(message); } else { throw new IllegalArgumentException(message); } }
public boolean add(final E element) { if (element == null) { final String message = CheckedArrayList.illegalElement(this, element, elementType); if (message == null) {
public boolean add(final E element) { if (element == null) { final String message = CheckedArrayList.illegalElement(this, element, elementType); if (message == null) {