Skip to content

Commit

Permalink
cleanup in eis/nosql world
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Sep 15, 2021
1 parent b2cd639 commit 5f1f8da
Show file tree
Hide file tree
Showing 36 changed files with 345 additions and 349 deletions.
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 @@ -29,13 +29,13 @@
public class EISCollectionChangeRecord extends CollectionChangeRecord implements org.eclipse.persistence.sessions.changesets.EISCollectionChangeRecord {

/** The added stuff. */
private List adds;
private List adds; //either ObjectChangeSet or String (simple type)

/** The removed stuff. */
private List removes;
private List removes; //either ObjectChangeSet or String (simple type)

/** The stuff whose Map keys have changed. */
private List changedMapKeys;
private List changedMapKeys; //either ObjectChangeSet or String (simple type)

/**
* Construct a ChangeRecord that can be used to represent the changes to
Expand Down Expand Up @@ -78,7 +78,7 @@ public void addRemovedChangeSet(Object changeSet) {
@Override
public List getAdds() {
if (adds == null) {
adds = new ArrayList(2);// keep it as small as possible
adds = new ArrayList<>(2);// keep it as small as possible
}
return adds;
}
Expand All @@ -92,7 +92,7 @@ public List getAdds() {
@Override
public List getChangedMapKeys() {
if (changedMapKeys == null) {
changedMapKeys = new ArrayList(2);// keep it as small as possible
changedMapKeys = new ArrayList<>(2);// keep it as small as possible
}
return changedMapKeys;
}
Expand All @@ -106,7 +106,7 @@ public List getChangedMapKeys() {
@Override
public List getRemoves() {
if (removes == null) {
removes = new ArrayList(2);// keep it as small as possible
removes = new ArrayList<>(2);// keep it as small as possible
}
return removes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public EISDOMRecord(jakarta.resource.cci.Record record) {
try {
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try{
setDOM((Element)AccessController.doPrivileged(new PrivilegedMethodInvoker(domMethod, record, null)));
setDOM(AccessController.doPrivileged(new PrivilegedMethodInvoker<>(domMethod, record, null)));
}catch (PrivilegedActionException ex){
throw (Exception)ex.getCause();
}
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 @@ -264,7 +264,7 @@ public AbstractRecord buildNestedRowFromFieldValue(Object fieldValue) {
if (!(fieldValue instanceof List)) {
return getObjectBuilder().createRecord(0, null);
}
List nestedRows = (List)fieldValue;
List<?> nestedRows = (List<?>)fieldValue;
if (nestedRows.isEmpty()) {
return getObjectBuilder().createRecord(0, null);
} else {
Expand All @@ -284,14 +284,14 @@ public AbstractRecord buildNestedRowFromFieldValue(Object fieldValue) {
public Vector buildNestedRowsFromFieldValue(Object fieldValue, AbstractSession session) {
if (!isXMLFormat()) {
if (!(fieldValue instanceof List)) {
return new Vector();
return new Vector<>();
}
return new Vector((List)fieldValue);
return new Vector<>((List<?>)fieldValue);
}

// BUG#2667762 if the tag was empty this could be a string of whitespace.
if (!(fieldValue instanceof Vector)) {
return new Vector(0);
return new Vector<>(0);
}
return (Vector)fieldValue;
}
Expand All @@ -305,7 +305,7 @@ public Vector buildNestedRowsFromFieldValue(Object fieldValue, AbstractSession s
@Override
public Vector buildDirectValuesFromFieldValue(Object fieldValue) {
if (!(fieldValue instanceof Vector)) {
Vector fieldValues = new Vector(1);
Vector<Object> fieldValues = new Vector<>(1);
fieldValues.add(fieldValue);
return fieldValues;
}
Expand All @@ -329,7 +329,7 @@ public Object buildFieldValueFromDirectValues(Vector directValues, String elemen
*/
@Override
public Object buildFieldValueFromNestedRow(AbstractRecord nestedRow, AbstractSession session) throws DatabaseException {
Vector nestedRows = new Vector(1);
Vector<AbstractRecord> nestedRows = new Vector<>(1);
nestedRows.add(nestedRow);
return this.buildFieldValueFromNestedRows(nestedRows, "", session);
}
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 @@ -178,7 +178,7 @@ public static EISException couldNotDeleteFile(Object[] args) {
return EISException.createResourceException(args, COULD_NOT_DELETE_FILE);
}

public static EISException incorrectLoginInstanceProvided(Class loginClass) {
public static EISException incorrectLoginInstanceProvided(Class<?> loginClass) {
Object[] args = { loginClass };
EISException exception = new EISException(ExceptionMessageGenerator.buildMessage(EISException.class, INCORRECT_LOGIN_INSTANCE_PROVIDED, args));
exception.setErrorCode(INCORRECT_LOGIN_INSTANCE_PROVIDED);
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 @@ -45,8 +45,8 @@ public EISMappedRecord(Map record, EISAccessor accessor) {
* getFields() is sued internally in a few places, so try to make that work for mapped records.
*/
@Override
public Vector getFields() {
return new Vector(getRecord().keySet());
public Vector<DatabaseField> getFields() {
return new Vector<>(getRecord().keySet());
}

/**
Expand Down Expand Up @@ -122,12 +122,12 @@ public Object get(String key) {
public Object get(DatabaseField field) {
Object value = get(field.getName());
if (value instanceof Map) {
Vector nestedRows = new Vector(1);
Vector<EISMappedRecord> nestedRows = new Vector<>(1);
nestedRows.add(new EISMappedRecord((Map)value, getAccessor()));
value = nestedRows;
} else if (value instanceof List) {
List values = (List)value;
Vector nestedValues = new Vector(values.size());
List<?> values = (List<?>)value;
Vector<Object> nestedValues = new Vector<>(values.size());
for (int index = 0; index < values.size(); index++) {
Object nestedValue = values.get(index);
if (nestedValue instanceof Map) {
Expand Down Expand Up @@ -194,7 +194,7 @@ public String toString() {
writer.write(Helper.getShortClassName(getClass()));
writer.write("(");

for (Iterator keysIterator = keySet().iterator(); keysIterator.hasNext();) {
for (Iterator<?> keysIterator = keySet().iterator(); keysIterator.hasNext();) {
Object key = keysIterator.next();
writer.write(Helper.cr());
writer.write("\t");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ protected ClassDescriptor buildXMLInteractionDescriptor() {
@Override
public Object getAttributeValueFromObject(Object object) {
XMLInteraction interaction = (XMLInteraction)object;
Vector argumentNames = interaction.getArgumentNames();
Vector arguments = interaction.getArguments();
Vector<String> argumentNames = interaction.getArgumentNames();
Vector<?> arguments = interaction.getArguments();
Vector<InteractionArgument> interactionArguments = new Vector<>(arguments.size());
for (int index = 0; index < arguments.size(); index++) {
InteractionArgument interactionArgument = new InteractionArgument();
interactionArgument.setArgumentName((String)argumentNames.get(index));
interactionArgument.setArgumentName(argumentNames.get(index));
Object argument = arguments.get(index);
if (argument instanceof DatabaseField) {
interactionArgument.setKey(argument);
Expand All @@ -198,12 +198,13 @@ public Object getAttributeValueFromObject(Object object) {
@Override
public void setAttributeValueInObject(Object object, Object value) {
XMLInteraction interaction = (XMLInteraction)object;
Vector interactionArguments = (Vector)value;
Vector arguments = new Vector(interactionArguments.size());
Vector argumentNames = new Vector(interactionArguments.size());
Vector values = new Vector(interactionArguments.size());
@SuppressWarnings({"unchecked"})
Vector<InteractionArgument> interactionArguments = (Vector<InteractionArgument>)value;
Vector<DatabaseField> arguments = new Vector<>(interactionArguments.size());
Vector<String> argumentNames = new Vector<>(interactionArguments.size());
Vector<Object> values = new Vector<>(interactionArguments.size());
for (int index = 0; index < interactionArguments.size(); index++) {
InteractionArgument interactionArgument = (InteractionArgument)interactionArguments.get(index);
InteractionArgument interactionArgument = interactionArguments.get(index);
if (interactionArgument.getKey() != null) {
arguments.add(new DatabaseField((String)interactionArgument.getKey()));
}
Expand Down Expand Up @@ -236,13 +237,13 @@ public void setAttributeValueInObject(Object object, Object value) {
@Override
public Object getAttributeValueFromObject(Object object) {
XMLInteraction interaction = (XMLInteraction)object;
Vector arguments = interaction.getOutputArguments();
Vector argumentNames = interaction.getOutputArgumentNames();
Vector<DatabaseField> arguments = interaction.getOutputArguments();
Vector<String> argumentNames = interaction.getOutputArgumentNames();
Vector<InteractionArgument> interactionArguments = new Vector<>(arguments.size());
for (int index = 0; index < arguments.size(); index++) {
InteractionArgument interactionArgument = new InteractionArgument();
interactionArgument.setKey(((DatabaseField)arguments.get(index)).getName());
interactionArgument.setArgumentName((String)argumentNames.get(index));
interactionArgument.setKey(arguments.get(index).getName());
interactionArgument.setArgumentName(argumentNames.get(index));
interactionArguments.add(interactionArgument);
}
return interactionArguments;
Expand All @@ -251,11 +252,12 @@ public Object getAttributeValueFromObject(Object object) {
@Override
public void setAttributeValueInObject(Object object, Object value) {
XMLInteraction interaction = (XMLInteraction)object;
Vector interactionArguments = (Vector)value;
@SuppressWarnings({"unchecked"})
Vector<InteractionArgument> interactionArguments = (Vector<InteractionArgument>)value;
Vector<DatabaseField> arguments = new Vector<>(interactionArguments.size());
Vector<String> argumentNames = new Vector<>(interactionArguments.size());
for (int index = 0; index < interactionArguments.size(); index++) {
InteractionArgument interactionArgument = (InteractionArgument)interactionArguments.get(index);
InteractionArgument interactionArgument = interactionArguments.get(index);
arguments.add(new DatabaseField((String)interactionArgument.getKey()));
argumentNames.add(interactionArgument.getArgumentName());
}
Expand Down Expand Up @@ -389,12 +391,13 @@ public Object getAttributeValueFromObject(Object object) {
@Override
public void setAttributeValueInObject(Object object, Object value) {
EISOneToOneMapping mapping = (EISOneToOneMapping)object;
List associations = (List)value;
mapping.setSourceToTargetKeyFields(new HashMap(associations.size() + 1));
mapping.setTargetToSourceKeyFields(new HashMap(associations.size() + 1));
Iterator iterator = associations.iterator();
@SuppressWarnings({"unchecked"})
List<Association> associations = (List<Association>)value;
mapping.setSourceToTargetKeyFields(new HashMap<>(associations.size() + 1));
mapping.setTargetToSourceKeyFields(new HashMap<>(associations.size() + 1));
Iterator<Association> iterator = associations.iterator();
while (iterator.hasNext()) {
Association association = (Association)iterator.next();
Association association = iterator.next();
mapping.getSourceToTargetKeyFields().put((DatabaseField)association.getKey(), (DatabaseField)association.getValue());
mapping.getTargetToSourceKeyFields().put((DatabaseField)association.getValue(), (DatabaseField)association.getKey());
}
Expand Down Expand Up @@ -459,7 +462,7 @@ public Object getAttributeValueFromObject(Object object) {

@Override
public void setAttributeValueInObject(Object object, Object value) {
if ((value != null) && value instanceof ReadQuery) {
if (value instanceof ReadQuery) {
((ForeignReferenceMapping)object).setCustomSelectionQuery((ReadQuery)value);
}
}
Expand Down Expand Up @@ -555,7 +558,7 @@ public Object getAttributeValueFromObject(Object object) {

@Override
public void setAttributeValueInObject(Object object, Object value) {
if ((value != null) && value instanceof ReadQuery) {
if (value instanceof ReadQuery) {
((ForeignReferenceMapping)object).setCustomSelectionQuery((ReadQuery)value);
}
}
Expand All @@ -581,7 +584,7 @@ public Object getAttributeValueFromObject(Object object) {

@Override
public void setAttributeValueInObject(Object object, Object value) {
if ((value != null) && value instanceof ModifyQuery) {
if (value instanceof ModifyQuery) {
((EISOneToManyMapping)object).setCustomDeleteAllQuery((ModifyQuery)value);
}
}
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 @@ -29,19 +29,19 @@
public class EISOrderedCollectionChangeRecord extends CollectionChangeRecord implements org.eclipse.persistence.sessions.changesets.EISOrderedCollectionChangeRecord {

/** The added stuff. */
private List adds;
private List adds; // either ObjectChangeSet or String (simple type)

/** The indexes into the new collection of the elements that were added. */
private int[] addIndexes;

/** The moved stuff. */
private List moves;
private List moves; // either ObjectChangeSet or String (simple type)

/** The index pairs of the elements that were moved (before and after indexes). */
private int[][] moveIndexPairs;

/** The removed stuff. */
private List removes;
private List removes; // either ObjectChangeSet or String (simple type)

/** The indexes into the old collection of the elements that were removed. */
private int[] removeIndexes;
Expand Down Expand Up @@ -137,7 +137,7 @@ public int[] getAddIndexes() {
@Override
public List getAdds() {
if (adds == null) {
adds = new ArrayList(2);// keep it as small as possible
adds = new ArrayList<>(2);// keep it as small as possible
}
return adds;
}
Expand Down Expand Up @@ -207,7 +207,7 @@ public int[][] getMoveIndexPairs() {
@Override
public List getMoves() {
if (moves == null) {
moves = new ArrayList(2);// keep it as small as possible
moves = new ArrayList<>(2);// keep it as small as possible
}
return moves;
}
Expand Down Expand Up @@ -310,7 +310,7 @@ public int[] getRemoveIndexes() {
@Override
public List getRemoves() {
if (removes == null) {
removes = new ArrayList(2);// keep it as small as possible
removes = new ArrayList<>(2);// keep it as small as possible
}
return removes;
}
Expand Down

0 comments on commit 5f1f8da

Please sign in to comment.