Skip to content

Commit

Permalink
handle excluded value types in an array #135
Browse files Browse the repository at this point in the history
  • Loading branch information
walterxie committed May 7, 2024
1 parent 5aa949d commit d770a99
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lphybeast/src/main/java/lphybeast/BEASTContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,21 @@ private BEASTInterface valueToBEAST(Value<?> val) {
return beastValue;
}

// handle the classes in excludedValueTypes, and also their types in an array.
private boolean isExcludedValue(Value value) {
if (LPhyBEASTExt.isExcludedValue(value)) // takes Value
return true;
Class valueType = value.getType();
// value.value() is array
if (valueType.isArray()) {
Class componentClass = valueType.getComponentType();
Class componentClass;
if (value.value() instanceof Object[] objects)
// Object[] can be different classes, such as TimeTreeNode[],
// getComponentType() only returns Object.
componentClass = objects[0].getClass();
else
componentClass = valueType.getComponentType();

for (Class vCls : excludedValueTypes) {
// if vCls is either the same as, or is a superclass or superinterface of value.getType().
if (vCls != null && vCls.isAssignableFrom(componentClass))
Expand Down

0 comments on commit d770a99

Please sign in to comment.