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

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

Introduction

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

Prototype

Transformer

Source Link

Usage

From source file:com.shelfmap.stepsfinder.CandidateStepsFactory.java

public static List<Class<?>> findStepsClasses(Class<?> embedderClass) {
    final String classPath = packagePath(embedderClass);
    List<String> paths = new StoryFinder().findPaths(codeLocationFromParentPackage(embedderClass).getFile(),
            asList("**/*.class"), null);

    transform(paths, new Transformer() {
        @Override//from   w  w  w  .  j  av a  2  s  .  co m
        public Object transform(Object input) {
            return classPath + (removeEnd((String) input, ".class"));
        }
    });

    List<Class<?>> classes = new ArrayList<Class<?>>();
    for (String path : paths) {
        final String className = path.replace("/", ".");
        try {
            Class<?> clazz = Class.forName(className);
            if (clazz.isAnnotationPresent(Steps.class)) {
                classes.add(clazz);
            }
        } catch (ClassNotFoundException ex) {
            LOGGER.error("Could not load the class: " + className);
        }
    }
    return classes;
}

From source file:de.hybris.platform.acceleratorservices.urlencoder.attributes.impl.DefaultLanguageAttributeManager.java

@Override
public Collection<String> getAllAvailableValues() {
    return CollectionUtils.collect(getCommerceCommonI18NService().getAllLanguages(), new Transformer() {
        @Override//w  ww. j av a 2s .  com
        public Object transform(final Object object) {
            return ((LanguageModel) object).getIsocode();
        }
    });
}

From source file:com.texeltek.accumulocloudbaseshim.ByteSequenceShim.java

