Skip to content

Commit

Permalink
Merge pull request #117 from Olafxso/patch-1
Browse files Browse the repository at this point in the history
Update VParentBase.java
  • Loading branch information
daviddbal authored Oct 31, 2019
2 parents f60f56f + 9732a23 commit 9096c0b
Showing 1 changed file with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,26 +331,29 @@ protected boolean checkChild(List<Message> messages, String content, String elem
MessageEffect.THROW_EXCEPTION);
messages.add(message);
}
final boolean isChildAlreadyPresent;
Object currentParameter = null;
try {
currentParameter = getter.invoke(this);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
if (currentParameter instanceof Collection)
{
isChildAlreadyPresent = ((Collection<?>) currentParameter).contains(newChild); // TODO contains is expensive - try to find a way to avoid
} else
{
isChildAlreadyPresent = currentParameter != null;
}
if (isChildAlreadyPresent)
{
Message message = new Message(this,
newChild.getClass().getSimpleName() + " can only occur once in a calendar component. Ignoring instances beyond first.",
MessageEffect.MESSAGE_ONLY);
messages.add(message);
else // Moved to an else block, because getter could be null here
{
final boolean isChildAlreadyPresent;
Object currentParameter = null;
try {
currentParameter = getter.invoke(this);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
if (currentParameter instanceof Collection)
{
isChildAlreadyPresent = ((Collection<?>) currentParameter).contains(newChild); // TODO contains is expensive - try to find a way to avoid
} else
{
isChildAlreadyPresent = currentParameter != null;
}
if (isChildAlreadyPresent)
{
Message message = new Message(this,
newChild.getClass().getSimpleName() + " can only occur once in a calendar component. Ignoring instances beyond first.",
MessageEffect.MESSAGE_ONLY);
messages.add(message);
}
}
return messages.size() == initialMessageSize;
}
Expand Down

0 comments on commit 9096c0b

Please sign in to comment.