private Optional < IRI > getPredicateIRI ( DataRangeExpression expression ) { if ( expression instanceof Datatype ) { return Optional . of ( ( ( Datatype ) expression ) . getIRI ( ) ) ; } if ( expression instanceof DataPropertyRangeExpression ) { return Optional . of ( ( ( DataPropertyRangeExpression ) expression ) . getProperty ( ) . getIRI ( ) ) ; } return Optional . empty ( ) ; }
if the answer is no drop the Optional and throw an exception instead