public static ActivityStreamMessage from ( final Event event ) { final ActivityStreamMessage msg = new ActivityStreamMessage ( ) ; msg . id = event . getIdentifier ( ) . getIRIString ( ) ; msg . type = event . getTypes ( ) . stream ( ) . map ( IRI :: getIRIString ) . map ( type -> type . startsWith ( AS . URI ) ? type . substring ( AS . URI . length ( ) ) : type ) . collect ( toList ( ) ) ; msg . published = event . getCreated ( ) . toString ( ) ; final List < String > actors = event . getAgents ( ) . stream ( ) . map ( IRI :: getIRIString ) . collect ( toList ( ) ) ; msg . actor = actors . isEmpty ( ) ? null : actors ; event . getInbox ( ) . map ( IRI :: getIRIString ) . ifPresent ( inbox -> msg . inbox = inbox ) ; event . getTarget ( ) . map ( IRI :: getIRIString ) . ifPresent ( target -> msg . object = new EventResource ( target , event . getTargetTypes ( ) . stream ( ) . map ( IRI :: getIRIString ) . collect ( toList ( ) ) ) ) ; return msg ; }
Populate a ActivityStreamMessage from an Event