@SuppressWarnings("unchecked")
public static Collection<cloudbase.core.data.ByteSequence> cloudbaseCollection(
        Collection<ByteSequence> byteSequenceCollection) {
    return CollectionUtils.collect(byteSequenceCollection, new Transformer() {
        @Override//from w  w w.java 2s.c  om
        public Object transform(Object o) {
            return ((ByteSequence) o).impl;
        }
    });
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.degree.execution.ReadExecutionCoursesByExecutionDegreeService.java

@Atomic
public static List run(String executionDegreeId, String executionPeriodId) throws FenixServiceException {

    final ExecutionSemester executionSemester;
    if (StringUtils.isEmpty(executionPeriodId)) {
        executionSemester = ExecutionSemester.readActualExecutionSemester();
    } else {/*w ww . jav a2 s .  c o  m*/
        executionSemester = FenixFramework.getDomainObject(executionPeriodId);
    }

    final ExecutionDegree executionDegree = FenixFramework.getDomainObject(executionDegreeId);
    if (executionDegree == null) {
        throw new NonExistingExecutionDegree();
    }

    Set<ExecutionCourse> executionCourseList = executionDegree.getDegreeCurricularPlan()
            .getExecutionCoursesByExecutionPeriod(executionSemester);

    List infoExecutionCourseList = (List) CollectionUtils.collect(executionCourseList, new Transformer() {

        @Override
        public Object transform(Object input) {
            ExecutionCourse executionCourse = (ExecutionCourse) input;
            InfoExecutionCourse infoExecutionCourse = InfoExecutionCourse.newInfoFromDomain(executionCourse);
            return infoExecutionCourse;
        }
    });

    return infoExecutionCourseList;

}

From source file:net.sf.wickedshell.action.batch.SelectBatchFileAction.java

/**
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 *///  w  ww  . j av a2 s.c o m
@SuppressWarnings("unchecked")
public void run(IAction action) {
    FileDialog fileDialog = new FileDialog(view.getSite().getShell(), SWT.OPEN);
    fileDialog.setText("Select existing Batch File for Batch View");

    List executableFiles = ShellViewUtil.getTargetableExecutableFiles();
    String[] batchFileExtensions = (String[]) CollectionUtils.collect(executableFiles, new Transformer() {
        /**
         * @see org.apache.commons.collections.Transformer#transform(java.lang.Object)
         */
        public Object transform(Object object) {
            IExecutableFile executableFile = (IExecutableFile) object;
            StringBuffer buffer = new StringBuffer();
            buffer.append("*");
            buffer.append(executableFile.getExtension());
            return buffer.toString();
        }
    }).toArray(new String[0]);

    String[] batchFileDescriptions = (String[]) CollectionUtils.collect(executableFiles, new Transformer() {
        public Object transform(Object object) {
            IExecutableFile executableFile = (IExecutableFile) object;
            StringBuffer buffer = new StringBuffer();
            buffer.append(executableFile.getDescription());
            buffer.append(" (*");
            buffer.append(executableFile.getExtension());
            buffer.append(")");
            return buffer.toString();
        }
    }).toArray(new String[0]);

    fileDialog.setFilterExtensions(batchFileExtensions);
    fileDialog.setFilterNames(batchFileDescriptions);

    String selectedBatch = fileDialog.open();
    if (selectedBatch != null) {
        BatchView batchView = (BatchView) view;
        batchView.getBatchManager()
                .addBatchFileDescriptor(IBatchFileDescriptor.Factory.newInstance(selectedBatch));
    }
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.ReadActiveDegreeCurricularPlansByDegreeType.java

private static Collection<InfoDegreeCurricularPlan> getActiveDegreeCurricularPlansByDegreeType(
        final DegreeType degreeType, AccessControlPredicate<Object> permission) {
    List<DegreeCurricularPlan> degreeCurricularPlans = new ArrayList<DegreeCurricularPlan>();
    for (DegreeCurricularPlan dcp : DegreeCurricularPlan.readByDegreeTypeAndState(degreeType,
            DegreeCurricularPlanState.ACTIVE)) {
        if (permission != null) {
            if (!permission.evaluate(dcp.getDegree())) {
                continue;
            }/*ww w .  j a  v  a2  s  . co m*/
        }
        degreeCurricularPlans.add(dcp);
    }

    return CollectionUtils.collect(degreeCurricularPlans, new Transformer() {

        @Override
        public Object transform(Object arg0) {
            DegreeCurricularPlan degreeCurricularPlan = (DegreeCurricularPlan) arg0;
            return InfoDegreeCurricularPlan.newInfoFromDomain(degreeCurricularPlan);
        }

    });
}

From source file:com.texeltek.accumulocloudbaseshim.BatchWriterShim.java

public void addMutations(Iterable<Mutation> iterable) throws MutationsRejectedException {
    try {//from  w w w  . ja  v  a  2 s  . c  om
        impl.addMutations(
                new TransformIterable<Mutation, cloudbase.core.data.Mutation>(iterable, new Transformer() {
                    public Object transform(Object input) {
                        return ((Mutation) input).impl;
                    }
                }));
    } catch (cloudbase.core.client.MutationsRejectedException e) {
        throw new MutationsRejectedException(e);
    }
}

From source file:com.texeltek.accumulocloudbaseshim.FormatterShim.java

@Override
@SuppressWarnings("unchecked")
public void initialize(final Iterable<Map.Entry<Key, Value>> scanner, boolean printTimestamps) {
    impl.initialize(new Iterable<Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value>>() {
        @Override//  w  w  w  . j a v  a  2s.c o m
        public Iterator<Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value>> iterator() {
            return IteratorUtils.transformedIterator(scanner.iterator(), new Transformer() {
                @Override
                public Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value> transform(Object input) {
                    Map.Entry<Key, Value> entry = (Map.Entry<Key, Value>) input;
                    return new AbstractMap.SimpleEntry<cloudbase.core.data.Key, cloudbase.core.data.Value>(
                            entry.getKey().impl, entry.getValue().impl);
                }
            });
        }
    }, printTimestamps);
}

From source file:net.sourceforge.fenixedu.dataTransferObject.InfoExamWithRoomOccupationsAndScopesWithCurricularCoursesWithDegreeAndSemesterAndYear.java

private List copyICurricularCourseScope2InfoCurricularCourseScope(Collection associatedCurricularCourseScopes) {
    List associatedInfoCCScopes = (List) CollectionUtils.collect(associatedCurricularCourseScopes,
            new Transformer() {

                @Override//w  w  w  .  ja va 2  s.  com
                public Object transform(Object arg0) {
                    return InfoCurricularCourseScope.newInfoFromDomain((CurricularCourseScope) arg0);
                }
            });

    return associatedInfoCCScopes;
}

From source file:com.texeltek.accumulocloudbaseshim.BatchScannerShim.java

public Iterator<Map.Entry<Key, Value>> iterator() {
    return new TransformIterator(new CloudbaseBatchScannerCloseableIterator(impl), new Transformer() {
        @Override/*from ww w.  j a  v  a2  s  .  c om*/
        public Object transform(Object input) {
            Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value> entry = (Map.Entry<cloudbase.core.data.Key, cloudbase.core.data.Value>) input;
            return new EntryShim(new Key(entry.getKey()), new Value(entry.getValue()));
        }
    });
}