Java Code Examples for org.opengis.parameter.ParameterDescriptor#getValueClass()
The following examples show how to use
org.opengis.parameter.ParameterDescriptor#getValueClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceParameter.java From sis with Apache License 2.0 | 6 votes |
/** * Gets the parameter name as a {@code MemberName}. This method first checks if the primary name is an instance of * {@code MemberName}. If not, this method searches for the first alias which is an instance of {@code MemberName}. * If none is found, then this method tries to build a member name from the primary name and value class. * * @param parameter the parameter from which to get the name (may be {@code null}). * @return the member name, or {@code null} if none. */ public static MemberName getMemberName(final ParameterDescriptor<?> parameter) { if (parameter != null) { final ReferenceIdentifier id = parameter.getName(); if (id instanceof MemberName) { return (MemberName) id; } for (final GenericName alias : nonNull(parameter.getAlias())) { if (alias instanceof MemberName) { return (MemberName) alias; } } if (id != null) { final Class<?> valueClass = parameter.getValueClass(); if (valueClass != null) { final String code = id.getCode(); if (code != null) { return Names.createMemberName(id.getCodeSpace(), null, code, valueClass); } } } } return null; }
Example 2
Source File: ServiceParameter.java From sis with Apache License 2.0 | 6 votes |
/** * Compares this object with the given one for equality. * * @param object the object to compare with this reference system. * @param mode the strictness level of the comparison. * @return {@code true} if both objects are equal. */ @Override public boolean equals(final Object object, final ComparisonMode mode) { if (object == this) { return true; } if (super.equals(object, mode) && object instanceof ParameterDescriptor<?>) { final ParameterDescriptor<?> that = (ParameterDescriptor<?>) object; if (that.getUnit() == null && that.getDefaultValue() == null && that.getValueClass() == getValueClass()) { if (mode.isIgnoringMetadata()) { return Objects.equals(toString(getName()), toString(that.getName())); // super.equals(…) already compared 'getName()' in others mode. } return that.getMinimumOccurs() == getMinimumOccurs() && that.getMaximumOccurs() == getMaximumOccurs() && that.getValidValues() == null && that.getMinimumValue() == null && that.getMaximumValue() == null; } } return false; }
Example 3
Source File: CC_GeneralOperationParameter.java From sis with Apache License 2.0 | 6 votes |
/** * Creates a new descriptor with the same properties than the {@code provided} one, but completed with * information not found in GML. Those extra information are given by the {@code complete} descriptor. * * <p>It is the caller's responsibility to construct the {@code merged} properties as a merge of the properties * of the two given descriptors. This can be done with the help of {@link #mergeArrays(String, Class, Collection, * Map, Identifier)} among others.</p> */ private static <T> ParameterDescriptor<T> create(final Map<String,?> merged, final ParameterDescriptor<?> provided, final ParameterDescriptor<T> complete) { final Class<T> valueClass = complete.getValueClass(); return new DefaultParameterDescriptor<>(merged, provided.getMinimumOccurs(), provided.getMaximumOccurs(), // Values below this point are not provided in GML documents, // so they must be inferred from the pre-defined descriptor. valueClass, Parameters.getValueDomain(complete), CollectionsExt.toArray(complete.getValidValues(), valueClass), complete.getDefaultValue()); }
Example 4
Source File: CustomCrsPanel.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private static PropertyContainer createValueContainer(ParameterValueGroup valueGroup) { final PropertyContainer vc = new PropertyContainer(); List<GeneralParameterDescriptor> descriptors = valueGroup.getDescriptor().descriptors(); for (GeneralParameterDescriptor descriptor : descriptors) { final Class valueType; Set validValues = null; Comparable minValue = null; Comparable maxValue = null; if (descriptor instanceof ParameterDescriptor) { ParameterDescriptor parameterDescriptor = (ParameterDescriptor) descriptor; valueType = parameterDescriptor.getValueClass(); validValues = parameterDescriptor.getValidValues(); minValue = parameterDescriptor.getMinimumValue(); maxValue = parameterDescriptor.getMaximumValue(); } else { valueType = Double.TYPE; } final String paramName = descriptor.getName().getCode(); final PropertyDescriptor vd = new PropertyDescriptor(paramName, valueType); final ParameterValue<?> parameterValue = valueGroup.parameter(paramName); if (parameterValue.getUnit() != null) { vd.setUnit(String.valueOf(parameterValue.getUnit())); } if (validValues != null) { vd.setValueSet(new ValueSet(validValues.toArray())); } if ( minValue instanceof Double && maxValue instanceof Double) { Double min = (Double) minValue; Double max = (Double) maxValue; vd.setValueRange(new ValueRange(min, max)); if(parameterValue.getValue() == null) { parameterValue.setValue((min + max) / 2); } } vd.setDefaultConverter(); final Property property = new Property(vd, new PropertyAccessor() { @Override public Object getValue() { return parameterValue.getValue(); } @Override public void setValue(Object value) { parameterValue.setValue(value); } }); vc.addProperty(property); } return vc; }
Example 5
Source File: DefaultParameterDescriptor.java From sis with Apache License 2.0 | 3 votes |
/** * Creates a new 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 descriptor to shallow copy. * * @see #castOrCopy(ParameterDescriptor) */ @SuppressWarnings("unchecked") protected DefaultParameterDescriptor(final ParameterDescriptor<T> descriptor) { super(descriptor); valueClass = descriptor.getValueClass(); validValues = descriptor.getValidValues(); defaultValue = descriptor.getDefaultValue(); valueDomain = Parameters.getValueDomain(descriptor); }