@ SuppressWarnings ( "ConstantConditions" ) public boolean isPossibleType ( Type abstractType , Type possibleObjectType ) { if ( ! isInterfaceOrUnion ( abstractType ) ) { return false ; } if ( ! isObjectType ( possibleObjectType ) ) { return false ; } ObjectTypeDefinition targetObjectTypeDef = getType ( possibleObjectType , ObjectTypeDefinition . class ) . get ( ) ; TypeDefinition abstractTypeDef = getType ( abstractType ) . get ( ) ; if ( abstractTypeDef instanceof UnionTypeDefinition ) { List < Type > memberTypes = ( ( UnionTypeDefinition ) abstractTypeDef ) . getMemberTypes ( ) ; for ( Type memberType : memberTypes ) { Optional < ObjectTypeDefinition > checkType = getType ( memberType , ObjectTypeDefinition . class ) ; if ( checkType . isPresent ( ) ) { if ( checkType . get ( ) . getName ( ) . equals ( targetObjectTypeDef . getName ( ) ) ) { return true ; } } } return false ; } else { InterfaceTypeDefinition iFace = ( InterfaceTypeDefinition ) abstractTypeDef ; List < ObjectTypeDefinition > objectTypeDefinitions = getImplementationsOf ( iFace ) ; return objectTypeDefinitions . stream ( ) . anyMatch ( od -> od . getName ( ) . equals ( targetObjectTypeDef . getName ( ) ) ) ; } }
Returns true of the abstract type is in implemented by the object type