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

Update VParentBase.java #117

Merged
merged 1 commit into from
Oct 31, 2019
Merged
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 @@ -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