Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial cleanup in helpers and custom collections, #1301

Merged
merged 2 commits into from
Sep 16, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .lgtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ path_classifiers:
- "license.html"
- "readme.html"

#########################################################################################
# Use the `queries` block to change the default display of query results. #
#########################################################################################

queries:
- include: "*"
# "by design" - synch is being removed intentionally
- exclude: java/non-sync-override

extraction:
java:
index:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,6 @@ public void getAllEmployees() {
comparer.isNodeEqual(controlDoc, doc));
}

@SuppressWarnings("unchecked")
@Test
public void buildEmployees() {
XMLUnmarshaller unMarshaller = xrService.getXMLContext().createUnmarshaller();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -33,8 +33,8 @@ public class RelationshipsEmployee {
public String gender;
public BigDecimal salary;
public RelationshipsAddress address;
public Collection<RelationshipsPhone> phones = new ArrayList<RelationshipsPhone>();
public Collection<String> responsibilities = new ArrayList<String>();
public Collection<RelationshipsPhone> phones = new ArrayList<>();
public Collection<String> responsibilities = new ArrayList<>();

public RelationshipsEmployee() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class XRDynamicEntityTestSuite {
@BeforeClass
public static void setUp() throws NoSuchFieldException, IllegalArgumentException,
IllegalAccessException {
Set<String> propertyNames = new HashSet<String>();
Set<String> propertyNames = new HashSet<>();
propertyNames.add(FIELD_1);
propertyNames.add(FIELD_2);
XRCustomer.DPM.setPropertyNames(propertyNames);
Expand Down Expand Up @@ -95,7 +95,7 @@ public void buildTestEntity() throws ReflectiveOperationException {
(Class<XRDynamicEntity>)xrdcl.createDynamicClass(TEST_CLASSNAME);
XRDynamicEntity newInstance = testClass.getConstructor().newInstance();
XRDynamicPropertiesManager xrDPM = newInstance.fetchPropertiesManager();
Set<String> propertyNames = new HashSet<String>();
Set<String> propertyNames = new HashSet<>();
propertyNames.add(FIELD_1);
propertyNames.add(FIELD_2);
xrDPM.setPropertyNames(propertyNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected InputStream initXRServiceStream(ClassLoader parentClassLoader,
}

protected InputStream initXRSchemaStream(ClassLoader parentClassLoader, ServletContext sc) {
InputStream xrSchemaStream = null;
InputStream xrSchemaStream;
String path = WSDL_DIR + DBWS_SCHEMA_XML;
if (sc != null) {
path = "/" + WEB_INF_DIR + path;
Expand All @@ -200,7 +200,7 @@ protected InputStream initXRSchemaStream(ClassLoader parentClassLoader, ServletC
}

protected InputStream initWSDLInputStream(ClassLoader parentClassLoader, ServletContext sc) {
InputStream wsdlInputStream = null;
InputStream wsdlInputStream;
String path = WSDL_DIR + DBWS_WSDL;
if (sc != null) {
path = "/" + WEB_INF_DIR + path;
Expand Down Expand Up @@ -430,11 +430,11 @@ public SOAPMessage invoke(SOAPMessage request) {
if (mtomEnabled) {
attachments = (Map<String, DataHandler>)mc.get(INBOUND_MESSAGE_ATTACHMENTS);
}
SOAPMessage response = null;
boolean usesSOAP12 = false;
SOAPMessage response;
boolean usesSOAP12;
DBWSAdapter dbwsAdapter = (DBWSAdapter)xrService;

SOAPEnvelope envelope = null;
SOAPEnvelope envelope;
try {
envelope = request.getSOAPPart().getEnvelope();
}
Expand All @@ -454,15 +454,15 @@ public SOAPMessage invoke(SOAPMessage request) {
}

if (body == null) {
SOAPFault soapFault = null;
SOAPFault soapFault;
try {
SOAPFactory soapFactory = null;
SOAPFactory soapFactory;
if (usesSOAP12) {
soapFactory = SOAPFactory.newInstance(SOAP_1_2_PROTOCOL);
} else {
soapFactory = SOAPFactory.newInstance();
}
QName faultCodeQName = null;
QName faultCodeQName;
if (usesSOAP12) {
faultCodeQName = SENDER_QNAME;
} else {
Expand All @@ -475,7 +475,7 @@ public SOAPMessage invoke(SOAPMessage request) {
throw new SOAPFaultException(soapFault);
}

XMLRoot xmlRoot = null;
XMLRoot xmlRoot;
try {
XMLContext xmlContext = dbwsAdapter.getXMLContext();
XMLUnmarshaller unmarshaller = xmlContext.createUnmarshaller();
Expand Down Expand Up @@ -529,15 +529,15 @@ public byte[] getAttachmentAsByteArray(String id) {
xmlRoot = (XMLRoot)unmarshaller.unmarshal(body, Invocation.class);
}
catch (Exception e) {
SOAPFault soapFault = null;
SOAPFault soapFault;
try {
SOAPFactory soapFactory = null;
SOAPFactory soapFactory;
if (usesSOAP12) {
soapFactory = SOAPFactory.newInstance(SOAP_1_2_PROTOCOL);
} else {
soapFactory = SOAPFactory.newInstance();
}
QName faultCodeQName = null;
QName faultCodeQName;
if (usesSOAP12) {
faultCodeQName = SENDER_QNAME;
} else {
Expand Down Expand Up @@ -606,7 +606,7 @@ public byte[] getAttachmentAsByteArray(String id) {
// incoming attachments ?
}
}
Object result = null;
Object result;
try {
result = op.invoke(dbwsAdapter, invocation);
if (result instanceof ValueObject) {
Expand All @@ -622,15 +622,15 @@ public byte[] getAttachmentAsByteArray(String id) {
response = responseWriter.generateResponse(op, usesSOAP12, e);
}
catch (SOAPException soape1) {
SOAPFault soapFault = null;
SOAPFault soapFault;
try {
SOAPFactory soapFactory = null;
SOAPFactory soapFactory;
if (usesSOAP12) {
soapFactory = SOAPFactory.newInstance(SOAP_1_2_PROTOCOL);
} else {
soapFactory = SOAPFactory.newInstance();
}
QName faultCodeQName = null;
QName faultCodeQName;
if (usesSOAP12) {
faultCodeQName = RECEIVER_QNAME;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -37,7 +37,7 @@
public class SOAPAttachmentHandler implements XMLAttachmentMarshaller {

private int count = 0;
private HashMap<String, DataHandler> attachments = new HashMap<String,DataHandler>();
private HashMap<String, DataHandler> attachments = new HashMap<>();

public boolean hasAttachments() {
return attachments.size() > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
public class SOAPResponseWriter {

protected DBWSAdapter dbwsAdapter;
protected Map<String, XMLDescriptor> resultDescriptors = new HashMap<String, XMLDescriptor>();
protected Map<String, XMLDescriptor> resultDescriptors = new HashMap<>();
public static final QName RECEIVER_QNAME = new QName(URI_NS_SOAP_1_2_ENVELOPE, "Receiver");
public static final QName SERVER_QNAME = new QName(URI_NS_SOAP_1_1_ENVELOPE, "Server");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -26,9 +26,9 @@ public class Descriptor {

protected String name = null;
protected String type = null;
protected List<LinkTemplate> linkTemplates = new ArrayList<LinkTemplate>();
protected List<Attribute> attributes = new ArrayList<Attribute>();
protected List<Query> queries = new ArrayList<Query>();
protected List<LinkTemplate> linkTemplates = new ArrayList<>();
protected List<Attribute> attributes = new ArrayList<>();
protected List<Query> queries = new ArrayList<>();

public String getName() {
return name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -43,7 +43,7 @@ public List<LinkV2> getLinks() {
*/
public void setLinks(List<LinkV2> links) {
if (this.links == null) {
this.links = new ArrayList<LinkV2>();
this.links = new ArrayList<>();
}

this.links = links;
Expand All @@ -56,7 +56,7 @@ public void setLinks(List<LinkV2> links) {
*/
public void addLink(LinkV2 link) {
if (this.links == null) {
this.links = new ArrayList<LinkV2>();
this.links = new ArrayList<>();
}

this.links.add(link);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -25,7 +25,7 @@
public class PersistenceUnit {

protected String persistenceUnitName = null;
protected List<Link> types = new ArrayList<Link>();
protected List<Link> types = new ArrayList<>();

public String getPersistenceUnitName() {
return persistenceUnitName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -26,7 +26,7 @@ public class Query {
protected String queryName;
protected String jpql;
protected LinkTemplate linkTemplate;
protected List<String> returnTypes = new ArrayList<String>();
protected List<String> returnTypes = new ArrayList<>();

public Query() {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -27,7 +27,7 @@ public class SessionBeanCall {
private String jndiName = null;
private String methodName = null;
private String context = null;
private List<Parameter> parameters = new ArrayList<Parameter>();
private List<Parameter> parameters = new ArrayList<>();

public String getContext() {
return context;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -45,7 +45,7 @@ public void setItems(List<Resource> items) {
*/
public void addContext(Resource context) {
if (items == null) {
items = new ArrayList<Resource>();
items = new ArrayList<>();
}
items.add(context);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -54,7 +54,7 @@ public void setLinks(List<LinkV2> links) {

public void addResource(Resource resource) {
if (items == null) {
items = new ArrayList<Resource>();
items = new ArrayList<>();
}
items.add(resource);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -108,23 +108,23 @@ public void setLinks(List<LinkV2> links) {

public void addProperty(String name, Property property) {
if (properties == null) {
properties = new ArrayList<JAXBElement>();
properties = new ArrayList<>();
}
properties.add(new JAXBElement<Property>(new QName(name), Property.class, property));
properties.add(new JAXBElement<>(new QName(name), Property.class, property));
}

public void addDefinition(String name, ResourceSchema definition) {
// Lazy initialization
if (definitions == null) {
definitions = new ArrayList<JAXBElement>(1);
definitions = new ArrayList<>(1);
}
definitions.add(new JAXBElement<ResourceSchema>(new QName(name), ResourceSchema.class, definition));
definitions.add(new JAXBElement<>(new QName(name), ResourceSchema.class, definition));
}

public void addAllOf(Reference reference) {
// Lazy initialization
if (allOf == null) {
allOf = new ArrayList<Reference>(1);
allOf = new ArrayList<>(1);
}
allOf.add(reference);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -40,7 +40,6 @@
* @author Mike Norman - michael.norman@oracle.com
* @since EclipseLink 1.x
*/
@SuppressWarnings({"unchecked"})
public class DeleteOperation extends Operation {
protected String descriptorName;
protected ClassDescriptor classDescriptor;
Expand Down Expand Up @@ -127,11 +126,11 @@ public Object invoke(XRServiceAdapter xrService, Invocation invocation) {
// set query args or execute args for the non-JPAQuery case,
// i.e. stored proc/funcs get populated from ORM metadata
// whereas named queries (SQL strings) do not...
List queryArguments = query.getArguments();
List<String> queryArguments = query.getArguments();
int queryArgumentsSize = queryArguments.size();
Vector executeArguments = new NonSynchronizedVector();
Vector<Object> executeArguments = new NonSynchronizedVector<>();
for (int i = 0; i < queryArgumentsSize; i++) {
String argName = (String)queryArguments.get(i);
String argName = queryArguments.get(i);
executeArguments.add(invocation.getParameter(argName));
}
toBeDeleted = uow.executeQuery(query, executeArguments);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -34,7 +34,7 @@
public class Invocation {

protected String name;
protected Map<String, Object> parameters = new HashMap<String, Object>();
protected Map<String, Object> parameters = new HashMap<>();

public Invocation() {
super();
Expand Down