Example usage for org.apache.commons.collections Factory Factory

List of usage examples for org.apache.commons.collections Factory Factory

Introduction

In this page you can find the example usage for org.apache.commons.collections Factory Factory.

Prototype

Factory

Source Link

Usage

From source file:info.magnolia.cms.gui.controlx.impl.RenderKitImpl.java

/**
 * Init the layzy map. //ww  w .  j a  v  a 2  s  .c o  m
 */
public RenderKitImpl() {
    renderers = MapUtils.lazyMap(new HashMap(), new Factory() {
        public Object create() {
            return new TemplatedRenderer();
        }
    });
}

From source file:fr.itinerennes.onebusaway.bundle.tasks.GenerateRoutesAndStopsCsvTask.java

/**
 * {@inheritDoc}//from   w  ww .  j ava  2s  . c  o m
 * 
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {

    @SuppressWarnings("unchecked")
    final Map<String, Set<String>> routesToStops = LazyMap.decorate(new HashMap<String, Set<String>>(),
            new Factory() {

                @Override
                public Object create() {

                    return new HashSet<String>();
                }
            });

    for (final StopTime stopTime : gtfsDao.getAllStopTimes()) {
        final String routeId = stopTime.getTrip().getRoute().getId().toString();
        final String stopId = stopTime.getStop().getId().toString();
        // add or overwrite stopId for the routeId
        routesToStops.get(routeId).add(stopId);
    }

    // count amount of couples (routeId, stopId)
    int count = 0;
    for (final Entry<String, Set<String>> route : routesToStops.entrySet()) {
        if (route.getValue().isEmpty()) {
            throw new IllegalStateException("route " + route.getKey() + " has 0 stops");
        }
        count += route.getValue().size();
    }

    BufferedWriter out = null;
    try {
        out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), CHARSET));

        // output amount of couples (routeId, stopId)
        out.write(String.valueOf(count));
        out.newLine();

        for (final Entry<String, Set<String>> route : routesToStops.entrySet()) {
            final String routeId = route.getKey();
            for (final String stopId : route.getValue()) {
                out.write(routeId);
                out.write(';');
                out.write(stopId);
                out.write(';');
                out.newLine();
            }
        }

    } catch (final FileNotFoundException e) {
        LOGGER.error("output file not found", e);
    } catch (final IOException e) {
        LOGGER.error("can't write to output file", e);
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:de.fhg.fokus.hss.form.GussForm.java

public void reset(ActionMapping arg0, HttpServletRequest arg1) {
    LOGGER.debug("entering");
    super.reset(arg0, arg1);
    uiccType = GussBO.GUS;/*from w  ww.  jav a  2  s.c om*/
    keyLifeTime = GussBO.LIFE_TIME_DEFAULT;
    Factory factory = new Factory() {
        public Object create() {
            return new UssForm();
        }
    };

    ussList = LazyList.decorate(new ArrayList(), factory);
    LOGGER.debug("exiting");
}

From source file:de.fhg.fokus.hss.web.form.GBA_USS_Form.java

public void reset(ActionMapping actionMapping, HttpServletRequest request) {
    this.id_impi = 0;
    this.identity = null;
    this.uicc_type = ZhConstants.UICC_Type_Basic_GBA;
    this.key_life_time = ZhConstants.Default_Key_Life_Time;
    this.default_auth_scheme = CxConstants.Auth_Scheme_AKAv1;

    Factory factory = new Factory() {
        public Object create() {
            return new USS_Form();
        }//from www . j  a v a 2  s.  c  o m
    };

    this.ussList = LazyList.decorate(new ArrayList(), factory);
}

From source file:de.fhg.fokus.hss.form.TriggerPointForm.java

public void reset(ActionMapping arg0, HttpServletRequest arg1) {
    LOGGER.debug("entering");
    trigPtId = null;//ww w. j a  v a 2 s  .c  om
    trigPtName = null;
    cnf = 0;
    type = -1;
    group = -1;

    Factory factory = new Factory() {
        public Object create() {
            return new SptForm();
        }
    };

    spts = LazyList.decorate(new ArrayList(), factory);
    LOGGER.debug("exiting");
}

From source file:de.fhg.fokus.hss.web.form.TP_Form.java

