use of com.thinkbiganalytics.metadata.modeshape.UnknownPropertyException in project kylo by Teradata.
the class NodeEntityMixin method getPropertyAsSet.
default <T> Set<T> getPropertyAsSet(String name, Class<T> objectType) {
Object o = null;
try {
o = JcrPropertyUtil.getProperty(getNode(), name);
} catch (UnknownPropertyException e) {
}
if (o != null) {
if (o instanceof Collection) {
// convert the objects to the correct type if needed
if (JcrObject.class.isAssignableFrom(objectType)) {
Set<T> objects = new HashSet<>();
for (Object collectionObj : (Collection) o) {
T obj = null;
if (collectionObj instanceof Node) {
try {
obj = ConstructorUtils.invokeConstructor(objectType, (Node) collectionObj);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
obj = (T) collectionObj;
}
} else {
obj = (T) collectionObj;
}
objects.add(obj);
}
return objects;
} else {
return new HashSet<T>((Collection) o);
}
} else {
Set<T> set = new HashSet<>();
if (JcrObject.class.isAssignableFrom(objectType) && o instanceof Node) {
T obj = null;
try {
obj = ConstructorUtils.invokeConstructor(objectType, (Node) o);
set.add((T) obj);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
}
set.add(obj);
} else {
set.add((T) o);
}
return set;
}
}
return new HashSet<T>();
}
Aggregations