private Set < String > findClassLabelsInHasContainers ( ) { Set < String > classLabels = new HashSet <> ( ) ; HasContainer container = this . hasContainers . stream ( ) . filter ( hasContainer -> isLabelKey ( hasContainer . getKey ( ) ) ) . findFirst ( ) . orElseGet ( ( ) -> { String defaultClass = Vertex . class . isAssignableFrom ( getReturnClass ( ) ) ? "V" : "E" ; HasContainer defaultContainer = new HasContainer ( T . label . name ( ) , P . eq ( defaultClass ) ) ; return defaultContainer ; } ) ; Object value = container . getValue ( ) ; //The ugly part. Is there anyway to know the return type of a predicate value ? if ( value instanceof List ) { ( ( List ) value ) . forEach ( label -> classLabels . add ( ( String ) label ) ) ; } else { classLabels . add ( ( String ) value ) ; } return classLabels ; }
if one of the HasContainers is a label matching predicate then return those labels