@SuppressWarnings("unchecked")
public <T> T getWith(LogicalPlanPersistence lpPersistance, Class<T> c) {
try {
if (opaque != null) {
final Class<?> opaqueClass = opaque.getClass();
if (opaqueClass.equals(c)) {
return (T) opaque;
} else {
if (c.isEnum()) {
final String opaqueName = opaqueClass.getName().replaceAll("\\$\\d+$", "");
final String cName = c.getName();
if(opaqueName.equals(cName)) {
return (T) opaque;
}
}
throw new IllegalArgumentException(String.format("Attempted to retrieve a option with type of %s. " +
"However, the JSON options carried an opaque value of type %s.", c.getName(), opaqueClass.getName()));
}
}
return lpPersistance.getMapper().treeToValue(root, c);
} catch (JsonProcessingException e) {
throw new LogicalPlanParsingException(String.format("Failure while trying to convert late bound " +
"json options to type of %s. Reference was originally located at line %d, column %d.",
c.getCanonicalName(), location.getLineNr(), location.getColumnNr()), e);
}
}