public static Optional<String> packageName(String longName){
  if (longName.contains(".")) {
    return Optional.of(longName.substring(0,longName.lastIndexOf(".")));
  }
 else {
    return Optional.empty();
  }
}

public static Optional < String > packageName ( String longName ) { if ( longName . contains ( "." ) ) { return Optional . of ( longName . substring ( 0 , longName . lastIndexOf ( "." ) ) ) ; } else { return Optional . empty ( ) ; } }
returns the ' package ' part of a long name . this is everything before the last dot .