public void reset(ActionMapping actionMapping, HttpServletRequest request) {
    this.id = -1;
    this.name = null;
    this.condition_type_cnf = CxConstants.ConditionType_CNF;

    Factory factory = new Factory() {
        public Object create() {
            return new SPT_Form();
        }/*ww  w  . ja va2 s.c o m*/
    };

    this.spts = LazyList.decorate(new ArrayList(), factory);
    this.type = 0;
    this.group = 1;
    this.nextAction = null;
    this.ifc_id = -1;
    this.associated_ID = -1;
    this.select_ifc = null;
}

From source file:de.unisb.cs.st.javaslicer.tracer.instrumentation.PauseTracingInstrumenter.java

@SuppressWarnings("unchecked")
public void transformMethod(final MethodNode method, final ListIterator<MethodNode> methodIt,
        final String className) {
    if ((method.access & ACC_ABSTRACT) != 0 || (method.access & ACC_NATIVE) != 0)
        return;//  ww  w . j a  v  a  2s  .  com

    int tracerLocalVarIndex = (method.access & Opcodes.ACC_STATIC) == 0 ? 1 : 0;
    for (final Type t : Type.getArgumentTypes(method.desc))
        tracerLocalVarIndex += t.getSize();

    // increment number of local variables by one (for the threadtracer)
    ++method.maxLocals;

    // and increment all local variable indexes after the new one by one
    for (final Object o : method.localVariables) {
        final LocalVariableNode localVar = (LocalVariableNode) o;
        if (localVar.index >= tracerLocalVarIndex)
            ++localVar.index;
    }
    final LabelNode l0 = new LabelNode();
    final LabelNode l1 = new LabelNode();

    final ListIterator<AbstractInsnNode> insnIt = method.instructions.iterator();

    insnIt.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(Tracer.class), "getInstance",
            "()L" + Type.getInternalName(Tracer.class) + ";"));
    insnIt.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(Tracer.class), "getThreadTracer",
            "()L" + Type.getInternalName(ThreadTracer.class) + ";"));
    insnIt.add(new InsnNode(DUP));
    insnIt.add(new VarInsnNode(ASTORE, tracerLocalVarIndex));
    insnIt.add(new MethodInsnNode(INVOKEINTERFACE, Type.getInternalName(ThreadTracer.class), "pauseTracing",
            "()V"));
    insnIt.add(l0);

    while (insnIt.hasNext()) {
        final AbstractInsnNode insn = insnIt.next();
        switch (insn.getType()) {
        case AbstractInsnNode.INSN:
            switch (insn.getOpcode()) {
            case IRETURN:
            case LRETURN:
            case FRETURN:
            case DRETURN:
            case ARETURN:
            case RETURN:
                insnIt.previous();
                insnIt.add(new VarInsnNode(ALOAD, tracerLocalVarIndex));
                insnIt.add(new MethodInsnNode(INVOKEINTERFACE, Type.getInternalName(ThreadTracer.class),
                        "resumeTracing", "()V"));
                insnIt.next();
            }
            break;
        case AbstractInsnNode.IINC_INSN:
            if (((IincInsnNode) insn).var >= tracerLocalVarIndex)
                ++((IincInsnNode) insn).var;
            break;
        case AbstractInsnNode.VAR_INSN:
            if (((VarInsnNode) insn).var >= tracerLocalVarIndex)
                ++((VarInsnNode) insn).var;
            break;
        default:
            break;
        }
    }

    method.instructions.add(l1);

    method.instructions.add(new VarInsnNode(ALOAD, tracerLocalVarIndex));
    method.instructions.add(new MethodInsnNode(INVOKEINTERFACE, Type.getInternalName(ThreadTracer.class),
            "resumeTracing", "()V"));
    method.instructions.add(new InsnNode(ATHROW));

    method.tryCatchBlocks.add(new TryCatchBlockNode(l0, l1, l1, null));

    // finally: create a copy of the method that gets the ThreadTracer as argument
    if (!"<clinit>".equals(method.name) && this.tracer.wasRedefined(className)) {
        final Type[] oldMethodArguments = Type.getArgumentTypes(method.desc);
        final Type[] newMethodArguments = Arrays.copyOf(oldMethodArguments, oldMethodArguments.length + 1);
        newMethodArguments[oldMethodArguments.length] = Type.getType(ThreadTracer.class);
        final String newMethodDesc = Type.getMethodDescriptor(Type.getReturnType(method.desc),
                newMethodArguments);
        final MethodNode newMethod = new MethodNode(method.access, method.name, newMethodDesc, method.signature,
                (String[]) method.exceptions.toArray(new String[method.exceptions.size()]));
        methodIt.add(newMethod);

        final Map<LabelNode, LabelNode> newMethodLabels = LazyMap.decorate(new HashMap<LabelNode, LabelNode>(),
                new Factory() {
                    @Override
                    public Object create() {
                        return new LabelNode();
                    }
                });

        // copy the local variables information to the new method
        for (final Object o : method.localVariables) {
            final LocalVariableNode lv = (LocalVariableNode) o;
            newMethod.localVariables.add(new LocalVariableNode(lv.name, lv.desc, lv.signature,
                    newMethodLabels.get(lv.start), newMethodLabels.get(lv.end), lv.index));
        }

        newMethod.maxLocals = method.maxLocals;
        newMethod.maxStack = method.maxStack;

        // copy the try-catch-blocks
        for (final Object o : method.tryCatchBlocks) {
            final TryCatchBlockNode tcb = (TryCatchBlockNode) o;
            newMethod.tryCatchBlocks.add(new TryCatchBlockNode(newMethodLabels.get(tcb.start),
                    newMethodLabels.get(tcb.end), newMethodLabels.get(tcb.handler), tcb.type));
        }

        // skip the first 4 instructions, replace them with this:
        newMethod.instructions.add(new VarInsnNode(ALOAD, tracerLocalVarIndex));
        final Iterator<AbstractInsnNode> oldInsnIt = method.instructions.iterator(4);
        // and add all the other instructions
        while (oldInsnIt.hasNext()) {
            final AbstractInsnNode insn = oldInsnIt.next();
            newMethod.instructions.add(insn.clone(newMethodLabels));
        }
    }
}

