Example usage for com.google.common.collect Lists transform

List of usage examples for com.google.common.collect Lists transform

Introduction

In this page you can find the example usage for com.google.common.collect Lists transform.

Prototype

@CheckReturnValue
public static <F, T> List<T> transform(List<F> fromList, Function<? super F, ? extends T> function) 

Source Link

Document

Returns a list that applies function to each element of fromList .

Usage

From source file:org.caleydo.view.domino.api.model.typed.TypedGroupSet.java

@Override
public TypedGroupList asList() {
    return new TypedGroupList(
            ImmutableList.copyOf(Lists.transform(groups, new Function<TypedSetGroup, TypedListGroup>() {
                @Override//from   www. j  a  v  a2 s  . c o  m
                public TypedListGroup apply(TypedSetGroup input) {
                    return input.asList();
                }
            })));
}

From source file:io.crate.analyze.symbol.Symbols.java

public static List<DataType> extractTypes(List<? extends Symbol> symbols) {
    return Lists.transform(symbols, TYPES_FUNCTION);
}

From source file:com.dangdang.ddframe.job.internal.reg.SensitiveInfoUtils.java

public static List<String> filterSensitiveIps(final List<String> result) {
    final Map<String, String> fakeIpMap = new HashMap<>();
    final String fakeIpSample = "ip";
    final AtomicInteger step = new AtomicInteger();
    Function<String, String> func = new Function<String, String>() {

        @Override/*from  w ww.j  a va  2s . c o m*/
        public String apply(final String line) {
            final String regex = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}";
            final Pattern pattern = Pattern.compile(regex);
            Matcher matcher = pattern.matcher(line);
            String result = line;
            while (matcher.find()) {
                String realIp = matcher.group();
                String fakeIp = fakeIpMap.get(realIp);
                if (Strings.isNullOrEmpty(fakeIp)) {
                    fakeIp = fakeIpSample + step.incrementAndGet();
                    fakeIpMap.put(realIp, fakeIp);
                }
                result = result.replace(realIp, fakeIp);
            }
            return result;
        }
    };
    return Lists.transform(result, func);
}

From source file:com.dangdang.ddframe.job.internal.util.SensitiveInfoUtils.java

public static List<String> filterSenstiveIps(final List<String> result) {
    final Map<String, String> fakeIpMap = new HashMap<>();
    final String fakeIpSample = "ip";
    final AtomicInteger step = new AtomicInteger();
    Function<String, String> func = new Function<String, String>() {

        @Override/*  w  w  w .j a v  a 2  s  . com*/
        public String apply(final String line) {
            final String regex = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}";
            final Pattern pattern = Pattern.compile(regex);
            Matcher matcher = pattern.matcher(line);
            String result = line;
            while (matcher.find()) {
                String realIp = matcher.group();
                String fakeIp = fakeIpMap.get(realIp);
                if (Strings.isNullOrEmpty(fakeIp)) {
                    fakeIp = fakeIpSample + step.incrementAndGet();
                    fakeIpMap.put(realIp, fakeIp);
                }
                result = result.replace(realIp, fakeIp);
            }
            return result;
        }
    };
    return Lists.transform(result, func);
}

From source file:google.registry.rde.imports.XjcToHostResourceConverter.java

static HostResource convert(XjcRdeHost host) {
    return new HostResource.Builder().setFullyQualifiedHostName(host.getName()).setRepoId(host.getRoid())
            .setCurrentSponsorClientId(host.getClID()).setLastTransferTime(host.getTrDate())
            .setCreationTime(host.getCrDate()).setLastEppUpdateTime(host.getUpDate())
            .setCreationClientId(host.getCrRr().getValue())
            .setLastEppUpdateClientId(host.getUpRr() == null ? null : host.getUpRr().getValue())
            .setStatusValues(ImmutableSet.copyOf(Lists.transform(host.getStatuses(), STATUS_VALUE_CONVERTER)))
            .setInetAddresses(ImmutableSet.copyOf(Lists.transform(host.getAddrs(), ADDR_CONVERTER))).build();
}

From source file:nz.co.testamation.core.reader.SelectRows.java

@Override
public SQLResult select(JdbcTemplate jdbcTemplate) {
    return new SQLResult(
            Lists.transform(jdbcTemplate.queryForList(getSql()), new Function<Map<String, Object>, TableRow>() {
                @Override/*w  ww.  j  av  a  2 s .  c o  m*/
                public TableRow apply(Map<String, Object> stringObjectMap) {
                    return new TableRowImpl(stringObjectMap);
                }
            }));
}

From source file:com.cloudera.oryx.app.serving.als.AbstractALSResource.java

static List<IDValue> toIDValueResponse(List<Pair<String, Double>> pairs, int howMany, int offset) {
    List<Pair<String, Double>> sublist = selectedSublist(pairs, howMany, offset);
    return Lists.transform(sublist, new Function<Pair<String, Double>, IDValue>() {
        @Override/*  w w w .j  a v a  2 s.c o  m*/
        public IDValue apply(Pair<String, Double> idDot) {
            return new IDValue(idDot.getFirst(), idDot.getSecond());
        }
    });
}

From source file:br.com.caelum.vraptor.http.iogi.ArrayAdapter.java

public Object instantiate(final Target<?> target, Parameters parameters) {
    List<Parameter> fixed = Lists.transform(parameters.forTarget(target), new Function<Parameter, Parameter>() {
        int i = 0;

        public Parameter apply(Parameter parameter) {
            if (target.getName().equals(parameter.getName())) {
                return new Parameter(parameter.getName() + "[" + i++ + "]", parameter.getValue());
            }//  www  .  ja  v a2s.  c  om
            return parameter;
        }
    });
    return delegate.instantiate(target, new Parameters(fixed));
}

From source file:com.onboard.domain.transform.TodolistTransform.java

public static TodolistDTO todolistToTodolistWithTodos(Todolist todolist) {
    TodolistDTO todolistDTO = new TodolistDTO();
    BeanUtils.copyProperties(todolist, todolistDTO);
    if (todolist.getTodos() != null) {
        todolistDTO.setTodos(Lists.transform(todolist.getTodos(), TodoTransform.TODO_DTO_FUNCTION));
    }//  w  ww  .j  ava 2 s .  c o m
    return todolistDTO;
}

From source file:edu.cmu.lti.oaqa.ecd.phase.ProcessingStepUtils.java

private static Trace getTraceString(Iterable<Annotation> steps, Function<Annotation, String> f) {
    Joiner joiner = Joiner.on(">").skipNulls();
    List<Annotation> list = new ProcessingStepOrdering().sortedCopy(steps);
    String trace = joiner.join(Lists.transform(list, f));
    return new Trace(trace);
}