/** * Forward the call to the {@linkplain MatrixParameterDescriptors matrix parameter descriptors} * specified at construction time. */ public int getMaximumOccurs() { return descriptor.getMaximumOccurs(); }
if (count >= check.getMaximumOccurs()) { throw new InvalidParameterCardinalityException( Errors.format(ErrorKeys.TOO_MANY_OCCURENCES_$2, name, count), name);
final int count = entry.getValue()[0]; final int min = descriptor.getMinimumOccurs(); final int max = descriptor.getMaximumOccurs(); if (!(count >= min && count <= max)) { final String name = getName(descriptor);
/** * Remove the value at the specified index. * * @param type The descriptor of the value to remove. * @param index The index of the value to remove. */ private GeneralParameterValue remove(final GeneralParameterDescriptor type, final int index) { modCount++; int count = 0; final String name = type.getName().getCode(); for (final GeneralParameterValue value : values) { if (AbstractIdentifiedObject.nameMatches(value.getDescriptor(), name)) { count++; } } final int min = type.getMinimumOccurs(); if (count <= min) { final int max = type.getMaximumOccurs(); throw new InvalidParameterCardinalityException( Errors.format( ErrorKeys.ILLEGAL_OCCURS_FOR_PARAMETER_$4, name, count - 1, min, max), name); } final GeneralParameterValue value = values.remove(index); assert value != null && type.equals(value.getDescriptor()) : value; return value; } }
Errors.format(ErrorKeys.ILLEGAL_ARGUMENT_$2, name, value), name); final int max = type.getMaximumOccurs(); if (max == 1) {
/** * Constructs a new parameter descriptor with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one or a * user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param descriptor the object to shallow copy. */ protected AbstractParameterDescriptor(final GeneralParameterDescriptor descriptor) { super(descriptor); minimumOccurs = crop(descriptor.getMinimumOccurs()); maximumOccurs = crop(descriptor.getMaximumOccurs()); }
/** * Constructs a new parameter descriptor with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one or a * user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param descriptor the object to shallow copy. */ protected AbstractParameterDescriptor(final GeneralParameterDescriptor descriptor) { super(descriptor); minimumOccurs = crop(descriptor.getMinimumOccurs()); maximumOccurs = crop(descriptor.getMaximumOccurs()); }
/** * Compares the specified object with this parameter for equality. * * @return {@inheritDoc} */ @Override public boolean equals(final Object object, final ComparisonMode mode) { if (super.equals(object, mode)) { switch (mode) { case STRICT: { final AbstractParameterDescriptor that = (AbstractParameterDescriptor) object; return minimumOccurs == that.minimumOccurs && maximumOccurs == that.maximumOccurs; } default: { final GeneralParameterDescriptor that = (GeneralParameterDescriptor) object; return getMinimumOccurs() == that.getMinimumOccurs() && getMaximumOccurs() == that.getMaximumOccurs(); } } } return false; }
/** * Verifies if adding a parameter with the given descriptor is allowed by the cardinality constraints. If adding * the parameter would result in more occurrences than {@link DefaultParameterDescriptor#getMaximumOccurs()}, * then this method throws an {@link InvalidParameterCardinalityException}. */ private void ensureCanAdd(final GeneralParameterDescriptor desc) { final Identifier name = desc.getName(); int count = 0; for (int i=0; i<size; i++) { if (name.equals(values[i].getDescriptor().getName())) { count++; } } final int max = desc.getMaximumOccurs(); if (count >= max) { throw new InvalidParameterCardinalityException(Errors.format( Errors.Keys.TooManyOccurrences_2, max, name), name.getCode()); } }
/** * Verifies if adding a parameter with the given descriptor is allowed by the cardinality constraints. If adding * the parameter would result in more occurrences than {@link DefaultParameterDescriptor#getMaximumOccurs()}, * then this method throws an {@link InvalidParameterCardinalityException}. */ private void ensureCanAdd(final GeneralParameterDescriptor desc) { final Identifier name = desc.getName(); int count = 0; for (int i=0; i<size; i++) { if (name.equals(values[i].getDescriptor().getName())) { count++; } } final int max = desc.getMaximumOccurs(); if (count >= max) { throw new InvalidParameterCardinalityException(Errors.format( Errors.Keys.TooManyOccurrences_2, max, name), name.getCode()); } }
/** * Compares the specified object with this parameter for equality. * * @return {@inheritDoc} */ @Override public boolean equals(final Object object, final ComparisonMode mode) { if (super.equals(object, mode)) { switch (mode) { case STRICT: { final AbstractParameterDescriptor that = (AbstractParameterDescriptor) object; return minimumOccurs == that.minimumOccurs && maximumOccurs == that.maximumOccurs; } default: { final GeneralParameterDescriptor that = (GeneralParameterDescriptor) object; return getMinimumOccurs() == that.getMinimumOccurs() && getMaximumOccurs() == that.getMaximumOccurs(); } } } return false; }
final int count = entry.getValue(); final int min = descriptor.getMinimumOccurs(); final int max = descriptor.getMaximumOccurs(); if (!(count>=min && count<=max)) { final String name = getName(descriptor);
/** * Removes the value at the specified index. * * @param type The descriptor of the value to remove. * @param index The index of the value to remove. */ private GeneralParameterValue remove(final GeneralParameterDescriptor type, final int index) { modCount++; int count = 0; final String name = type.getName().getCode(); for (final GeneralParameterValue value : values) { if (IdentifiedObjects.isHeuristicMatchForName(value.getDescriptor(), name)) { count++; } } final int min = type.getMinimumOccurs(); if (count <= min) { final int max = type.getMaximumOccurs(); throw new InvalidParameterCardinalityException(Errors.format( Errors.Keys.IllegalOccursForParameter_4, name, count-1, min, max), name); } final GeneralParameterValue value = values.remove(index); assert value!=null && type.equals(value.getDescriptor()) : value; return value; } }
if (count >= check.getMaximumOccurs()) { throw new InvalidParameterCardinalityException(Errors.format( Errors.Keys.TooManyOccurrences_2, name, count), name);
/** * Validates the test parameter descriptors given by {@link #M1_M1_O1_O2}. */ @Test public void validateTestObjects() { for (final GeneralParameterDescriptor descriptor : M1_M1_O1_O2.descriptors()) { AssertionError error = null; try { validate(descriptor); } catch (AssertionError e) { error = e; } if (descriptor.getMaximumOccurs() > 1) { assertNotNull("Validation methods should have detected that the descriptor is invalid.", error); } else if (error != null) { throw error; } } }
final int max = desc.getMaximumOccurs(); if (count >= max) { throw new InvalidParameterCardinalityException(Errors.format(
final int max = desc.getMaximumOccurs(); if (count >= max) { throw new InvalidParameterCardinalityException(Errors.format(
/** * Verifies that the given parameter descriptor has the expected EPSG code, name and OGC alias. * * @param code the expected EPSG code. * @param name the expected EPSG name. * @param alias the expected OGC alias. * @param required {@code true} if the parameter should be mandatory, or {@code false} if optional. * @param descriptor the parameter descriptor to verify. */ private static void verifyDescriptor(final int code, final String name, final String alias, final boolean required, final GeneralParameterDescriptor descriptor) { assertEpsgNameAndIdentifierEqual(name, code, descriptor); assertAliasTipEquals(alias, descriptor); assertEquals("maximumOccurs", 1, descriptor.getMaximumOccurs()); assertEquals("minimumOccurs", required ? 1 : 0, descriptor.getMinimumOccurs()); }
if (!(descriptor instanceof ParameterDescriptor<?>) || descriptor.getMaximumOccurs() == 0) { throw new ParameterNotFoundException(Resources.format(Resources.Keys.ParameterNotFound_2, Verifier.getDisplayName(values.descriptor), name), name);
/** * Verifies the properties of the given member of a {@link DefaultParameterDescriptorGroup}. */ private static void verifyParameter(final GeneralParameterDescriptor complete, final GeneralParameterDescriptor merged, final boolean same, final String remarks) { assertEquals("same", same, merged == complete); assertSame ("name", complete.getName(), merged.getName()); assertEquals("minimumOccurs", 0, merged.getMinimumOccurs()); assertEquals("maximumOccurs", 1, merged.getMaximumOccurs()); assertEquals("valueClass", Integer.class, ((ParameterDescriptor<?>) merged).getValueClass()); assertEquals("remarks", remarks, (remarks == null) ? null : merged.getRemarks().toString()); } }