From source file:edu.harvard.med.screensaver.service.cherrypicks.CherryPickRequestPlateMapFilesBuilder.java

@SuppressWarnings("unchecked")
/**/*from  w  ww.  j  av a2  s . c  om*/
 * Normally, we create 1 file per assay plate. However, in the case where an
 * assay plate is comprised of wells from library copy plates that have
 * different plate types, we need to generate a separate file for each source
 * plate type (i.e., the assay plate will be defined over multiple files).
 * @return a MultiMap that partitions the cherry picks by file,
 * ordering both the file names and cherry picks for each file.
 */
private MultiMap/*<String,SortedSet<CherryPick>>*/ buildCherryPickFiles(CherryPickRequest cherryPickRequest,
        Set<CherryPickAssayPlate> forPlates) {
    MultiMap assayPlate2SourcePlateTypes = getSourcePlateTypesForEachAssayPlate(cherryPickRequest);

    MultiMap result = MultiValueMap.decorate(new TreeMap<String, SortedSet<LabCherryPick>>(), new Factory() {
        public Object create() {
            return new TreeSet<LabCherryPick>(PlateMappingCherryPickComparator.getInstance());
        }
    });

    // HACK: transform set of CPAP into a set of IDs, for purpose of checking
    // set membership; we can't rely upon CPAP.equals(), since we're comparing
    // non-managed entities with managed entities, and therefore we do not have
    // the guarantee of instance equality for entities with the same ID
    Set<Serializable> forPlateIds = new HashSet<Serializable>(forPlates.size());
    for (CherryPickAssayPlate cpap : forPlates) {
        if (cpap.getEntityId() == null) {
            throw new IllegalArgumentException(
                    "all members of 'forPlates' must already be persisted and have a database identifier");
        }
        forPlateIds.add(cpap.getEntityId());
    }

    for (LabCherryPick cherryPick : cherryPickRequest.getLabCherryPicks()) {
        if (cherryPick.isAllocated()) {
            CherryPickAssayPlate assayPlate = cherryPick.getAssayPlate();
            if (forPlates == null || (assayPlate != null && forPlateIds.contains(assayPlate.getEntityId()))) {
                Set<PlateType> sourcePlateTypes = (Set<PlateType>) assayPlate2SourcePlateTypes
                        .get(assayPlate.getName());
                String fileName = makeFilename(cherryPick, sourcePlateTypes.size());
                result.put(fileName, cherryPick);
            }
        }
    }
    return result;
}

From source file:de.unisb.cs.st.javaslicer.tracer.instrumentation.TracingMethodInstrumenter.java

