use of org.apache.sis.parameter.DefaultParameterDescriptorGroup in project sis by apache.
the class CC_OperationMethod method group.
/**
* Wraps the given descriptors in a descriptor group of the given name. If the given name can be matched
* to the name of one of the predefined operation method, then the predefined parameters will be used.
*
* <p>We try to use predefined parameters if possible because they contain information, especially the
* {@link org.opengis.parameter.ParameterDescriptor#getValueClass()} property, which are not available
* in the GML document.</p>
*
* <div class="note"><b>Note:</b>
* this code is defined in this {@code CC_OperationMethod} class instead than in the
* {@link DefaultOperationMethod} class in the hope to reduce the amount of code processed
* by the JVM in the common case where JAXB (un)marshalling is not needed.</div>
*
* @param name the operation method name, to be also given to the descriptor group.
* @param descriptors the parameter descriptors to wrap in a group. This array will be modified in-place.
* @return a parameter group containing at least the given descriptors, or equivalent descriptors.
*/
public static ParameterDescriptorGroup group(final Identifier name, final GeneralParameterDescriptor[] descriptors) {
OperationMethod method;
try {
method = CoordinateOperations.factory().getOperationMethod(name.getCode());
} catch (FactoryException e) {
// Use DefaultOperationMethod as the source class because it is the first public class in callers.
Context.warningOccured(Context.current(), DefaultOperationMethod.class, "setDescriptors", e, true);
method = null;
}
final Map<String, ?> properties = Collections.singletonMap(ParameterDescriptorGroup.NAME_KEY, name);
if (method != null) {
/*
* Verify that the pre-defined operation method contains at least all the parameters specified by
* the 'descriptors' array. If this is the case, then the pre-defined parameters will be used in
* replacement of the given ones.
*/
final ParameterDescriptorGroup parameters = method.getParameters();
return CC_GeneralOperationParameter.merge(DefaultOperationMethod.class, properties, IdentifiedObjects.getProperties(parameters), 1, 1, descriptors, parameters, true);
}
return new DefaultParameterDescriptorGroup(properties, 1, 1, descriptors);
}
Aggregations