Пример #1
0
 /**
  * Calls the next mapper in the chain, if any
  * @param data The data to pass along the chain
  * @param event the event generated by last {@link EventMapper}, if any
  */
 public void doMap(EventData data)
 {
     if (this.mappers.Peek() != null)
     {
         EventMapper mapper = this.mappers.poll();
         mapper.doMap(data, this);
     }
 }
Пример #2
0
        /*
         * (non-Javadoc)
         *
         * @see
         * eu.jpereira.trainings.designpatterns.behavioral.observer.mapper.EventMapper
         * #doMap(eu.jpereira.trainings.designpatterns.behavioral.observer.event.
         * EventData,
         * eu.jpereira.trainings.designpatterns.behavioral.observer.event.
         * ApplianceEvent,
         * eu.jpereira.trainings.designpatterns.behavioral.observer.mapper
         * .MapperChain)
         */
        public void doMap(EventData data, MapperChain chain)
        {
            //If event is null or event.sourceAppliance is null, create new one
            if ( data.getEvent() ==null) {

            data.setEvent( new ApplianceEvent(null));
            }
            if (data.getEvent().getSourceAppliance()==null) {
            //Find the right appliance in the DAO
            Appliance appliance = applianceDao.findByMacAddress(data.getProperty("applianceMacAddress"));
            data.getEvent().setSourceAppliance(appliance);

            }

            chain.doMap(data);
        }