@SuppressWarnings("unchecked")
public void transform(final ListIterator<MethodNode> methodIt) {

    // do not modify abstract or native methods
    if ((this.methodNode.access & ACC_ABSTRACT) != 0 || (this.methodNode.access & ACC_NATIVE) != 0)
        return;/* w  w  w . j  av  a  2 s  . co m*/

    // check out what labels are jump targets (only these have to be traced)
    analyze(this.methodNode);

    this.instructionIterator = new FixedInstructionIterator(this.methodNode.instructions);
    // in the old method, initialize the new local variable for the threadtracer
    this.instructionIterator.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(Tracer.class),
            "getInstance", "()L" + Type.getInternalName(Tracer.class) + ";"));
    this.instructionIterator.add(new MethodInsnNode(INVOKEVIRTUAL, Type.getInternalName(Tracer.class),
            "getThreadTracer", "()L" + Type.getInternalName(ThreadTracer.class) + ";"));
    this.instructionIterator.add(new InsnNode(DUP));
    this.instructionIterator.add(new VarInsnNode(ASTORE, this.tracerLocalVarIndex));

    this.instructionIterator.add(
            new MethodInsnNode(INVOKEINTERFACE, Type.getInternalName(ThreadTracer.class), "isPaused", "()Z"));
    final LabelNode noTracingLabel = new LabelNode();
    this.instructionIterator.add(new JumpInsnNode(IFNE, noTracingLabel));
    // create a copy of the (uninstrumented) instructions (later, while iterating through the instructions)
    final InsnList oldInstructions = new InsnList();
    final Map<LabelNode, LabelNode> labelCopies = LazyMap.decorate(new HashMap<LabelNode, LabelNode>(),
            new Factory() {
                @Override
                public Object create() {
                    return new LabelNode();
                }
            });
    // copy the try-catch-blocks
    final Object[] oldTryCatchblockNodes = this.methodNode.tryCatchBlocks.toArray();
    for (final Object o : oldTryCatchblockNodes) {
        final TryCatchBlockNode tcb = (TryCatchBlockNode) o;
        final TryCatchBlockNode newTcb = new TryCatchBlockNode(labelCopies.get(tcb.start),
                labelCopies.get(tcb.end), labelCopies.get(tcb.handler), tcb.type);
        this.methodNode.tryCatchBlocks.add(newTcb);
    }

    // increment number of local variables by one (for the threadtracer)
    ++this.methodNode.maxLocals;

    // and increment all local variable indexes after the new one by one
    for (final Object o : this.methodNode.localVariables) {
        final LocalVariableNode localVar = (LocalVariableNode) o;
        if (localVar.index >= this.tracerLocalVarIndex)
            ++localVar.index;
    }

    // store information about local variables in the ReadMethod object
    List<LocalVariable> localVariables = new ArrayList<LocalVariable>();
    for (final Object o : this.methodNode.localVariables) {
        final LocalVariableNode localVar = (LocalVariableNode) o;
        while (localVariables.size() <= localVar.index)
            localVariables.add(null);
        localVariables.set(localVar.index, new LocalVariable(localVar.index, localVar.name, localVar.desc));
    }
    this.readMethod.setLocalVariables(localVariables.toArray(new LocalVariable[localVariables.size()]));
    localVariables = null;

    // each method must start with a (dedicated) label:
    assert this.readMethod.getInstructions().isEmpty();
    traceLabel(null, InstructionType.METHODENTRY);
    assert this.readMethod.getInstructions().size() == 1
            && this.readMethod.getInstructions().get(0) instanceof LabelMarker
            && ((LabelMarker) this.readMethod.getInstructions().get(0)).isAdditionalLabel();
    this.readMethod.setMethodEntryLabel((LabelMarker) this.readMethod.getInstructions().get(0));

    // needed later:
    final LabelNode l0 = new LabelNode();
    this.instructionIterator.add(l0);

    // then, visit the instructions that were in the method before
    while (this.instructionIterator.hasNext()) {

        final AbstractInsnNode insnNode = this.instructionIterator.next();
        switch (insnNode.getType()) {
        case AbstractInsnNode.INSN:
            transformInsn((InsnNode) insnNode);
            break;
        case AbstractInsnNode.INT_INSN:
            transformIntInsn((IntInsnNode) insnNode);
            break;
        case AbstractInsnNode.VAR_INSN:
            transformVarInsn((VarInsnNode) insnNode);
            break;
        case AbstractInsnNode.TYPE_INSN:
            transformTypeInsn((TypeInsnNode) insnNode);
            break;
        case AbstractInsnNode.FIELD_INSN:
            transformFieldInsn((FieldInsnNode) insnNode);
            break;
        case AbstractInsnNode.METHOD_INSN:
            transformMethodInsn((MethodInsnNode) insnNode);
            break;
        case AbstractInsnNode.JUMP_INSN:
            transformJumpInsn((JumpInsnNode) insnNode);
            break;
        case AbstractInsnNode.LABEL:
            transformLabel((LabelNode) insnNode);
            break;
        case AbstractInsnNode.LDC_INSN:
            transformLdcInsn((LdcInsnNode) insnNode);
            break;
        case AbstractInsnNode.IINC_INSN:
            transformIincInsn((IincInsnNode) insnNode);
            break;
        case AbstractInsnNode.TABLESWITCH_INSN:
            transformTableSwitchInsn((TableSwitchInsnNode) insnNode);
            break;
        case AbstractInsnNode.LOOKUPSWITCH_INSN:
            transformLookupSwitchInsn((LookupSwitchInsnNode) insnNode);
            break;
        case AbstractInsnNode.MULTIANEWARRAY_INSN:
            transformMultiANewArrayInsn((MultiANewArrayInsnNode) insnNode);
            break;
        case AbstractInsnNode.FRAME:
            // ignore
            break;
        case AbstractInsnNode.LINE:
            // ignore
            break;
        default:
            throw new RuntimeException("Unknown instruction type " + insnNode.getType() + " ("
                    + insnNode.getClass().getSimpleName() + ")");
        }
        oldInstructions.add(insnNode.clone(labelCopies));
    }

    assert this.outstandingInitializations == 0;

    // add exception handlers for array allocations, *before* any other exception handler.
    // the Java VM Spec (paragraph 3.10) specified that they are executed in the order in which they
    // appear in the bytecode
    if (this.newArrayErrorHandlers != null) {
        for (Entry<LabelNode, Integer> handler : this.newArrayErrorHandlers.entrySet()) {
            this.methodNode.instructions.add(handler.getKey());
            this.methodNode.instructions.add(new VarInsnNode(ALOAD, this.tracerLocalVarIndex));
            this.methodNode.instructions.add(new InsnNode(ACONST_NULL));
            this.methodNode.instructions.add(getIntConstInsn(handler.getValue()));
            this.methodNode.instructions.add(new MethodInsnNode(INVOKEINTERFACE,
                    Type.getInternalName(ThreadTracer.class), "traceObject", "(Ljava/lang/Object;I)V"));
            this.methodNode.instructions.add(new InsnNode(ATHROW));
        }
        this.newArrayErrorHandlers = null;
    }

    // add the (old) try-catch blocks to the readMethods
    // (can only be done down here since we use the information in the
    // labels map)
    for (final Object o : oldTryCatchblockNodes) {
        final TryCatchBlockNode tcb = (TryCatchBlockNode) o;
        this.readMethod.addTryCatchBlock(new TryCatchBlock(this.labels.get(tcb.start), this.labels.get(tcb.end),
                this.labels.get(tcb.handler), tcb.type));
    }

    final LabelNode l1 = new LabelNode();
    this.instructionIterator.add(l1);
    final int newPos = this.readMethod.getInstructions().size();
    traceLabel(null, InstructionType.METHODEXIT);
    assert this.readMethod.getInstructions().size() == newPos + 1;
    final AbstractInstruction abnormalTerminationLabel = this.readMethod.getInstructions().get(newPos);
    assert abnormalTerminationLabel instanceof LabelMarker;
    this.readMethod.setAbnormalTerminationLabel((LabelMarker) abnormalTerminationLabel);
    this.methodNode.instructions.add(new InsnNode(ATHROW));

    // add a try catch block around the method so that we can trace when this method is left
    // by a thrown exception
    this.methodNode.tryCatchBlocks.add(new TryCatchBlockNode(l0, l1, l1, null));

    // now add the code that is executed if no tracing should be performed
    this.methodNode.instructions.add(noTracingLabel);
    if (this.firstLine != -1)
        this.methodNode.instructions.add(new LineNumberNode(this.firstLine, noTracingLabel));
    this.methodNode.instructions.add(new InsnNode(ACONST_NULL));
    this.methodNode.instructions.add(new VarInsnNode(ASTORE, this.tracerLocalVarIndex));
    this.methodNode.instructions.add(oldInstructions);

    // finally: create a copy of the method that gets the ThreadTracer as argument
    // this is only necessary for private methods or "<init>"
    if (this.tracer.wasRedefined(this.readMethod.getReadClass().getName())
            && (this.methodNode.access & ACC_PRIVATE) != 0) {
        final Type[] oldMethodArguments = Type.getArgumentTypes(this.methodNode.desc);
        final Type[] newMethodArguments = Arrays.copyOf(oldMethodArguments, oldMethodArguments.length + 1);
        newMethodArguments[oldMethodArguments.length] = Type.getType(ThreadTracer.class);
        final String newMethodDesc = Type.getMethodDescriptor(Type.getReturnType(this.methodNode.desc),
                newMethodArguments);
        final MethodNode newMethod = new MethodNode(this.methodNode.access, this.methodNode.name, newMethodDesc,
                this.methodNode.signature,
                (String[]) this.methodNode.exceptions.toArray(new String[this.methodNode.exceptions.size()]));
        methodIt.add(newMethod);

        int threadTracerParamPos = ((this.readMethod.getAccess() & Opcodes.ACC_STATIC) == 0 ? 1 : 0);
        for (final Type t : oldMethodArguments)
            threadTracerParamPos += t.getSize();

        final Map<LabelNode, LabelNode> newMethodLabels = LazyMap.decorate(new HashMap<LabelNode, LabelNode>(),
                new Factory() {
                    @Override
                    public Object create() {
                        return new LabelNode();
                    }
                });

        // copy the local variables information to the new method
        for (final Object o : this.methodNode.localVariables) {
            final LocalVariableNode lv = (LocalVariableNode) o;
            newMethod.localVariables.add(new LocalVariableNode(lv.name, lv.desc, lv.signature,
                    newMethodLabels.get(lv.start), newMethodLabels.get(lv.end), lv.index));
        }

        newMethod.maxLocals = this.methodNode.maxLocals;
        newMethod.maxStack = this.methodNode.maxStack;

        // copy the try-catch-blocks
        for (final Object o : this.methodNode.tryCatchBlocks) {
            final TryCatchBlockNode tcb = (TryCatchBlockNode) o;
            newMethod.tryCatchBlocks.add(new TryCatchBlockNode(newMethodLabels.get(tcb.start),
                    newMethodLabels.get(tcb.end), newMethodLabels.get(tcb.handler), tcb.type));
        }

        // skip the first 6 instructions, replace them with these:
        newMethod.instructions.add(new VarInsnNode(ALOAD, threadTracerParamPos));
        newMethod.instructions.add(new InsnNode(DUP));
        newMethod.instructions.add(new VarInsnNode(ASTORE, this.tracerLocalVarIndex));
        newMethod.instructions.add(new JumpInsnNode(IFNULL, newMethodLabels.get(noTracingLabel)));
        final Iterator<AbstractInsnNode> oldInsnIt = this.methodNode.instructions.iterator(6);
        // and add all the other instructions
        while (oldInsnIt.hasNext()) {
            final AbstractInsnNode insn = oldInsnIt.next();
            newMethod.instructions.add(insn.clone(newMethodLabels));
        }
    }

    ready();
}

From source file:edu.harvard.med.screensaver.service.cherrypicks.CherryPickRequestPlateMapFilesBuilder.java

private MultiMap getSourcePlateTypesForEachAssayPlate(CherryPickRequest cherryPickRequest) {
    MultiMap assayPlateName2PlateTypes = MultiValueMap.decorate(new HashMap(), new Factory() {
        public Object create() {
            return new HashSet();
        }//from  w w w .j  a va2 s .c o  m
    });

    for (LabCherryPick cherryPick : cherryPickRequest.getLabCherryPicks()) {
        if (cherryPick.isAllocated() && cherryPick.isMapped()) {
            assayPlateName2PlateTypes.put(cherryPick.getAssayPlate().getName(), cherryPick.getSourceCopy()
                    .findPlate(cherryPick.getSourceWell().getPlateNumber()).getPlateType());
        }
    }
    return assayPlateName2PlateTypes;
}