Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand All @@ -40,6 +39,13 @@
import org.eclipse.xsd.XSDTypeDefinition;
import org.eclipse.xsd.util.XSDConstants;
import org.eclipse.xsd.util.XSDUtil;
import org.geotools.api.feature.type.AttributeDescriptor;
import org.geotools.api.feature.type.AttributeType;
import org.geotools.api.feature.type.ComplexType;
import org.geotools.api.feature.type.FeatureTypeFactory;
import org.geotools.api.feature.type.Name;
import org.geotools.api.feature.type.PropertyDescriptor;
import org.geotools.api.feature.type.Schema;
import org.geotools.feature.NameImpl;
import org.geotools.feature.type.FeatureTypeFactoryImpl;
import org.geotools.feature.type.SchemaImpl;
Expand All @@ -54,16 +60,8 @@
import org.geotools.graph.util.graph.CycleDetector;
import org.geotools.graph.util.graph.DirectedCycleDetector;
import org.geotools.util.Utilities;
import org.geotools.xsd.Schemas;
import org.geotools.xs.XS;
import org.geotools.api.feature.Attribute;
import org.geotools.api.feature.type.AttributeDescriptor;
import org.geotools.api.feature.type.AttributeType;
import org.geotools.api.feature.type.ComplexType;
import org.geotools.api.feature.type.FeatureTypeFactory;
import org.geotools.api.feature.type.Name;
import org.geotools.api.feature.type.PropertyDescriptor;
import org.geotools.api.feature.type.Schema;
import org.geotools.xsd.Schemas;

