@Override
	public UserProfile convert(String text)
	{
		if(text == null || text.trim().length() == 0)
			return null;
		
		String[] lines = text.split("\\\n");
		
		BiConsumer<String,UserProfile> strategy = null;
		UserProfile userProfile = null;
		String lineUpper = null;
		for (String line : lines)
		{
			//get first term
			int index = line.indexOf(";");
			if(index < 0)
				continue; //skip line
			//
			String term = line.substring(0, index);
			
			strategy = strategies.get(term.toLowerCase());
			lineUpper = line.toUpperCase();
			if(strategy == null)
			{
				//check for a different format
				//N:Green;Gregory;;;
				if(lineUpper.startsWith("N:"))
					strategy = strategies.get("n");
				else if(lineUpper.startsWith("FN:"))
					strategy = strategies.get("fn");
				else if(lineUpper.contains("EMAIL;"))
					strategy = strategies.get("email");
				else
					continue; //skip
			}
			
			if(userProfile == null)
			{
				userProfile = ClassPath.newInstance(this.userProfileClass);
			}
			
			strategy.accept(line, userProfile);
			
		}
		return userProfile;
	}
@ Override public UserProfile convert ( String text ) { if ( text == null || text . trim ( ) . length ( ) == 0 ) return null ; String [ ] lines = text . split ( "\\\n" ) ; BiConsumer < String , UserProfile > strategy = null ; UserProfile userProfile = null ; String lineUpper = null ; for ( String line : lines ) { int index = line . indexOf ( ";" ) ; if ( index < 0 ) continue ; String term = line . substring ( 0 , index ) ; strategy = strategies . get ( term . toLowerCase ( ) ) ; lineUpper = line . toUpperCase ( ) ; if ( strategy == null ) { if ( lineUpper . startsWith ( "N:" ) ) strategy = strategies . get ( "n" ) ; else if ( lineUpper . startsWith ( "FN:" ) ) strategy = strategies . get ( "fn" ) ; else if ( lineUpper . contains ( "EMAIL;" ) ) strategy = strategies . get ( "email" ) ; else continue ; } if ( userProfile == null ) { userProfile = ClassPath . newInstance ( this . userProfileClass ) ; } strategy . accept ( line , userProfile ) ; } return userProfile ; }
Convert from text from user profile