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.gradle.internal.operations.trace.BuildOperationTree.java

static List<Map<String, ?>> serialize(List<BuildOperationRecord> roots) {
    return Lists.transform(roots, new Function<BuildOperationRecord, Map<String, ?>>() {
        @Override//from  w w w .  j a  v  a  2  s .c om
        public Map<String, ?> apply(BuildOperationRecord input) {
            return input.toSerializable();
        }
    });
}

From source file:darwin.resourcehandling.handle.ClasspathHelper.java

public static List<URI> getClasspath() {
    Function<URL, URI> func = new Function<URL, URI>() {
        @Override//w ww  . j  a v a2  s  .  c om
        public URI apply(URL f) {
            try {
                return f.toURI();
            } catch (URISyntaxException ex) {
                throw new RuntimeException(ex);
            }
        }
    };

    return Lists.transform(Arrays.asList(getClassLoader().getURLs()), func);
}

From source file:com.xebialabs.deployit.plugins.notifications.email.util.Addresses.java

public static List<Recipient> toRecipients(List<String> addresses, final RecipientType type) {
    return Lists.transform(addresses, new Function<String, Recipient>() {
        @Override//ww  w .j  av  a  2 s .c o  m
        public Recipient apply(String input) {
            return new Recipient(toNameAndAddress(input), type);
        }
    });
}

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

/**
 * ??IP???.//from  w w w .  jav a 2s . c o m
 * 
 * @param target ???
 * @return ????
 */
public static List<String> filterSensitiveIps(final List<String> target) {
    final Map<String, String> fakeIpMap = new HashMap<>();
    final AtomicInteger step = new AtomicInteger();
    return Lists.transform(target, new Function<String, String>() {

        @Override
        public String apply(final String input) {
            Matcher matcher = Pattern.compile(IP_REGEX).matcher(input);
            String result = input;
            while (matcher.find()) {
                String realIp = matcher.group();
                String fakeIp;
                if (fakeIpMap.containsKey(realIp)) {
                    fakeIp = fakeIpMap.get(realIp);
                } else {
                    fakeIp = Joiner.on("").join(FAKE_IP_SAMPLE, step.incrementAndGet());
                    fakeIpMap.put(realIp, fakeIp);
                }
                result = result.replace(realIp, fakeIp);
            }
            return result;
        }
    });
}

From source file:io.druid.query.spec.LegacySegmentSpec.java

private static List<Interval> convertValue(Object intervals) {
    final List<?> intervalStringList;
    if (intervals instanceof String) {
        intervalStringList = Arrays.asList((((String) intervals).split(",")));
    } else if (intervals instanceof Interval) {
        intervalStringList = Arrays.asList(intervals.toString());
    } else if (intervals instanceof Map) {
        intervalStringList = (List) ((Map) intervals).get("intervals");
    } else if (intervals instanceof List) {
        intervalStringList = (List) intervals;
    } else {/*  ww  w  . j  a  v  a  2 s  . com*/
        throw new IAE("Unknown type[%s] for intervals[%s]", intervals.getClass(), intervals);
    }

    return Lists.transform(intervalStringList, new Function<Object, Interval>() {
        @Override
        public Interval apply(Object input) {
            return new Interval(input);
        }
    });
}

From source file:org.apache.cassandra.db.composites.Composites.java

/**
 * Converts the specified <code>Composites</code> into <code>ByteBuffer</code>s.
 *
 * @param composites the composites to convert.
 * @return the <code>ByteBuffer</code>s corresponding to the specified <code>Composites</code>.
 *///from  w w  w.  j  ava 2 s  .c o m
public static List<ByteBuffer> toByteBuffers(List<Composite> composites) {
    return Lists.transform(composites, new Function<Composite, ByteBuffer>() {
        public ByteBuffer apply(Composite composite) {
            return composite.toByteBuffer();
        }
    });
}

From source file:io.druid.query.filter.DimFilters.java

public static DimFilter dimEquals(final String dimension, String... values) {
    return or(Lists.transform(Arrays.asList(values), new Function<String, DimFilter>() {
        @Override/* w w w .  j  a  v  a  2  s . com*/
        public DimFilter apply(String input) {
            return dimEquals(dimension, input);
        }
    }));
}

From source file:io.crate.analyze.Relations.java

static Collection<? extends Path> namesFromOutputs(List<Symbol> outputs) {
    return Lists.transform(outputs, Symbols::pathFromSymbol);
}

From source file:com.metamx.druid.query.segment.LegacySegmentSpec.java

private static List<Interval> convertValue(Object intervals) {
    final List<?> intervalStringList;
    if (intervals instanceof String) {
        intervalStringList = Arrays.asList((((String) intervals).split(",")));
    } else if (intervals instanceof Map) {
        intervalStringList = (List) ((Map) intervals).get("intervals");
    } else if (intervals instanceof List) {
        intervalStringList = (List) intervals;
    } else {/*from   ww w .j av  a  2  s  .co  m*/
        throw new IAE("Unknown type[%s] for intervals[%s]", intervals.getClass(), intervals);
    }

    return Lists.transform(intervalStringList, new Function<Object, Interval>() {
        @Override
        public Interval apply(Object input) {
            return new Interval(input);
        }
    });
}

From source file:com.meiste.greg.ptwgame.RefUtils.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> List<T> deref(List<Ref<T>> reflist) {
    return Lists.transform(reflist, (DerefFunc) DerefFunc.INSTANCE);
}