/**
* Parses an XML schema to procuce an instance of
Expand Down Expand Up @@ -313,9 +311,8 @@ public Collection<Schema> getImports() {
public XSDTypeDefinition getXSDType(AttributeType type) {
for (Entry<XSDTypeDefinition, AttributeType> xsdTypeDefinitionAttributeTypeEntry :
types.entrySet()) {
Entry entry = xsdTypeDefinitionAttributeTypeEntry;
XSDTypeDefinition xsdType = (XSDTypeDefinition) entry.getKey();
AttributeType gtType = (AttributeType) entry.getValue();
XSDTypeDefinition xsdType = xsdTypeDefinitionAttributeTypeEntry.getKey();
AttributeType gtType = xsdTypeDefinitionAttributeTypeEntry.getValue();

if (gtType.equals(type)) {
return xsdType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,7 @@ public String generate(Object argument)
if (!type.getUserData().isEmpty()) {
//attributes
for (Map.Entry<Object, Object> objectObjectEntry : type.getUserData().entrySet()) {
Map.Entry entry = objectObjectEntry;
Name n = (Name) entry.getKey();
PropertyDescriptor pd = (PropertyDescriptor) entry.getValue();
PropertyDescriptor pd = (PropertyDescriptor) objectObjectEntry.getValue();
PropertyType pdType = pd.getType();

String pdTypeName = pdType.getName().getLocalPart().toUpperCase() +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@ public void testParseBoreholeSchema() throws Exception {
expectedNamesAndTypes.put(name(XMMLNS, "log"), typeName(XMMLNS, "LogPropertyType"));

for (Entry<Name, Name> nameNameEntry : expectedNamesAndTypes.entrySet()) {
Entry entry = nameNameEntry;
Name dName = (Name) entry.getKey();
Name tName = (Name) entry.getValue();
Name dName = nameNameEntry.getKey();
Name tName = nameNameEntry.getValue();

AttributeDescriptor d = (AttributeDescriptor) Types.descriptor(borehole, dName);
assertNotNull("Descriptor not found: " + dName, d);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,8 @@ private void createFoundationTypes() {

protected void importSchema(Schema schema) {
for (Entry<Name, AttributeType> nameAttributeTypeEntry : schema.entrySet()) {
Entry entry = nameAttributeTypeEntry;
Name key = (Name) entry.getKey();
Object value = entry.getValue();
Name key = nameAttributeTypeEntry.getKey();
Object value = nameAttributeTypeEntry.getValue();
if (typeRegistry.containsKey(key)) {
LOGGER.finer("Ignoring "
+ key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public MBLayer layer(String id) {
public List<MBLayer> layers() {
JSONArray layers = parse.getJSONArray(json, "layers");
List<MBLayer> layersList = new ArrayList<>();
@SuppressWarnings("PMD.UnusedLocalVariable")
int labelPriority = 0;
for (Object obj : layers) {
if (obj instanceof JSONObject) {
Expand All @@ -156,7 +155,8 @@ public List<MBLayer> layers() {
}
// adjust label priority so that the labels of the last layer are painted first
if (mbLayer instanceof SymbolMBLayer) {
((SymbolMBLayer) mbLayer).setLabelPriority(labelPriority += DEFAULT_LABEL_PRIORITY);
labelPriority += DEFAULT_LABEL_PRIORITY;
((SymbolMBLayer) mbLayer).setLabelPriority(labelPriority);
}
layersList.add(mbLayer);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ public XSDNamedComponent getDeclaration() {
// atomic

// walk through the facets and preparse as necessary
for (org.eclipse.xsd.XSDConstrainingFacet xsdConstrainingFacet : type.getFacets()) {
XSDFacet facet = xsdConstrainingFacet;
for (org.eclipse.xsd.XSDConstrainingFacet facet : type.getFacets()) {

if (facet instanceof XSDWhiteSpaceFacet && !parser.isCDATA()) {
XSDWhiteSpaceFacet whitespace = (XSDWhiteSpaceFacet) facet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,14 @@ protected Binding binding(QName name) {
throw new RuntimeException(e);
}

for (Map.Entry<String, String> stringStringEntry : mappings.entrySet()) {
Map.Entry mapping = stringStringEntry;
String key = (String) mapping.getKey();
for (Map.Entry<String, String> mapping : mappings.entrySet()) {
String key = mapping.getKey();

if (key == null) {
key = "";
}

namespaces.declarePrefix(key, (String) mapping.getValue());
namespaces.declarePrefix(key, mapping.getValue());
}

context.registerComponentInstance(namespaces);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,21 +665,15 @@ public BinarySpatialOperator buildSpatialEqualFilter() throws CQLException {

Expression property = this.resultStack.popExpression();

FilterFactory ff = filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation

return ff.equal(property, geom);
return filterFactory.equal(property, geom);
}

public BinarySpatialOperator buildSpatialDisjointFilter() throws CQLException {
Literal geom = this.resultStack.popLiteral();

Expression property = this.resultStack.popExpression();

FilterFactory ff = filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation

return ff.disjoint(property, geom);
return filterFactory.disjoint(property, geom);
}

public BinarySpatialOperator buildSpatialIntersectsFilter() throws CQLException {
Expand All @@ -688,10 +682,7 @@ public BinarySpatialOperator buildSpatialIntersectsFilter() throws CQLException

Expression property = this.resultStack.popExpression();

FilterFactory ff = filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation

return ff.intersects(property, geom);
return filterFactory.intersects(property, geom);
}

public PropertyIsEqualTo buildSpatialRelateFilter() throws CQLException {
Expand Down Expand Up @@ -726,21 +717,15 @@ public BinarySpatialOperator buildSpatialTouchesFilter() throws CQLException {

Expression property = this.resultStack.popExpression();

FilterFactory ff = filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation

return ff.touches(property, geom);
return filterFactory.touches(property, geom);
}

public BinarySpatialOperator buildSpatialCrossesFilter() throws CQLException {
Literal geom = this.resultStack.popLiteral();

Expression property = this.resultStack.popExpression();

FilterFactory ff = filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation

return ff.crosses(property, geom);
return filterFactory.crosses(property, geom);
}

public BinarySpatialOperator buildSpatialWithinFilter() throws CQLException {
Expand All @@ -749,10 +734,7 @@ public BinarySpatialOperator buildSpatialWithinFilter() throws CQLException {

Expression property = this.resultStack.popExpression();

FilterFactory ff = filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation

return ff.within(property, geom);
return filterFactory.within(property, geom);
}

public BinarySpatialOperator buildSpatialContainsFilter() throws CQLException {
Expand All @@ -761,10 +743,7 @@ public BinarySpatialOperator buildSpatialContainsFilter() throws CQLException {

Expression property = this.resultStack.popExpression();

FilterFactory ff = filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation

return ff.contains(property, geom);
return filterFactory.contains(property, geom);
}

public BinarySpatialOperator buildSpatialOverlapsFilter() throws CQLException {
Expand All @@ -773,10 +752,7 @@ public BinarySpatialOperator buildSpatialOverlapsFilter() throws CQLException {

Expression property = this.resultStack.popExpression();

FilterFactory ff = filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation

return ff.overlaps(property, geom);
return filterFactory.overlaps(property, geom);
}

public Filter buildBBox() throws CQLException {
Expand Down Expand Up @@ -816,10 +792,7 @@ public DistanceBufferOperator buildSpatialDWithinFilter() throws CQLException {

Expression property = this.resultStack.popExpression();

FilterFactory ff = filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation

return ff.dwithin(property, geom, tolerance, unit);
return filterFactory.dwithin(property, geom, tolerance, unit);
}

public DistanceBufferOperator buildSpatialBeyondFilter() throws CQLException {
Expand All @@ -832,10 +805,7 @@ public DistanceBufferOperator buildSpatialBeyondFilter() throws CQLException {

Expression property = this.resultStack.popExpression();

FilterFactory ff = filterFactory; // TODO this cast must be removed. It depends of Geometry
// implementation

return ff.beyond(property, geom, tolerance, unit);
return filterFactory.beyond(property, geom, tolerance, unit);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,10 @@ public static Object duplicate(Object src) {

if (src instanceof Map) {
@SuppressWarnings("unchecked")
Map<Object, Object> map = (Map) src;
Map<Object, Object> map = (Map<Object, Object>) src;
Map<Object, Object> copy = new HashMap<>(map.size());

for (Map.Entry<Object, Object> objectObjectEntry : map.entrySet()) {
Map.Entry entry = objectObjectEntry;
for (Map.Entry<Object, Object> entry : map.entrySet()) {
copy.put(entry.getKey(), duplicate(entry.getValue()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ protected void fireChange(SimpleFeature feature, int type) {
}

protected void fireChange(Collection coll, int type) {
@SuppressWarnings({"unchecked", "PMD.UnnecessaryCast"})
SimpleFeature[] features = (SimpleFeature[]) coll.toArray(n -> new SimpleFeature[n]);
@SuppressWarnings("unchecked")
Collection<SimpleFeature> fcoll = coll;
SimpleFeature[] features = fcoll.toArray(SimpleFeature[]::new);
fireChange(features, type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,35 +156,23 @@ public Set toSet() {
}

@Override
public List toList() {
@SuppressWarnings("unchecked")
public List<Object> toList() {
Object value = getValue();

if (value == null) {
return null;
}

if (value instanceof List) {
List list = (List) value;

return list;
return (List<Object>) value;
}

if (value.getClass().isArray()) {
return Arrays.asList((Object[]) value);
}

if (value instanceof HashSet) {
Set set = (HashSet) value;
// Object[] values = set.toArray();
return Arrays.asList(set.toArray());
// List list = new ArrayList();
// for (int i = 0; i < values.length; i++)
// list.add(values[i]);
// return list;
}

if (value instanceof Collection) {
@SuppressWarnings("unchecked")
Collection<Object> cast = (Collection<Object>) value;
return new ArrayList<>(cast);
}
Expand All @@ -194,7 +182,7 @@ public List toList() {

@Override
public Object[] toArray() {
List list = toList();
List<Object> list = toList();

if (list == null) {
return null;
Expand All @@ -203,15 +191,14 @@ public Object[] toArray() {
return list.toArray();
}

@SuppressWarnings("unchecked")
public String[] toStringArray() {
List<Object> list = toList();

if (list == null) {
return null;
}

return list.stream().map(o -> o != null ? String.valueOf(o) : null).toArray(n -> new String[n]);
return list.stream().map(o -> o != null ? String.valueOf(o) : null).toArray(String[]::new);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private RangedClassifier calculateNonNumerical(int classNum, FeatureCollection<?
// sort the results and put them in an array
Collections.sort(result);

Comparable[] values = result.toArray(new Comparable[result.size()]);
Comparable[] values = result.toArray(Comparable[]::new);

// size arrays
classNum = Math.min(classNum, values.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,9 @@ public void setSchema(String schema) {
@Override
protected String adaptSQL(final String statement) {
final StringBuilder modified = new StringBuilder(statement);
for (Map.Entry<String, String> stringStringEntry : map.entrySet()) {
final Map.Entry entry = stringStringEntry;
final String oldName = (String) entry.getKey();
final String newName = (String) entry.getValue();
for (Map.Entry<String, String> entry : map.entrySet()) {
final String oldName = entry.getKey();
final String newName = entry.getValue();
/*
* Replaces all occurences of 'oldName' by 'newName'.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,10 @@ public Citation getAuthority() {
public Set<String> getAuthorityCodes(final Class<? extends IdentifiedObject> type) throws FactoryException {
ensureInitialized();
final Set<String> set = new LinkedHashSet<>();
for (Map.Entry<Integer, CoordinateReferenceSystem> integerCoordinateReferenceSystemEntry : crsMap.entrySet()) {
final Map.Entry entry = integerCoordinateReferenceSystemEntry;
final CoordinateReferenceSystem crs = (CoordinateReferenceSystem) entry.getValue();
for (Map.Entry<Integer, CoordinateReferenceSystem> entry : crsMap.entrySet()) {
final CoordinateReferenceSystem crs = entry.getValue();
if (type.isAssignableFrom(crs.getClass())) {
final Integer code = (Integer) entry.getKey();
final Integer code = entry.getKey();
set.add(String.valueOf(code));
}
}
Expand Down
Loading